From 58fe132902162de5ce17d15f5aa3f14f32536ce0 Mon Sep 17 00:00:00 2001 From: Prince Kumar Date: Sun, 3 Nov 2024 19:41:49 +0530 Subject: [PATCH] Qr code dev (#91) * handle mess time feedbackk * update mess-card * handling errors * update --- api/views.py | 5 ++- .../migrations/0005_alter_messcard_student.py | 20 ++++++++++ qrscan/templates/mess_card.html | 2 +- qrscan/views.py | 9 +++-- static/css/mess-card.css | 38 ++++++++++++------- 5 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 qrscan/migrations/0005_alter_messcard_student.py diff --git a/api/views.py b/api/views.py index 5944a67..d7abe84 100644 --- a/api/views.py +++ b/api/views.py @@ -109,7 +109,7 @@ def _get_meal_type(self, time): if meal_timing.start_time <= time <= meal_timing.end_time: return meal_type except MessTiming.DoesNotExist: - raise ValueError(f"{meal_type.capitalize()} timings not found.") + return None return None def _filter_valid_cards(self, cards, meal_type): @@ -187,6 +187,9 @@ def post(self, request): meal_type = self._get_meal_type(time) + if(meal_type == None): + return Response({"success": False, "detail": "Meal time over.", "mess_card": card_return_data}, status=status.HTTP_403_FORBIDDEN) + if getattr(meal, meal_type): return Response({"success": False, "detail": "Meal Already Recorded", "mess_card": card_return_data}, status=status.HTTP_409_CONFLICT) diff --git a/qrscan/migrations/0005_alter_messcard_student.py b/qrscan/migrations/0005_alter_messcard_student.py new file mode 100644 index 0000000..efa0a5a --- /dev/null +++ b/qrscan/migrations/0005_alter_messcard_student.py @@ -0,0 +1,20 @@ +# Generated by Django 5.0.8 on 2024-10-22 13:30 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0001_initial'), + ('qrscan', '0004_messtiming_delete_messtimings'), + ] + + operations = [ + migrations.AlterField( + model_name='messcard', + name='student', + field=models.ForeignKey(help_text='This contains the student details', on_delete=django.db.models.deletion.CASCADE, to='home.student'), + ), + ] diff --git a/qrscan/templates/mess_card.html b/qrscan/templates/mess_card.html index 09d24c9..b8e2f7f 100644 --- a/qrscan/templates/mess_card.html +++ b/qrscan/templates/mess_card.html @@ -11,7 +11,7 @@
-
+