Suppression de champs inutiles sur les catégories

This commit is contained in:
Jean-Marie Favreau 2024-11-01 23:09:20 +01:00
parent a7a529c776
commit 597ada73da
4 changed files with 55 additions and 20 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 4.2.9 on 2024-11-01 22:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agenda_culturel', '0096_alter_tag_name'),
]
operations = [
migrations.AlterField(
model_name='category',
name='alt_name',
field=models.CharField(blank=True, help_text='Alternative name used with a time period', max_length=512, null=True, verbose_name='Alternative Name'),
),
migrations.AlterField(
model_name='category',
name='codename',
field=models.CharField(blank=True, help_text='Short name of the category', max_length=3, null=True, verbose_name='Short name'),
),
]

View File

@ -0,0 +1,21 @@
# Generated by Django 4.2.9 on 2024-11-01 22:08
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('agenda_culturel', '0097_alter_category_alt_name_alter_category_codename'),
]
operations = [
migrations.RemoveField(
model_name='category',
name='alt_name',
),
migrations.RemoveField(
model_name='category',
name='codename',
),
]

View File

@ -93,16 +93,7 @@ class Category(models.Model):
name = models.CharField( name = models.CharField(
verbose_name=_("Name"), help_text=_("Category name"), max_length=512 verbose_name=_("Name"), help_text=_("Category name"), max_length=512
) )
alt_name = models.CharField(
verbose_name=_("Alternative Name"),
help_text=_("Alternative name used with a time period"),
max_length=512,
)
codename = models.CharField(
verbose_name=_("Short name"),
help_text=_("Short name of the category"),
max_length=3,
)
color = ColorField( color = ColorField(
verbose_name=_("Color"), verbose_name=_("Color"),
help_text=_("Color used as background for the category"), help_text=_("Color used as background for the category"),

View File

@ -7,21 +7,21 @@ def run():
# divers # divers
categories = [ categories = [
("Théâtre", "Au théâtre", "T"), ("Théâtre"),
("Concert", "Concerts", "C"), ("Concert"),
("Danse", "Danse", "D"), ("Danse"),
("Arts du spectacle", None, "S"), ("Arts du spectacle"),
("Jeune public", "Pour le jeune public", "J"), ("Jeune public"),
("Exposition", "Expositions", "E"), ("Exposition"),
("Conférence", "Conférences", "C"), ("Conférence"),
("Nature", "Événements nature", "N"), ("Nature"),
("Autre", "Autres événements", "A"), ("Autre"),
] ]
if len(Category.objects.all()) <= 1: if len(Category.objects.all()) <= 1:
print("On créée des catégories") print("On créée des catégories")
for c in categories: for c in categories:
cat = Category( cat = Category(
name=c[0], alt_name=c[1] if c[1] is not None else c[0], codename=c[2] name=c[0]
) )
cat.save() cat.save()