diff --git a/apps/food/admin.py b/apps/food/admin.py index 7579aff5..d5005adc 100644 --- a/apps/food/admin.py +++ b/apps/food/admin.py @@ -1,3 +1,6 @@ +# Copyright (C) 2018-2024 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + from django.contrib import admin from note_kfet.admin import admin_site diff --git a/apps/food/migrations/0001_initial.py b/apps/food/migrations/0001_initial.py index 49b7a329..b51c8a59 100644 --- a/apps/food/migrations/0001_initial.py +++ b/apps/food/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.28 on 2024-05-21 12:05 +# Generated by Django 2.2.28 on 2024-05-25 20:32 from django.db import migrations, models import django.db.models.deletion @@ -15,14 +15,15 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='Basic_food', + name='BasicFood', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=255, verbose_name='name')), ('is_DLC', models.BooleanField(default=False, verbose_name='is DLC')), ('is_DDM', models.BooleanField(default=False, verbose_name='is DDM')), - ('expiry_date', models.DateTimeField(blank=True, default=django.utils.timezone.now, verbose_name='expiry date')), - ('label', models.ImageField(default='pic/default.png', max_length=255, upload_to='label/', verbose_name='food label')), + ('arrival_date', models.DateTimeField(default=django.utils.timezone.now, verbose_name='arrival date')), + ('expiry_date', models.DateTimeField(blank=True, null=True, verbose_name='expiry date')), + ('label', models.ImageField(max_length=255, upload_to='label/', verbose_name='food label')), ('was_eaten', models.BooleanField(default=False, verbose_name='was eaten')), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='member.Club', verbose_name='owner')), ], @@ -32,7 +33,7 @@ class Migration(migrations.Migration): }, ), migrations.CreateModel( - name='Transformed_food', + name='TransformedFood', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=255, verbose_name='name')), @@ -41,7 +42,7 @@ class Migration(migrations.Migration): ('is_active', models.BooleanField(default=True, verbose_name='is active')), ('was_eaten', models.BooleanField(default=False, verbose_name='was eaten')), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='member.Club', verbose_name='owner')), - ('transformed_ingredient', models.ManyToManyField(blank=True, related_name='transformed_ingredient_inv', to='food.Transformed_food', verbose_name='transformed ingredient')), + ('transformed_ingredient', models.ManyToManyField(blank=True, related_name='transformed_ingredient_inv', to='food.TransformedFood', verbose_name='transformed ingredient')), ], options={ 'verbose_name': 'Transformed food', @@ -53,8 +54,8 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('qr_code_number', models.PositiveIntegerField(verbose_name='QR-code number')), - ('basic_food', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='QR_code', to='food.Basic_food', verbose_name='basic food')), - ('transformed_food_container', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='QR_code', to='food.Transformed_food', verbose_name='transformed food container')), + ('basic_food', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='QR_code', to='food.BasicFood', verbose_name='basic food')), + ('transformed_food_container', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='QR_code', to='food.TransformedFood', verbose_name='transformed food container')), ], options={ 'verbose_name': 'QR-code', @@ -62,9 +63,9 @@ class Migration(migrations.Migration): }, ), migrations.AddField( - model_name='basic_food', + model_name='basicfood', name='transformed_food', - field=models.ManyToManyField(blank=True, related_name='Basic_food', to='food.Transformed_food', verbose_name='transformed food'), + field=models.ManyToManyField(blank=True, related_name='BasicFood', to='food.TransformedFood', verbose_name='transformed food'), ), migrations.CreateModel( name='Allergen', @@ -85,8 +86,8 @@ class Migration(migrations.Migration): ('groundnut', models.BooleanField(default=False, verbose_name='groundnut')), ('sesame', models.BooleanField(default=False, verbose_name='sesame')), ('alcohol', models.BooleanField(default=False, verbose_name='alcohol')), - ('basic_food', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='Allergen', to='food.Basic_food', verbose_name='basic food')), - ('transformed_food', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='Allergen', to='food.Transformed_food', verbose_name='transformed food')), + ('basic_food', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='Allergen', to='food.BasicFood', verbose_name='basic food')), + ('transformed_food', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='Allergen', to='food.TransformedFood', verbose_name='transformed food')), ], options={ 'verbose_name': 'Allergen', diff --git a/apps/food/migrations/0002_auto_20240524_2139.py b/apps/food/migrations/0002_auto_20240524_2139.py deleted file mode 100644 index d4423976..00000000 --- a/apps/food/migrations/0002_auto_20240524_2139.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.2.28 on 2024-05-24 19:39 - -from django.db import migrations, models -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - ('food', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='basic_food', - name='expiry_date', - field=models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True, verbose_name='expiry date'), - ), - ] diff --git a/apps/food/migrations/0003_auto_20240525_1350.py b/apps/food/migrations/0003_auto_20240525_1350.py deleted file mode 100644 index 23321d64..00000000 --- a/apps/food/migrations/0003_auto_20240525_1350.py +++ /dev/null @@ -1,55 +0,0 @@ -# Generated by Django 2.2.28 on 2024-05-25 11:50 - -from django.db import migrations, models -import django.db.models.deletion -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - ('member', '0011_profile_vss_charter_read'), - ('food', '0002_auto_20240524_2139'), - ] - - operations = [ - migrations.CreateModel( - name='BasicFood', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=255, verbose_name='name')), - ('is_DLC', models.BooleanField(default=False, verbose_name='is DLC')), - ('is_DDM', models.BooleanField(default=False, verbose_name='is DDM')), - ('expiry_date', models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True, verbose_name='expiry date')), - ('label', models.ImageField(default='pic/default.png', max_length=255, upload_to='label/', verbose_name='food label')), - ('was_eaten', models.BooleanField(default=False, verbose_name='was eaten')), - ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='member.Club', verbose_name='owner')), - ], - options={ - 'verbose_name': 'Basic food', - 'verbose_name_plural': 'Basic foods', - }, - ), - migrations.AlterField( - model_name='allergen', - name='basic_food', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='Allergen', to='food.BasicFood', verbose_name='basic food'), - ), - migrations.AlterField( - model_name='qr_code', - name='basic_food', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='QR_code', to='food.BasicFood', verbose_name='basic food'), - ), - migrations.RenameModel( - old_name='Transformed_food', - new_name='TransformedFood', - ), - migrations.DeleteModel( - name='Basic_food', - ), - migrations.AddField( - model_name='basicfood', - name='transformed_food', - field=models.ManyToManyField(blank=True, null=True, related_name='BasicFood', to='food.TransformedFood', verbose_name='transformed food'), - ), - ] diff --git a/apps/food/migrations/0004_auto_20240525_1352.py b/apps/food/migrations/0004_auto_20240525_1352.py deleted file mode 100644 index 5c7932c4..00000000 --- a/apps/food/migrations/0004_auto_20240525_1352.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.28 on 2024-05-25 11:52 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('food', '0003_auto_20240525_1350'), - ] - - operations = [ - migrations.AlterField( - model_name='basicfood', - name='transformed_food', - field=models.ManyToManyField(blank=True, related_name='BasicFood', to='food.TransformedFood', verbose_name='transformed food'), - ), - ] diff --git a/apps/food/migrations/0005_auto_20240525_1559.py b/apps/food/migrations/0005_auto_20240525_1559.py deleted file mode 100644 index 88d794b2..00000000 --- a/apps/food/migrations/0005_auto_20240525_1559.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.28 on 2024-05-25 13:59 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('food', '0004_auto_20240525_1352'), - ] - - operations = [ - migrations.AlterField( - model_name='basicfood', - name='label', - field=models.ImageField(max_length=255, upload_to='label/', verbose_name='food label'), - ), - ] diff --git a/apps/food/models.py b/apps/food/models.py index 7bc47da1..44a9f595 100644 --- a/apps/food/models.py +++ b/apps/food/models.py @@ -13,6 +13,12 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ from member.models import Club +################################################################# +# TO DO +# - link allergen with one food (basic or transformed) with check +# - check on basic food +# - check on transformed food +################################################################# class QR_code(models.Model): """ @@ -173,10 +179,14 @@ class BasicFood(models.Model): verbose_name=_("is DDM"), default=False, ) + + arrival_date = models.DateTimeField( + verbose_name=_('arrival date'), + default=timezone.now, + ) expiry_date = models.DateTimeField( verbose_name=_('expiry date'), - default=timezone.now, blank=True, null = True, ) diff --git a/apps/food/templates/food/basic_food_form.html b/apps/food/templates/food/basic_food_form.html index abce7e9b..43cf1c43 100644 --- a/apps/food/templates/food/basic_food_form.html +++ b/apps/food/templates/food/basic_food_form.html @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% block content %}