Ajout d'un pictogramme pour les catégories (pas encore affiché)

This commit is contained in:
Jean-Marie Favreau 2024-09-14 15:42:55 +02:00
parent 9fdd3edd0e
commit 62060925cd
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# Generated by Django 4.2.9 on 2024-09-14 12:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('agenda_culturel', '0073_alter_event_location'),
]
operations = [
migrations.AddField(
model_name='category',
name='pictogram',
field=models.ImageField(blank=True, help_text='Pictogram of the category', max_length=1024, null=True, upload_to='', verbose_name='Pictogram'),
),
migrations.AlterField(
model_name='event',
name='category',
field=models.ForeignKey(default=None, help_text='Category of the event', null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='agenda_culturel.category', verbose_name='Category'),
),
migrations.AlterField(
model_name='recurrentimport',
name='defaultCategory',
field=models.ForeignKey(default=None, help_text='Category of each imported event', on_delete=django.db.models.deletion.SET_DEFAULT, to='agenda_culturel.category', verbose_name='Category'),
),
]

View File

@ -107,6 +107,15 @@ class Category(models.Model):
null=True,
)
pictogram = models.ImageField(
verbose_name=_("Pictogram"),
help_text=_("Pictogram of the category"),
max_length=1024,
blank=True,
null=True,
)
def save(self, *args, **kwargs):
if self.color is None:
existing_colors = [c.color for c in Category.objects.all()]