From c376aea7871e813387d23141426d35db1ef47820 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 27 Aug 2025 20:45:48 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20cat=C3=A9gorie=20de=20documents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beesgospel/admin.py | 3 ++- .../migrations/0004_document_categorie.py | 17 +++++++++++++++++ beesgospel/models.py | 7 +++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 beesgospel/migrations/0004_document_categorie.py diff --git a/beesgospel/admin.py b/beesgospel/admin.py index 35f08e5..afcc0ed 100644 --- a/beesgospel/admin.py +++ b/beesgospel/admin.py @@ -14,7 +14,8 @@ class AgendaAdmin(admin.ModelAdmin): @admin.register(Document) class DocumentAdmin(admin.ModelAdmin): - list_display = ["titre", "quand", "prive"] + list_display = ["titre", "quand", "categorie", "prive"] + list_filter = ["categorie"] ordering = ["-quand"] diff --git a/beesgospel/migrations/0004_document_categorie.py b/beesgospel/migrations/0004_document_categorie.py new file mode 100644 index 0000000..0cdfb85 --- /dev/null +++ b/beesgospel/migrations/0004_document_categorie.py @@ -0,0 +1,17 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('beesgospel', '0003_membre_annee_entree_date_naissance'), + ] + + operations = [ + migrations.AddField( + model_name='document', + name='categorie', + field=models.CharField(choices=[('video', 'Vidéo'), ('audio', 'Audio'), ('photos', 'Photos'), ('doc', 'Document')], default='doc', max_length=30, verbose_name='Catégorie'), + preserve_default=False, + ), + ] diff --git a/beesgospel/models.py b/beesgospel/models.py index b167719..83d63b1 100644 --- a/beesgospel/models.py +++ b/beesgospel/models.py @@ -63,11 +63,18 @@ class Agenda(models.Model): class Document(models.Model): + class Categories(models.TextChoices): + VIDEO = "video", "Vidéo" + AUDIO = "audio", "Audio" + PHOTOS = "photos", "Photos" + DOCUMENT = "doc", "Document" + fichier = models.FileField("Fichier", upload_to="documents", blank=True) url = models.URLField("URL", blank=True) quand = models.DateField("Date") titre = models.CharField("Titre", max_length=150) infos = models.TextField("Infos", blank=True) + categorie = models.CharField("Catégorie", max_length=30, choices=Categories) prive = models.BooleanField( "Privé", default=False, help_text=( "Un document privé ne peut être consulté que par les membres de "