diff --git a/home/admin.py b/home/admin.py index cac27ef..a78a8ef 100644 --- a/home/admin.py +++ b/home/admin.py @@ -1203,6 +1203,7 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin): "start_time", "end_time", "active", + "show_allocated", ) }, ), diff --git a/home/migrations/0003_allocationform_show_allocated.py b/home/migrations/0003_allocationform_show_allocated.py new file mode 100644 index 0000000..1c06dd1 --- /dev/null +++ b/home/migrations/0003_allocationform_show_allocated.py @@ -0,0 +1,17 @@ +# Generated by Django 5.0.3 on 2024-08-24 05:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("home", "0002_remove_allocationautumn22_month_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="allocationform", + name="show_allocated", + field=models.BooleanField(default=False, verbose_name="show_allocated"), + ), + ] diff --git a/home/models/students.py b/home/models/students.py index 5331e1b..67ffaec 100644 --- a/home/models/students.py +++ b/home/models/students.py @@ -272,6 +272,7 @@ class AllocationForm(models.Model): _("Start Time"), default=now, null=True, blank=True ) end_time = models.DateTimeField(_("End Time"), null=True, blank=True) + show_allocated = models.BooleanField(_("show_allocated"), default=False) def __str__(self): return str(self.heading) diff --git a/home/views.py b/home/views.py index b9abdb6..a6f5b03 100644 --- a/home/views.py +++ b/home/views.py @@ -467,19 +467,21 @@ def profile(request): provider="google", user_id=request.user.id ) picture = "not available" - allocation = Allocation.objects.filter(email=student).last() + allocation: Allocation | None = Allocation.objects.filter(email=student).last() + show_allocated_enabled = AllocationForm.objects.filter( + show_allocated=True, period=allocation.period + ).exists() allocation_info = {} # improve this alignment of text to be shown on the profile section - if allocation: + if allocation and show_allocated_enabled: allocation_info = { - "Allocation ID": allocation.student_id, + "start date": allocation.period.start_date, + "end date": allocation.period.end_date, + # "Allocation ID": allocation.student_id, "Caterer": allocation.caterer.name, - "High Tea": "Yes" if allocation.high_tea else "No", + # "High Tea": "Yes" if allocation.high_tea else "No", "Jain": "Yes" if allocation.jain else "No", } - # allocation_info = "Allocation ID: " + allocation.student_id + " Caterer: " + allocation.caterer.name + " High Tea: " + str(allocation.high_tea) + " Jain: " + str(allocation.jain) - # else: - # allocation_info = "Not allocated for this period" try: if socialaccount_obj: picture = socialaccount_obj[0].extra_data["picture"] diff --git a/templates/profile.html b/templates/profile.html index 44da9d4..1b93e59 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -34,7 +34,7 @@
{{ key }}
{% endfor %} {% else %} -
Your view your allocated caterer once the allocation for this period is completed.
+
You will be able to see your allocated caterer after the allocation process is completed
{% endif %}