From 981fa48309032e0ccfe1a56246a3eb9a552f29a9 Mon Sep 17 00:00:00 2001 From: Ishaan Mittal Date: Sat, 24 Aug 2024 10:08:01 +0530 Subject: [PATCH 1/3] update ssl certs docker ignore --- .gitignore | 1 + nginx/.dockerignore | 1 + 2 files changed, 2 insertions(+) create mode 100644 nginx/.dockerignore diff --git a/.gitignore b/.gitignore index 699b170..92bf975 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ venv .venv media staticfiles +ssl-certs diff --git a/nginx/.dockerignore b/nginx/.dockerignore new file mode 100644 index 0000000..4a966b5 --- /dev/null +++ b/nginx/.dockerignore @@ -0,0 +1 @@ +!ssl-certs/ From 12b41e2b175719bd0d96b89eeb5c762d7f0637b2 Mon Sep 17 00:00:00 2001 From: Ishaan Mittal Date: Sat, 24 Aug 2024 10:43:20 +0530 Subject: [PATCH 2/3] few fixes --- home/admin.py | 4 ++-- home/views.py | 16 +++++++--------- templates/profile.html | 11 ++++++++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/home/admin.py b/home/admin.py index 3e79b7d..cac27ef 100644 --- a/home/admin.py +++ b/home/admin.py @@ -982,11 +982,11 @@ def get_queryset(self, request): @admin.display(description="email") def email(self, obj): - return obj.email.email + return obj.email.email if obj.email else "" @admin.display(description="name") def name(self, obj): - return obj.email.name + return obj.email.name if obj.email else "" actions = ["export_as_csv", "correct_bills", "fix_issue"] diff --git a/home/views.py b/home/views.py index 625e9d6..b9abdb6 100644 --- a/home/views.py +++ b/home/views.py @@ -363,6 +363,8 @@ def allocationForm(request): alloc_form = AllocationForm.objects.filter(active=True).last() try: student = Student.objects.filter(email__iexact=str(request.user.email)).last() + if not student: + raise Exception("Student not found") text = "" message = "" if (alloc_form.start_time and alloc_form.start_time > now()) or ( @@ -372,13 +374,7 @@ def allocationForm(request): elif Allocation.objects.filter( email=student, period=alloc_form.period ).exists(): - allocation_id = Allocation.objects.filter( - email=student, period=alloc_form.period - ).last() - message = ( - "You have already filled the form for this period. with first preference:" - + allocation_id.first_pref - ) + message = "You have filled the form for this period. Please visit the profile page after the allocation process is completed to check your allocated caterer" elif request.method == "POST" and request.user.is_authenticated: try: period_obj = alloc_form.period @@ -444,8 +440,8 @@ def allocationForm(request): if text != "": del request.session["text"] except Exception as e: - print(e) - message = "Signed in account can not fill the allocation form" + logger.error(e) + message = "Signed in account can not fill the allocation form. Please inform the dining Office to add your email ID to the database" text = "" context = { "text": text, @@ -524,6 +520,8 @@ def rebate_data(request): semester = request.GET.get("semester") semester_obj = Semester.objects.get(name=semester) rebate = StudentBills.objects.filter(email=student, semester=semester_obj).last() + if not rebate: + return JsonResponse({"semester": semester, "period": sno, "data": []}) rebate_bills = get_rebate_bills(rebate, sno) rebate_data = {"semester": semester, "period": sno, "data": rebate_bills} return JsonResponse(rebate_data) diff --git a/templates/profile.html b/templates/profile.html index e749d90..44da9d4 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -34,7 +34,7 @@
{{ key }}
{% endfor %} {% else %} -
You have not been allotted a caterer for this period yet.
+
Your view your allocated caterer once the allocation for this period is completed.
{% endif %}
@@ -123,7 +123,6 @@
Rebate Bills
return; } var semester = $('#semester-select').val(); - console.log(period); $.ajax({ url: "{% url 'rebate_data' %}", type: "GET", @@ -132,8 +131,14 @@
Rebate Bills
'period': period }, success: function(response) { - console.log(response); var data = response.data; + if(data.length == 0) { + $('#short').html(''); + $('#long').html(''); + $('#high_tea').html(''); + $('#bills').html(''); + return; + } var short = document.getElementById('short'); var long = document.getElementById('long'); var high_tea = document.getElementById('high_tea'); From bd34fc9f274dd5af13a7217632aeb3e11b40a220 Mon Sep 17 00:00:00 2001 From: Ishaan Mittal Date: Sat, 24 Aug 2024 11:51:10 +0530 Subject: [PATCH 3/3] quick fix --- home/admin.py | 1 + .../0003_allocationform_show_allocated.py | 17 +++++++++++++++++ home/models/students.py | 1 + home/views.py | 16 +++++++++------- templates/profile.html | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 home/migrations/0003_allocationform_show_allocated.py 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 %}