add shortterm and change slug to readable field
This commit is contained in:
@@ -22,14 +22,16 @@ class TopicInline(admin.TabularInline):
|
|||||||
verbose_name = "Thema"
|
verbose_name = "Thema"
|
||||||
verbose_name_plural = "Themen"
|
verbose_name_plural = "Themen"
|
||||||
show_change_link = True
|
show_change_link = True
|
||||||
|
readonly_fields = ("slug",)
|
||||||
|
|
||||||
|
|
||||||
class DocumentationInline(admin.TabularInline):
|
class DocumentationInline(admin.TabularInline):
|
||||||
model = Documentation
|
model = Documentation
|
||||||
form = DocumentationInlineForm
|
form = DocumentationInlineForm
|
||||||
extra = 0
|
extra = 0
|
||||||
verbose_name = "Dokument"
|
verbose_name = "Dokumentation"
|
||||||
verbose_name_plural = "Dokument-Übersicht"
|
verbose_name_plural = "Dokumentation-Übersicht"
|
||||||
|
readonly_fields = ("slug",)
|
||||||
|
|
||||||
|
|
||||||
class EtherpadInline(admin.TabularInline):
|
class EtherpadInline(admin.TabularInline):
|
||||||
@@ -52,6 +54,23 @@ class TopicGroupAdmin(admin.ModelAdmin):
|
|||||||
form = TopicGroupAdminForm
|
form = TopicGroupAdminForm
|
||||||
model = TopicGroup
|
model = TopicGroup
|
||||||
search_fields = ("title",)
|
search_fields = ("title",)
|
||||||
|
|
||||||
|
readonly_fields = ("slug",)
|
||||||
|
fieldsets = (
|
||||||
|
(
|
||||||
|
None,
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
"title",
|
||||||
|
"shortterm",
|
||||||
|
"slug",
|
||||||
|
"order",
|
||||||
|
"short_description",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
inlines = (TopicInline,)
|
inlines = (TopicInline,)
|
||||||
|
|
||||||
list_display = ["title", "order"]
|
list_display = ["title", "order"]
|
||||||
@@ -85,6 +104,24 @@ class TopicAdmin(admin.ModelAdmin):
|
|||||||
form = TopicAdminForm
|
form = TopicAdminForm
|
||||||
model = Topic
|
model = Topic
|
||||||
search_fields = ("title",)
|
search_fields = ("title",)
|
||||||
|
|
||||||
|
readonly_fields = ("slug",)
|
||||||
|
fieldsets = (
|
||||||
|
(
|
||||||
|
None,
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
"title",
|
||||||
|
"shortterm",
|
||||||
|
"slug",
|
||||||
|
"topic_group",
|
||||||
|
"task_list",
|
||||||
|
"archive",
|
||||||
|
"description",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
inlines = (DocumentationInline,)
|
inlines = (DocumentationInline,)
|
||||||
|
|
||||||
list_filter = ["topic_group", "archive"]
|
list_filter = ["topic_group", "archive"]
|
||||||
@@ -118,6 +155,23 @@ class TopicAdmin(admin.ModelAdmin):
|
|||||||
class DocumentationAdmin(admin.ModelAdmin):
|
class DocumentationAdmin(admin.ModelAdmin):
|
||||||
form = DocumentationAdminForm
|
form = DocumentationAdminForm
|
||||||
model = Documentation
|
model = Documentation
|
||||||
|
|
||||||
|
readonly_fields = ("slug",)
|
||||||
|
fieldsets = (
|
||||||
|
(
|
||||||
|
None,
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
"title",
|
||||||
|
"shortterm",
|
||||||
|
"slug",
|
||||||
|
"topic",
|
||||||
|
"description",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
inlines = (
|
inlines = (
|
||||||
EtherpadInline,
|
EtherpadInline,
|
||||||
FileUploadInline,
|
FileUploadInline,
|
||||||
|
|||||||
@@ -14,58 +14,56 @@ class DateInput(forms.DateInput):
|
|||||||
class TopicGroupAdminForm(forms.ModelForm):
|
class TopicGroupAdminForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TopicGroup
|
model = TopicGroup
|
||||||
fields = [
|
fields = "__all__"
|
||||||
"title",
|
|
||||||
"slug",
|
|
||||||
"order",
|
|
||||||
"short_description",
|
|
||||||
]
|
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
|
"shortterm": _("Kürzel für Link"),
|
||||||
"slug": _("Permalink"),
|
"slug": _("Permalink"),
|
||||||
"short_description": _("Kurzbeschreibung"),
|
"short_description": _("Kurzbeschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
help_texts = {
|
||||||
|
"shortterm": _("max. 10 Zeichen erlaubt."),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TopicAdminForm(forms.ModelForm):
|
class TopicAdminForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Topic
|
model = Topic
|
||||||
fields = [
|
fields = "__all__"
|
||||||
"title",
|
|
||||||
"slug",
|
|
||||||
"topic_group",
|
|
||||||
"task_list",
|
|
||||||
"archive",
|
|
||||||
"description",
|
|
||||||
]
|
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
|
"shortterm": _("Kürzel für Link"),
|
||||||
"slug": _("Permalink"),
|
"slug": _("Permalink"),
|
||||||
"task_list": _("Aufgabenbereich"),
|
"task_list": _("Aufgabenbereich"),
|
||||||
"description": _("Beschreibung"),
|
"description": _("Beschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
help_texts = {
|
||||||
|
"shortterm": _("max. 10 Zeichen erlaubt."),
|
||||||
|
}
|
||||||
|
|
||||||
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
||||||
|
|
||||||
|
|
||||||
class DocumentationAdminForm(forms.ModelForm):
|
class DocumentationAdminForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Documentation
|
model = Documentation
|
||||||
fields = [
|
fields = "__all__"
|
||||||
"title",
|
|
||||||
"slug",
|
|
||||||
"topic",
|
|
||||||
"description",
|
|
||||||
]
|
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
|
"shortterm": _("Kürzel für Link"),
|
||||||
"slug": _("Permalink"),
|
"slug": _("Permalink"),
|
||||||
"description": _("Beschreibung"),
|
"description": _("Beschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
help_texts = {
|
||||||
|
"shortterm": _("max. 10 Zeichen erlaubt."),
|
||||||
|
}
|
||||||
|
|
||||||
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
||||||
|
|
||||||
|
|
||||||
@@ -94,11 +92,13 @@ class TopicInlineForm(forms.ModelForm):
|
|||||||
model = Topic
|
model = Topic
|
||||||
fields = [
|
fields = [
|
||||||
"title",
|
"title",
|
||||||
|
"shortterm",
|
||||||
"slug",
|
"slug",
|
||||||
]
|
]
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
|
"shortterm": _("Kürzel für Link"),
|
||||||
"slug": _("Permalink"),
|
"slug": _("Permalink"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,11 +108,13 @@ class DocumentationInlineForm(forms.ModelForm):
|
|||||||
model = Documentation
|
model = Documentation
|
||||||
fields = [
|
fields = [
|
||||||
"title",
|
"title",
|
||||||
|
"shortterm",
|
||||||
"slug",
|
"slug",
|
||||||
]
|
]
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
|
"shortterm": _("Kürzel für Link"),
|
||||||
"slug": _("Permalink"),
|
"slug": _("Permalink"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class TopicGroup(models.Model):
|
class TopicGroup(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
title = models.CharField(verbose_name="Titel", max_length=128)
|
||||||
|
|
||||||
|
shortterm = models.CharField(max_length=10, unique=True)
|
||||||
slug = models.SlugField(max_length=10, unique=True)
|
slug = models.SlugField(max_length=10, unique=True)
|
||||||
|
|
||||||
short_description = models.TextField(null=True, blank=True)
|
short_description = models.TextField(null=True, blank=True)
|
||||||
@@ -40,13 +42,15 @@ class TopicGroup(models.Model):
|
|||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.slug:
|
if not self.slug:
|
||||||
self.slug = slugify(self.title)
|
self.slug = slugify(self.shortterm)
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class Topic(models.Model):
|
class Topic(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
title = models.CharField(verbose_name="Titel", max_length=128)
|
||||||
|
|
||||||
|
shortterm = models.CharField(max_length=10, unique=True)
|
||||||
slug = models.SlugField(max_length=10, unique=True)
|
slug = models.SlugField(max_length=10, unique=True)
|
||||||
|
|
||||||
archive = models.BooleanField(verbose_name="Archiv", default=False)
|
archive = models.BooleanField(verbose_name="Archiv", default=False)
|
||||||
@@ -81,6 +85,8 @@ class Topic(models.Model):
|
|||||||
|
|
||||||
class Documentation(models.Model):
|
class Documentation(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
title = models.CharField(verbose_name="Titel", max_length=128)
|
||||||
|
|
||||||
|
shortterm = models.CharField(max_length=10, unique=True)
|
||||||
slug = models.SlugField(max_length=10)
|
slug = models.SlugField(max_length=10)
|
||||||
|
|
||||||
description = models.TextField(null=True, blank=True)
|
description = models.TextField(null=True, blank=True)
|
||||||
@@ -113,7 +119,7 @@ class Documentation(models.Model):
|
|||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.slug:
|
if not self.slug:
|
||||||
self.slug = slugify(self.title)
|
self.slug = slugify(self.shortterm)
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,15 @@ class TaskAdmin(admin.ModelAdmin):
|
|||||||
form = TaskAdminForm
|
form = TaskAdminForm
|
||||||
model = Task
|
model = Task
|
||||||
inlines = (DocumentInline,)
|
inlines = (DocumentInline,)
|
||||||
|
|
||||||
|
readonly_fields = ("slug",)
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
{
|
{
|
||||||
"fields": (
|
"fields": (
|
||||||
"title",
|
"title",
|
||||||
|
"shortterm",
|
||||||
"slug",
|
"slug",
|
||||||
"task_list",
|
"task_list",
|
||||||
"assigned_to",
|
"assigned_to",
|
||||||
@@ -74,6 +77,21 @@ class TaskListAdmin(admin.ModelAdmin):
|
|||||||
form = TaskListAdminForm
|
form = TaskListAdminForm
|
||||||
model = TaskList
|
model = TaskList
|
||||||
|
|
||||||
|
readonly_fields = ("slug",)
|
||||||
|
fieldsets = (
|
||||||
|
(
|
||||||
|
None,
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
"name",
|
||||||
|
"shortterm",
|
||||||
|
"slug",
|
||||||
|
"users",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def add_view(self, request, form_url="", extra_context=None):
|
def add_view(self, request, form_url="", extra_context=None):
|
||||||
extra_context = extra_context or {}
|
extra_context = extra_context or {}
|
||||||
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ class TaskAdminForm(forms.ModelForm):
|
|||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
|
"shortterm": _("Kürzel für den Link"),
|
||||||
|
"slug": _("Permalink"),
|
||||||
"task_list": _("Aufgabenbereich"),
|
"task_list": _("Aufgabenbereich"),
|
||||||
"due_date": _("Fälligkeit"),
|
"due_date": _("Fälligkeit"),
|
||||||
"completed": _("Abgeschlossen"),
|
"completed": _("Abgeschlossen"),
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ from .managers import TaskManager
|
|||||||
|
|
||||||
class TaskList(models.Model):
|
class TaskList(models.Model):
|
||||||
name = models.CharField(max_length=128)
|
name = models.CharField(max_length=128)
|
||||||
|
|
||||||
|
shortterm = models.CharField(max_length=128, unique=True, null=True, blank=True)
|
||||||
slug = models.SlugField(unique=True, null=True, blank=True)
|
slug = models.SlugField(unique=True, null=True, blank=True)
|
||||||
|
|
||||||
users = models.ManyToManyField(User, blank=True)
|
users = models.ManyToManyField(User, blank=True)
|
||||||
@@ -32,12 +34,17 @@ class TaskList(models.Model):
|
|||||||
return reverse("tasks:index")
|
return reverse("tasks:index")
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if not self.slug:
|
if not self.shortterm:
|
||||||
self.slug = slugify(self.name)
|
self.slug = slugify(self.name)
|
||||||
|
|
||||||
|
if not self.slug:
|
||||||
|
self.slug = slugify(self.shortterm)
|
||||||
|
|
||||||
|
|
||||||
class Task(models.Model):
|
class Task(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
title = models.CharField(verbose_name="Titel", max_length=128)
|
||||||
|
|
||||||
|
shortterm = models.CharField(max_length=128, null=True, blank=True)
|
||||||
slug = models.SlugField(null=True, blank=True)
|
slug = models.SlugField(null=True, blank=True)
|
||||||
|
|
||||||
task_list = models.ForeignKey(
|
task_list = models.ForeignKey(
|
||||||
@@ -83,9 +90,12 @@ class Task(models.Model):
|
|||||||
return reverse("tasks:task-detail", kwargs={"pk": self.id})
|
return reverse("tasks:task-detail", kwargs={"pk": self.id})
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if not self.slug:
|
if not self.shortterm:
|
||||||
self.slug = slugify(self.title)
|
self.slug = slugify(self.title)
|
||||||
|
|
||||||
|
if not self.slug:
|
||||||
|
self.slug = slugify(self.shortterm)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.completed and not self.completed_date:
|
if self.completed and not self.completed_date:
|
||||||
self.completed_date = timezone.now().date()
|
self.completed_date = timezone.now().date()
|
||||||
|
|||||||
Reference in New Issue
Block a user