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_plural = "Themen"
|
||||
show_change_link = True
|
||||
readonly_fields = ("slug",)
|
||||
|
||||
|
||||
class DocumentationInline(admin.TabularInline):
|
||||
model = Documentation
|
||||
form = DocumentationInlineForm
|
||||
extra = 0
|
||||
verbose_name = "Dokument"
|
||||
verbose_name_plural = "Dokument-Übersicht"
|
||||
verbose_name = "Dokumentation"
|
||||
verbose_name_plural = "Dokumentation-Übersicht"
|
||||
readonly_fields = ("slug",)
|
||||
|
||||
|
||||
class EtherpadInline(admin.TabularInline):
|
||||
@@ -52,6 +54,23 @@ class TopicGroupAdmin(admin.ModelAdmin):
|
||||
form = TopicGroupAdminForm
|
||||
model = TopicGroup
|
||||
search_fields = ("title",)
|
||||
|
||||
readonly_fields = ("slug",)
|
||||
fieldsets = (
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"title",
|
||||
"shortterm",
|
||||
"slug",
|
||||
"order",
|
||||
"short_description",
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
inlines = (TopicInline,)
|
||||
|
||||
list_display = ["title", "order"]
|
||||
@@ -85,6 +104,24 @@ class TopicAdmin(admin.ModelAdmin):
|
||||
form = TopicAdminForm
|
||||
model = Topic
|
||||
search_fields = ("title",)
|
||||
|
||||
readonly_fields = ("slug",)
|
||||
fieldsets = (
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"title",
|
||||
"shortterm",
|
||||
"slug",
|
||||
"topic_group",
|
||||
"task_list",
|
||||
"archive",
|
||||
"description",
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
inlines = (DocumentationInline,)
|
||||
|
||||
list_filter = ["topic_group", "archive"]
|
||||
@@ -118,6 +155,23 @@ class TopicAdmin(admin.ModelAdmin):
|
||||
class DocumentationAdmin(admin.ModelAdmin):
|
||||
form = DocumentationAdminForm
|
||||
model = Documentation
|
||||
|
||||
readonly_fields = ("slug",)
|
||||
fieldsets = (
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"title",
|
||||
"shortterm",
|
||||
"slug",
|
||||
"topic",
|
||||
"description",
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
inlines = (
|
||||
EtherpadInline,
|
||||
FileUploadInline,
|
||||
|
||||
@@ -14,58 +14,56 @@ class DateInput(forms.DateInput):
|
||||
class TopicGroupAdminForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = TopicGroup
|
||||
fields = [
|
||||
"title",
|
||||
"slug",
|
||||
"order",
|
||||
"short_description",
|
||||
]
|
||||
fields = "__all__"
|
||||
|
||||
labels = {
|
||||
"title": _("Titel"),
|
||||
"shortterm": _("Kürzel für Link"),
|
||||
"slug": _("Permalink"),
|
||||
"short_description": _("Kurzbeschreibung"),
|
||||
}
|
||||
|
||||
help_texts = {
|
||||
"shortterm": _("max. 10 Zeichen erlaubt."),
|
||||
}
|
||||
|
||||
|
||||
class TopicAdminForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Topic
|
||||
fields = [
|
||||
"title",
|
||||
"slug",
|
||||
"topic_group",
|
||||
"task_list",
|
||||
"archive",
|
||||
"description",
|
||||
]
|
||||
fields = "__all__"
|
||||
|
||||
labels = {
|
||||
"title": _("Titel"),
|
||||
"shortterm": _("Kürzel für Link"),
|
||||
"slug": _("Permalink"),
|
||||
"task_list": _("Aufgabenbereich"),
|
||||
"description": _("Beschreibung"),
|
||||
}
|
||||
|
||||
help_texts = {
|
||||
"shortterm": _("max. 10 Zeichen erlaubt."),
|
||||
}
|
||||
|
||||
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
||||
|
||||
|
||||
class DocumentationAdminForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Documentation
|
||||
fields = [
|
||||
"title",
|
||||
"slug",
|
||||
"topic",
|
||||
"description",
|
||||
]
|
||||
fields = "__all__"
|
||||
|
||||
labels = {
|
||||
"title": _("Titel"),
|
||||
"shortterm": _("Kürzel für Link"),
|
||||
"slug": _("Permalink"),
|
||||
"description": _("Beschreibung"),
|
||||
}
|
||||
|
||||
help_texts = {
|
||||
"shortterm": _("max. 10 Zeichen erlaubt."),
|
||||
}
|
||||
|
||||
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
||||
|
||||
|
||||
@@ -94,11 +92,13 @@ class TopicInlineForm(forms.ModelForm):
|
||||
model = Topic
|
||||
fields = [
|
||||
"title",
|
||||
"shortterm",
|
||||
"slug",
|
||||
]
|
||||
|
||||
labels = {
|
||||
"title": _("Titel"),
|
||||
"shortterm": _("Kürzel für Link"),
|
||||
"slug": _("Permalink"),
|
||||
}
|
||||
|
||||
@@ -108,11 +108,13 @@ class DocumentationInlineForm(forms.ModelForm):
|
||||
model = Documentation
|
||||
fields = [
|
||||
"title",
|
||||
"shortterm",
|
||||
"slug",
|
||||
]
|
||||
|
||||
labels = {
|
||||
"title": _("Titel"),
|
||||
"shortterm": _("Kürzel für Link"),
|
||||
"slug": _("Permalink"),
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class TopicGroup(models.Model):
|
||||
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)
|
||||
|
||||
short_description = models.TextField(null=True, blank=True)
|
||||
@@ -40,13 +42,15 @@ class TopicGroup(models.Model):
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.slug:
|
||||
self.slug = slugify(self.title)
|
||||
self.slug = slugify(self.shortterm)
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class Topic(models.Model):
|
||||
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)
|
||||
|
||||
archive = models.BooleanField(verbose_name="Archiv", default=False)
|
||||
@@ -81,6 +85,8 @@ class Topic(models.Model):
|
||||
|
||||
class Documentation(models.Model):
|
||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
||||
|
||||
shortterm = models.CharField(max_length=10, unique=True)
|
||||
slug = models.SlugField(max_length=10)
|
||||
|
||||
description = models.TextField(null=True, blank=True)
|
||||
@@ -113,7 +119,7 @@ class Documentation(models.Model):
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.slug:
|
||||
self.slug = slugify(self.title)
|
||||
self.slug = slugify(self.shortterm)
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user