diff --git a/apps/food/forms.py b/apps/food/forms.py index ad308727..34a4f5f0 100644 --- a/apps/food/forms.py +++ b/apps/food/forms.py @@ -11,7 +11,20 @@ from note_kfet.inputs import Autocomplete, DateTimePickerInput from note_kfet.middlewares import get_current_request from permission.backends import PermissionBackend -from .models import BasicFood, TransformedFood +from .models import BasicFood, QRCode, TransformedFood + + +class AddIngredientForms(forms.ModelForm): + """ + Form for add an ingredient + """ + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields['ingredient'].queryset = self.fields['ingredient'].queryset.filter(is_ready=False) + + class Meta: + model = TransformedFood + fields = ('ingredient',) class BasicFoodForms(forms.ModelForm): @@ -42,6 +55,19 @@ class BasicFoodForms(forms.ModelForm): } +class QRCodeForms(forms.ModelForm): + """ + Form for create QRCode + """ + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields['food_container'].queryset = self.fields['food_container'].queryset.filter(is_ready=False) + + class Meta: + model = QRCode + fields = ('food_container',) + + class TransformedFoodForms(forms.ModelForm): """ Form for add transformed food diff --git a/apps/food/migrations/0001_initial.py b/apps/food/migrations/0001_initial.py index 7d7d6745..011d0f3f 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-07-03 07:40 +# Generated by Django 2.2.28 on 2024-07-05 08:57 from django.db import migrations, models import django.db.models.deletion @@ -10,8 +10,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('member', '0011_profile_vss_charter_read'), ('contenttypes', '0002_remove_content_type_name'), + ('member', '0011_profile_vss_charter_read'), ] operations = [ @@ -19,7 +19,7 @@ class Migration(migrations.Migration): name='Allergen', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=255, null=True, verbose_name='name')), + ('name', models.CharField(max_length=255, verbose_name='name')), ], options={ 'verbose_name': 'Allergen', @@ -33,7 +33,7 @@ class Migration(migrations.Migration): ('name', models.CharField(max_length=255, verbose_name='name')), ('expiry_date', models.DateTimeField(verbose_name='expiry date')), ('was_eaten', models.BooleanField(default=False, verbose_name='was eaten')), - ('code', models.IntegerField(unique=True, verbose_name='code')), + ('is_ready', models.BooleanField(default=False, verbose_name='is ready')), ('allergens', models.ManyToManyField(blank=True, to='food.Allergen', verbose_name='allergen')), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='member.Club', verbose_name='owner')), ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_food.food_set+', to='contenttypes.ContentType')), @@ -47,7 +47,7 @@ class Migration(migrations.Migration): fields=[ ('food_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='food.Food')), ('date_type', models.CharField(choices=[('DLC', 'DLC'), ('DDM', 'DDM')], max_length=255)), - ('arrival_date', models.DateTimeField(blank=True, default=django.utils.timezone.now, verbose_name='arrival date')), + ('arrival_date', models.DateTimeField(default=django.utils.timezone.now, verbose_name='arrival date')), ], options={ 'verbose_name': 'Basic food', @@ -55,6 +55,18 @@ class Migration(migrations.Migration): }, bases=('food.food',), ), + migrations.CreateModel( + name='QRCode', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('qr_code_number', models.PositiveIntegerField(unique=True, verbose_name='QR-code number')), + ('food_container', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='QR_code', to='food.Food', verbose_name='food container')), + ], + options={ + 'verbose_name': 'QR-code', + 'verbose_name_plural': 'QR-codes', + }, + ), migrations.CreateModel( name='TransformedFood', fields=[ diff --git a/apps/food/migrations/0002_auto_20240703_1549.py b/apps/food/migrations/0002_auto_20240703_1549.py deleted file mode 100644 index fd3732c2..00000000 --- a/apps/food/migrations/0002_auto_20240703_1549.py +++ /dev/null @@ -1,30 +0,0 @@ -# Generated by Django 2.2.28 on 2024-07-03 13:49 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('food', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='food', - name='code', - ), - migrations.CreateModel( - name='QRCode', - 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')), - ('food_container', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='QR_code', to='food.Food', unique=True, verbose_name='food container')), - ], - options={ - 'verbose_name': 'QR-code', - 'verbose_name_plural': 'QR-codes', - }, - ), - ] diff --git a/apps/food/models.py b/apps/food/models.py index 367e47f9..bc5103b5 100644 --- a/apps/food/models.py +++ b/apps/food/models.py @@ -7,13 +7,6 @@ from django.utils.translation import gettext_lazy as _ from member.models import Club from polymorphic.models import PolymorphicModel -################################################################# -# TO DO -# - link allergen with one food (basic or transformed) with check -# - check on basic food -# - check on transformed food -################################################################# - class QRCode(models.Model): """ @@ -21,13 +14,13 @@ class QRCode(models.Model): """ qr_code_number = models.PositiveIntegerField( verbose_name=_("QR-code number"), + unique=True, ) - food_container = models.ForeignKey( + food_container = models.OneToOneField( 'Food', on_delete=models.PROTECT, related_name='QR_code', - unique=True, verbose_name=_('food container'), ) @@ -77,6 +70,7 @@ class Food(PolymorphicModel): expiry_date = models.DateTimeField( verbose_name=_('expiry date'), + null=False, ) was_eaten = models.BooleanField( @@ -84,6 +78,11 @@ class Food(PolymorphicModel): verbose_name=_('was eaten'), ) + is_ready = models.BooleanField( + default=False, + verbose_name=_('is ready'), + ) + def __str__(self): return self.name @@ -111,7 +110,6 @@ class BasicFood(Food): arrival_date = models.DateTimeField( verbose_name=_('arrival date'), default=timezone.now, - blank=True, # TEMPORARY ) # label = models.ImageField( diff --git a/apps/food/tables.py b/apps/food/tables.py new file mode 100644 index 00000000..c824e42e --- /dev/null +++ b/apps/food/tables.py @@ -0,0 +1,19 @@ +# Copyright (C) 2018-2024 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +import django_tables2 as tables +from django_tables2 import A + +from .models import TransformedFood + + +class TransformedFoodTable(tables.Table): + name = tables.LinkColumn( + 'food:food_view', + args=[A('pk'), ], + ) + + class Meta: + model = TransformedFood + template_name = 'django_tables2/bootstrap4.html' + fields = ('name', ) diff --git a/apps/food/templates/food/add_ingredient_form.html b/apps/food/templates/food/add_ingredient_form.html new file mode 100644 index 00000000..86e3b03e --- /dev/null +++ b/apps/food/templates/food/add_ingredient_form.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% comment %} +SPDX-License-Identifier: GPL-3.0-or-later +{% endcomment %} +{% load i18n crispy_forms_tags %} + +{% block content %} +
+

+ HTML not finished
+ {{ title }} +

+
+
+ {% csrf_token %} + {{ form|crispy }} + +
+
+
+{% endblock %} diff --git a/apps/food/templates/food/basicfood_detail.html b/apps/food/templates/food/basicfood_detail.html index 86b7ac9e..b0629f58 100644 --- a/apps/food/templates/food/basicfood_detail.html +++ b/apps/food/templates/food/basicfood_detail.html @@ -11,8 +11,8 @@ SPDX-License-Identifier: GPL-3.0-or-later {{ title }}
-

name : {{ food.name }}

- Update +

name : {{ food.name }}

+ Update
{% endblock %} diff --git a/apps/food/templates/food/create_food_form.html b/apps/food/templates/food/create_food_form.html index 137c1880..5728dd25 100644 --- a/apps/food/templates/food/create_food_form.html +++ b/apps/food/templates/food/create_food_form.html @@ -10,12 +10,12 @@ SPDX-License-Identifier: GPL-3.0-or-later {{ title }}
-
- +
+ +
{% endblock %} diff --git a/apps/food/templates/food/create_qrcode_form.html b/apps/food/templates/food/create_qrcode_form.html index 6af507ca..74f3ec29 100644 --- a/apps/food/templates/food/create_qrcode_form.html +++ b/apps/food/templates/food/create_qrcode_form.html @@ -2,6 +2,7 @@ {% comment %} SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} +{% load i18n crispy_forms_tags %} {% block content %}
@@ -9,13 +10,20 @@ SPDX-License-Identifier: GPL-3.0-or-later HTML not finished
{{ title }} -
-
- +
+
+ -
+
+
+
+
+ {% csrf_token %} + {{ form|crispy }} + +
+
{% endblock %} diff --git a/apps/food/templates/food/qrcode_detail.html b/apps/food/templates/food/qrcode_detail.html index 5e11ecf4..c74dd0e3 100644 --- a/apps/food/templates/food/qrcode_detail.html +++ b/apps/food/templates/food/qrcode_detail.html @@ -11,13 +11,14 @@ SPDX-License-Identifier: GPL-3.0-or-later {{ title }}
-

qrcode : {{ qrcode.qr_code_number }}

-

name : {{ qrcode.food_container.name }}

- {% if qrcode.food_container.polymorphic_ctype.name == 'Basic food' %} - Update - {% else %} - Update - {% endif %} +

qrcode : {{ qrcode.qr_code_number }}

+

name : {{ qrcode.food_container.name }}

+ {% if qrcode.food_container.polymorphic_ctype.name == 'Basic food' %} + Update + {% else %} + Update + {% endif %} + Add the ingrdient
{% endblock %} diff --git a/apps/food/templates/food/transformedfood_detail.html b/apps/food/templates/food/transformedfood_detail.html index d73b0d09..f2604c65 100644 --- a/apps/food/templates/food/transformedfood_detail.html +++ b/apps/food/templates/food/transformedfood_detail.html @@ -13,6 +13,18 @@ SPDX-License-Identifier: GPL-3.0-or-later

name : {{ food.name }}

owner : {{ food.owner }}

+

allergens :

+ +

ingredients :

+ Update
diff --git a/apps/food/templates/food/transformedfood_list.html b/apps/food/templates/food/transformedfood_list.html new file mode 100644 index 00000000..a7b276fc --- /dev/null +++ b/apps/food/templates/food/transformedfood_list.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} +{% comment %} +SPDX-License-Identifier: GPL-3.0-or-later +{% endcomment %} +{% load render_table from django_tables2 %} +{% load i18n %} + +{% block content %} +
+

+ Transformed food +

+ + {% render_table table %} +
+{% endblock %} diff --git a/apps/food/urls.py b/apps/food/urls.py index c422e514..f47f5fa8 100644 --- a/apps/food/urls.py +++ b/apps/food/urls.py @@ -8,6 +8,7 @@ from . import views app_name = 'food' urlpatterns = [ + path('', views.TransfomedListView.as_view(), name='food_list'), path('', views.QRCodeView.as_view(), name='qrcode_view'), path('detail/', views.FoodView.as_view(), name='food_view'), @@ -15,9 +16,10 @@ urlpatterns = [ path('create', views.FoodCreateView.as_view(), name='food_create'), path('/create_qrcode/basic', views.QRCodeBasicFoodCreateView.as_view(), name='qrcode_basic_create'), path('/create_qrcode/transformed', views.QRCodeTransformedFoodCreateView.as_view(), name='qrcode_transformed_create'), - path('create/basic', views.BasicFoodCreateView.as_view(), name='basic_create'), path('create/transformed', views.TransformedFoodCreateView.as_view(), name='transformed_create'), path('update/basic/', views.BasicFoodUpdateView.as_view(), name='basic_update'), path('update/transformed/', views.TransformedFoodUpdateView.as_view(), name='transformed_update'), + + path('add/', views.AddIngredientView.as_view(), name='add_ingredient'), ] diff --git a/apps/food/views.py b/apps/food/views.py index 5964f3f7..9e79689d 100644 --- a/apps/food/views.py +++ b/apps/food/views.py @@ -6,69 +6,62 @@ from datetime import timedelta from django.db import transaction from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpResponseRedirect +from django_tables2.views import SingleTableView from django.urls import reverse from django.utils.translation import gettext_lazy as _ from django.utils import timezone from django.views.generic import DetailView, UpdateView, TemplateView +from django.views.generic.edit import FormView from permission.views import ProtectQuerysetMixin, ProtectedCreateView -from .forms import BasicFoodForms, TransformedFoodForms +from .forms import AddIngredientForms, BasicFoodForms, QRCodeForms, TransformedFoodForms from .models import BasicFood, Food, QRCode, TransformedFood +from .tables import TransformedFoodTable -class QRCodeView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): +class AddIngredientView(ProtectQuerysetMixin, FormView): """ - A view to add a basic food + A view to see a qrcode """ - model = QRCode - extra_context = {"title": _("Add a new meal")} - context_object_name = "qrcode" - slug_field = "qr_code_number" - - def get(self, *args, **kwargs): - qrcode = kwargs["slug"] - if self.model.objects.filter(qr_code_number=qrcode).count() > 0: - return super().get(*args, **kwargs) - else: - return HttpResponseRedirect(reverse("food:qrcode_create", kwargs=kwargs)) - - -class QRCodeCreateView(ProtectQuerysetMixin, LoginRequiredMixin, TemplateView): - """ - A view to add a basic food - """ - template_name = 'food/create_qrcode_form.html' - extra_context = {"title": _("Add a new aliment")} + model = Food + template_name = 'food/add_ingredient_form.html' + extra_context = {"title": _("Add the ingredient")} + form_class = AddIngredientForms def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context["slug"] = kwargs["slug"] + context["pk"] = self.kwargs["pk"] return context + @transaction.atomic + def form_valid(self, form): + form.instance.creater = self.request.user + add_ingredient_form = AddIngredientForms(data=self.request.POST) + if not add_ingredient_form.is_valid(): + return self.form_invalid(form) -class FoodView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): - """ - A view to add a basic food - """ - model = Food - extra_context = {"title": _("Add a new meal")} - context_object_name = "food" + food = Food.objects.get(pk=self.kwargs['pk']) + # Save the aliment and the allergens associed + for transformed_pk in self.request.POST.getlist('ingredient'): + transformed = TransformedFood.objects.get(pk=transformed_pk) + transformed.ingredient.add(food) + transformed._force_save = True + transformed.save() + transformed.refresh_from_db() + + return super().form_valid(form) + + def get_success_url(self, **kwargs): + return reverse('food:food_list') + + def get_sample_object(self): + return TransformedFood( + name="", + creation_date=timezone.now(), + ) -class FoodCreateView(ProtectQuerysetMixin, LoginRequiredMixin, TemplateView): - """ - A view to add a basic food - """ - template_name = 'food/create_food_form.html' - extra_context = {"title": _("Add a new aliment")} - - -class BasicFoodFormView(ProtectQuerysetMixin): - ##################################################################### - # TO DO - # - fix picture save - # - implement solution crop and convert image (reuse or recode ImageForm from members apps) - ##################################################################### +class BasicFoodUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): """ A view to add a basic food """ @@ -98,16 +91,21 @@ class BasicFoodFormView(ProtectQuerysetMixin): return reverse('food:food_view', kwargs={"pk": self.object.pk}) -class BasicFoodUpdateView(BasicFoodFormView, LoginRequiredMixin, UpdateView): - pass +class FoodCreateView(ProtectQuerysetMixin, LoginRequiredMixin, TemplateView): + """ + A view to add a new aliment + """ + template_name = 'food/create_food_form.html' + extra_context = {"title": _("Add a new aliment")} -class BasicFoodCreateView(BasicFoodFormView, ProtectedCreateView): - def get_sample_object(self): - return BasicFood( - name="", - expiry_date=timezone.now(), - ) +class FoodView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): + """ + A view to see a food + """ + model = Food + extra_context = {"title": _("Details")} + context_object_name = "food" class QRCodeBasicFoodCreateView(ProtectQuerysetMixin, ProtectedCreateView): @@ -117,12 +115,12 @@ class QRCodeBasicFoodCreateView(ProtectQuerysetMixin, ProtectedCreateView): # - implement solution crop and convert image (reuse or recode ImageForm from members apps) ##################################################################### """ - A view to add a basic food + A view to add a basic food with a qrcode """ model = BasicFood form_class = BasicFoodForms template_name = 'food/basic_food_form.html' - extra_context = {"title": _("Add a new aliment")} + extra_context = {"title": _("Add a new basic food with QRCode")} @transaction.atomic def form_valid(self, form): @@ -135,6 +133,7 @@ class QRCodeBasicFoodCreateView(ProtectQuerysetMixin, ProtectedCreateView): basic_food = form.save(commit=False) # We assume the date of labeling and the same as the date of arrival basic_food.arrival_date = timezone.now() + basic_food.is_ready = True basic_food._force_save = True basic_food.save() basic_food.refresh_from_db() @@ -148,7 +147,7 @@ class QRCodeBasicFoodCreateView(ProtectQuerysetMixin, ProtectedCreateView): def get_success_url(self, **kwargs): self.object.refresh_from_db() - return reverse('food:food_view', kwargs={"pk": self.object.pk}) + return reverse('food:qrcode_view', kwargs={"slug": self.kwargs['slug']}) def get_sample_object(self): return BasicFood( @@ -157,12 +156,117 @@ class QRCodeBasicFoodCreateView(ProtectQuerysetMixin, ProtectedCreateView): ) +class QRCodeCreateView(ProtectQuerysetMixin, ProtectedCreateView): + """ + A view to add a new qrcode + """ + model = QRCode + template_name = 'food/create_qrcode_form.html' + form_class = QRCodeForms + extra_context = {"title": _("Add a new QRCode")} + + def get(self, *args, **kwargs): + qrcode = kwargs["slug"] + if self.model.objects.filter(qr_code_number=qrcode).count() > 0: + return HttpResponseRedirect(reverse("food:qrcode_view", kwargs=kwargs)) + else: + return super().get(*args, **kwargs) + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["slug"] = self.kwargs["slug"] + return context + + @transaction.atomic + def form_valid(self, form): + form.instance.creater = self.request.user + qrcode_food_form = QRCodeForms(data=self.request.POST) + if not qrcode_food_form.is_valid(): + return self.form_invalid(form) + + # Save the qrcode + qrcode = form.save(commit=False) + qrcode.qr_code_number = self.kwargs["slug"] + qrcode._force_save = True + qrcode.save() + qrcode.refresh_from_db() + + qrcode.food_container.is_ready = True + qrcode.food_container.save() + + return super().form_valid(form) + + def get_success_url(self, **kwargs): + self.object.refresh_from_db() + return reverse('food:qrcode_view', kwargs={"slug": self.kwargs['slug']}) + + def get_sample_object(self): + return QRCode( + qr_code_number=self.kwargs["slug"], + ) + + +class QRCodeTransformedFoodCreateView(ProtectQuerysetMixin, ProtectedCreateView): + """ + A view to add a transformed food with a qrcode + """ + model = TransformedFood + template_name = 'food/transformed_food_form.html' + form_class = TransformedFoodForms + extra_context = {"title": _("Add a new transformed food with QRCode")} + + @transaction.atomic + def form_valid(self, form): + form.instance.creater = self.request.user + transformed_food_form = TransformedFoodForms(data=self.request.POST) + if not transformed_food_form.is_valid(): + return self.form_invalid(form) + + # Save the aliment and allergens associated + transformed_food = form.save(commit=False) + # Without microbiological analyzes, the storage time is 3 days + transformed_food.expiry_date = transformed_food.creation_date + timedelta(days=3) + transformed_food.is_ready = True + transformed_food._force_save = True + transformed_food.save() + transformed_food.refresh_from_db() + + qrcode = QRCode() + qrcode.qr_code_number = self.kwargs['slug'] + qrcode.food_container = transformed_food + qrcode.save() + + return super().form_valid(form) + + def get_success_url(self, **kwargs): + self.object.refresh_from_db() + return reverse('food:qrcode_view', kwargs={"slug": self.kwargs['slug']}) + + def get_sample_object(self): + return TransformedFood( + name="", + creation_date=timezone.now(), + ) + + +class QRCodeView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): + """ + A view to see a qrcode + """ + model = QRCode + extra_context = {"title": _("QRCode")} + context_object_name = "qrcode" + slug_field = "qr_code_number" + + def get(self, *args, **kwargs): + qrcode = kwargs["slug"] + if self.model.objects.filter(qr_code_number=qrcode).count() > 0: + return super().get(*args, **kwargs) + else: + return HttpResponseRedirect(reverse("food:qrcode_create", kwargs=kwargs)) + + class TransformedFoodFormView(ProtectQuerysetMixin): - ##################################################################### - # TO DO - # - fix picture save - # - implement solution crop and convert image (reuse or recode ImageForm from members apps) - ##################################################################### """ A view to add a tranformed food """ @@ -204,48 +308,16 @@ class TransformedFoodCreateView(TransformedFoodFormView, ProtectedCreateView): ) -class QRCodeTransformedFoodCreateView(ProtectQuerysetMixin, ProtectedCreateView): - ##################################################################### - # TO DO - # - fix picture save - # - implement solution crop and convert image (reuse or recode ImageForm from members apps) - ##################################################################### +class TransfomedListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): """ - A view to add a basic food + Displays all Activities, and classify if they are on-going or upcoming ones. """ model = TransformedFood - template_name = 'food/transformed_food_form.html' - form_class = TransformedFoodForms - extra_context = {"title": _("Add a new meal")} + table_class = TransformedFoodTable + ordering = ('-name',) + extra_context = {"title": _("Transformed food")} - @transaction.atomic - def form_valid(self, form): - form.instance.creater = self.request.user - transformed_food_form = TransformedFoodForms(data=self.request.POST) - if not transformed_food_form.is_valid(): - return self.form_invalid(form) - - # Save the aliment and allergens associated - transformed_food = form.save(commit=False) - # Without microbiological analyzes, the storage time is 3 days - transformed_food.expiry_date = transformed_food.creation_date + timedelta(days=3) - transformed_food._force_save = True - transformed_food.save() - transformed_food.refresh_from_db() - - qrcode = QRCode() - qrcode.qr_code_number = self.kwargs['slug'] - qrcode.food_container = transformed_food - qrcode.save() - - return super().form_valid(form) - - def get_success_url(self, **kwargs): - self.object.refresh_from_db() - return reverse('food:food_view', kwargs={"pk": self.object.pk}) - - def get_sample_object(self): - return BasicFood( - name="", - expiry_date=timezone.now(), - ) + def get_queryset(self, **kwargs): + return super().get_queryset(**kwargs)\ + .filter(is_ready=False)\ + .distinct() diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index 93ae0afd..91702559 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -69,6 +69,7 @@ INSTALLED_APPS = [ # Note apps 'api', 'activity', + 'food', 'logs', 'member', 'note', @@ -77,7 +78,6 @@ INSTALLED_APPS = [ 'scripts', 'treasury', 'wei', - 'food', ] MIDDLEWARE = [ diff --git a/note_kfet/templates/base.html b/note_kfet/templates/base.html index 63d0ddfe..6a7721b2 100644 --- a/note_kfet/templates/base.html +++ b/note_kfet/templates/base.html @@ -66,6 +66,10 @@ SPDX-License-Identifier: GPL-3.0-or-later {% trans 'Consumptions' %} {% endif %} + {% if user.is_authenticated and user|is_member:"Kfet" %}