From 4f60a6783155edc826425d3d7814187a42901cca Mon Sep 17 00:00:00 2001 From: "Ph. SW" Date: Sun, 25 Jun 2023 18:37:29 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20l'interface=20d'administration?= =?UTF-8?q?=20pour=20les=20labels=20(#6513)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ajoute l'auto-complétion du champ pour le slug à partir du nom du label * Ajoute un lien pour accéder à la page listant les contenus ayant tel label --- zds/tutorialv2/admin.py | 1 + zds/tutorialv2/models/labels.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/zds/tutorialv2/admin.py b/zds/tutorialv2/admin.py index e0c4bbeb66..d8591b6663 100644 --- a/zds/tutorialv2/admin.py +++ b/zds/tutorialv2/admin.py @@ -124,6 +124,7 @@ class GoalAdmin(admin.ModelAdmin): class LabelAdmin(admin.ModelAdmin): list_display = ["name", "description"] ordering = ["name"] + prepopulated_fields = {"slug": ("name",)} admin.site.register(PublishableContent, PublishableContentAdmin) diff --git a/zds/tutorialv2/models/labels.py b/zds/tutorialv2/models/labels.py index b9c2646a00..e67d982341 100644 --- a/zds/tutorialv2/models/labels.py +++ b/zds/tutorialv2/models/labels.py @@ -1,4 +1,5 @@ from django.db import models +from django.urls import reverse class Label(models.Model): @@ -21,3 +22,6 @@ class Meta: def __str__(self): return self.name + + def get_absolute_url(self): + return reverse("content:view-labels", args=[self.slug])