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)
|
||||
|
||||
|
||||
@@ -16,12 +16,15 @@ class TaskAdmin(admin.ModelAdmin):
|
||||
form = TaskAdminForm
|
||||
model = Task
|
||||
inlines = (DocumentInline,)
|
||||
|
||||
readonly_fields = ("slug",)
|
||||
fieldsets = (
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"title",
|
||||
"shortterm",
|
||||
"slug",
|
||||
"task_list",
|
||||
"assigned_to",
|
||||
@@ -74,6 +77,21 @@ class TaskListAdmin(admin.ModelAdmin):
|
||||
form = TaskListAdminForm
|
||||
model = TaskList
|
||||
|
||||
readonly_fields = ("slug",)
|
||||
fieldsets = (
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"name",
|
||||
"shortterm",
|
||||
"slug",
|
||||
"users",
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
def add_view(self, request, form_url="", extra_context=None):
|
||||
extra_context = extra_context or {}
|
||||
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
||||
|
||||
@@ -48,6 +48,8 @@ class TaskAdminForm(forms.ModelForm):
|
||||
|
||||
labels = {
|
||||
"title": _("Titel"),
|
||||
"shortterm": _("Kürzel für den Link"),
|
||||
"slug": _("Permalink"),
|
||||
"task_list": _("Aufgabenbereich"),
|
||||
"due_date": _("Fälligkeit"),
|
||||
"completed": _("Abgeschlossen"),
|
||||
|
||||
@@ -15,6 +15,8 @@ from .managers import TaskManager
|
||||
|
||||
class TaskList(models.Model):
|
||||
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)
|
||||
|
||||
users = models.ManyToManyField(User, blank=True)
|
||||
@@ -32,12 +34,17 @@ class TaskList(models.Model):
|
||||
return reverse("tasks:index")
|
||||
|
||||
def clean(self):
|
||||
if not self.slug:
|
||||
if not self.shortterm:
|
||||
self.slug = slugify(self.name)
|
||||
|
||||
if not self.slug:
|
||||
self.slug = slugify(self.shortterm)
|
||||
|
||||
|
||||
class Task(models.Model):
|
||||
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)
|
||||
|
||||
task_list = models.ForeignKey(
|
||||
@@ -83,9 +90,12 @@ class Task(models.Model):
|
||||
return reverse("tasks:task-detail", kwargs={"pk": self.id})
|
||||
|
||||
def clean(self):
|
||||
if not self.slug:
|
||||
if not self.shortterm:
|
||||
self.slug = slugify(self.title)
|
||||
|
||||
if not self.slug:
|
||||
self.slug = slugify(self.shortterm)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.completed and not self.completed_date:
|
||||
self.completed_date = timezone.now().date()
|
||||
|
||||
Reference in New Issue
Block a user