diff --git a/.gitignore b/.gitignore index 7f86a49..699b170 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ db.sqlite3 db1.sqlite3 __pycache__ -migrations venv .venv media diff --git a/home/admin.py b/home/admin.py index 0205e17..27143b8 100644 --- a/home/admin.py +++ b/home/admin.py @@ -36,9 +36,9 @@ Update, ) -from .resources import ( # AllocationResource,; CatererBillsResource, - AllocationNewResource, - CatererBillsNewResource, +from .resources import ( + AllocationResource, + CatererBillsResource, LongRebateResource, RebateBillsResource, RebateResource, @@ -924,7 +924,7 @@ def export_as_csv(self, request, queryset): @admin.register(Allocation) class about_Admin(ImportExportModelAdmin, admin.ModelAdmin): list_per_page = 500 - resource_class = AllocationNewResource + resource_class = AllocationResource model = Allocation search_fields = ( "email__name", @@ -994,7 +994,7 @@ def export_as_csv(self, request, queryset): """ Export action available in the admin page """ - resource = AllocationNewResource() + resource = AllocationResource() dataset = resource.export(queryset) response = HttpResponse(dataset.csv, content_type="text/csv") response["Content-Disposition"] = 'attachment; filename="allocation.csv"' @@ -1049,31 +1049,9 @@ class about_Admin(admin.ModelAdmin): } -# @admin.register(CatererBillsSpring23) -# class about_Admin(ImportExportModelAdmin, admin.ModelAdmin): -# resource_class = CatererBillsResource -# model = CatererBillsSpring23 -# fieldsets = ((None,caterer_bill_fields,),) -# list_display = ("__str__", "period1_bills", "period2_bills", "period3_bills", "period4_bills", "period5_bills", "period6_bills",) -# search_fields = ("caterer__name",) -# actions = ["export_as_csv"] - -# def export_as_csv(self, request, queryset): -# """ -# Export action available in the admin page -# """ -# resource = CatererBillsResource() -# dataset = resource.export(queryset) -# response = HttpResponse(dataset.csv, content_type="text/csv") -# response["Content-Disposition"] = 'attachment; filename="caterer_bills.csv"' -# return response - -# export_as_csv.short_description = "Export Caterer Bills details to CSV" - - @admin.register(CatererBills) class about_Admin(ImportExportModelAdmin, admin.ModelAdmin): - resource_class = CatererBillsNewResource + resource_class = CatererBillsResource model = CatererBills fieldsets = ( ( @@ -1110,7 +1088,7 @@ def export_as_csv(self, request, queryset): """ Export action available in the admin page """ - resource = CatererBillsNewResource() + resource = CatererBillsResource() dataset = resource.export(queryset) response = HttpResponse(dataset.csv, content_type="text/csv") response["Content-Disposition"] = 'attachment; filename="caterer_bills.csv"' diff --git a/home/forms.py b/home/forms.py index 979ae24..5adb568 100644 --- a/home/forms.py +++ b/home/forms.py @@ -12,9 +12,3 @@ def signup(self, request, user): user.last_name = self.cleaned_data["last_name"] user.save() return user - - -# class CustomSocialSignupForm(SocialSignupForm): -# def __init__(self, *args, **kwargs): -# super().__init__(*args, **kwargs) -# self.prevent_enumeration = False diff --git a/home/migrations/0002_remove_allocationautumn22_month_and_more.py b/home/migrations/0002_remove_allocationautumn22_month_and_more.py new file mode 100644 index 0000000..93423d9 --- /dev/null +++ b/home/migrations/0002_remove_allocationautumn22_month_and_more.py @@ -0,0 +1,125 @@ +# Generated by Django 5.0.3 on 2024-08-17 14:53 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("home", "0001_initial"), + ] + + operations = [ + migrations.RemoveField( + model_name="allocationautumn22", + name="month", + ), + migrations.RemoveField( + model_name="allocationautumn22", + name="roll_no", + ), + migrations.RemoveField( + model_name="allocationautumn23", + name="month", + ), + migrations.RemoveField( + model_name="allocationautumn23", + name="roll_no", + ), + migrations.RemoveField( + model_name="allocationspring23", + name="month", + ), + migrations.RemoveField( + model_name="allocationspring23", + name="roll_no", + ), + migrations.AlterField( + model_name="scan", + name="student_id", + field=models.ForeignKey( + default=0, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="home.student", + ), + ), + migrations.RemoveField( + model_name="catererbillsautumn22", + name="caterer", + ), + migrations.RemoveField( + model_name="catererbillsautumn23", + name="caterer", + ), + migrations.RemoveField( + model_name="catererbillsspring23", + name="caterer", + ), + migrations.RemoveField( + model_name="rebateautumn23", + name="email", + ), + migrations.AddField( + model_name="longrebate", + name="reason", + field=models.TextField( + blank=True, + choices=[ + ("", "Choose the reason"), + ( + "Incomplete form. Please submit a new rebate application", + "Incomplete form", + ), + ( + "Signature of approving authority missing. Please submit a new rebate application", + "Signature missing", + ), + ( + "Attached file is not the rebate form. Please submit a new rebate application with correct attachment", + "Wrong attached document", + ), + ( + "There is a date mismatch between the one written in the form and the one in the attached form. Please submit a new rebate application", + "There is a date mismatch between the one written in the form and the one in the attached form", + ), + ], + default="", + ), + ), + migrations.AlterField( + model_name="rule", + name="sno", + field=models.AutoField(primary_key=True, serialize=False), + ), + migrations.DeleteModel( + name="PeriodAutumn22", + ), + migrations.DeleteModel( + name="AllocationAutumn22", + ), + migrations.DeleteModel( + name="PeriodAutumn23", + ), + migrations.DeleteModel( + name="AllocationAutumn23", + ), + migrations.DeleteModel( + name="PeriodSpring23", + ), + migrations.DeleteModel( + name="AllocationSpring23", + ), + migrations.DeleteModel( + name="CatererBillsAutumn22", + ), + migrations.DeleteModel( + name="CatererBillsAutumn23", + ), + migrations.DeleteModel( + name="CatererBillsSpring23", + ), + migrations.DeleteModel( + name="RebateAutumn23", + ), + ] diff --git a/home/models/Semesters/autumn22.py b/home/models/Semesters/autumn22.py index 1ac6fad..44d8fb5 100644 --- a/home/models/Semesters/autumn22.py +++ b/home/models/Semesters/autumn22.py @@ -1,100 +1,9 @@ from django.db import models from django.utils.translation import gettext as _ -from ..caterer import Caterer from ..students import Student -class PeriodAutumn22(models.Model): - Sno = models.IntegerField( - _("Sno"), default=0, help_text="This contains the serial number of the Period" - ) - start_date = models.DateField( - help_text="This contains the start date of this Period for this semester", - null=True, - blank=True, - ) - end_date = models.DateField( - help_text="This contains the end date of this Period of this semester", - null=True, - blank=True, - ) - - def __str__(self): - return str(self.Sno) - - class Meta: - verbose_name = "Period Details for Autumn 2022" - verbose_name_plural = "Period Details for Autumn 2022" - - -class AllocationAutumn22(models.Model): - """ - Stores the Allocation details - """ - - roll_no = models.ForeignKey( - Student, default=0, on_delete=models.SET_NULL, null=True - ) - student_id = models.CharField( - _("Allocation Id"), - default=None, - max_length=30, - help_text="This contains the Allocation Id", - null=True, - blank=True, - ) - month = models.ForeignKey( - PeriodAutumn22, default=0, on_delete=models.SET_NULL, null=True - ) - caterer_name = models.CharField( - _("Caterer Name"), - max_length=50, - help_text="The text in this text field contains the caterer name.", - default="", - null=True, - blank=True, - ) - high_tea = models.BooleanField( - _("High Tea"), - help_text="This contains the info if high tea is taken or not", - default=False, - null=True, - blank=True, - ) - first_pref = models.CharField( - _("First Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - second_pref = models.CharField( - _("Second Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - third_pref = models.CharField( - _("Third Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - - def __str__(self): - return self.student_id - - class Meta: - verbose_name = "Allocation Details for Autumn 2022" - verbose_name_plural = "Allocation Details for Autumn 2022" - - class RebateAutumn22(models.Model): """ Storing the Rebate Bills of the Students for the Autumn Semester @@ -162,25 +71,3 @@ def __str__(self): class Meta: verbose_name = "Rebate Bill Autumn 2022" verbose_name_plural = "Rebate Bills Autumn 2022" - - -class CatererBillsAutumn22(models.Model): - """ - Storing the Bills of the Caterers for the Autumn Semester - """ - - caterer = models.ForeignKey(Caterer, on_delete=models.SET_NULL, null=True) - - period1_bills = models.IntegerField(_("Period 1 Bill"), default=0, null=True) - period2_bills = models.IntegerField(_("Period 2 Bill"), default=0, null=True) - period3_bills = models.IntegerField(_("Period 3 Bill"), default=0, null=True) - period4_bills = models.IntegerField(_("Period 4 Bill"), default=0, null=True) - period5_bills = models.IntegerField(_("Period 5 Bill"), default=0, null=True) - period6_bills = models.IntegerField(_("Period 6 Bill"), default=0, null=True) - - def __str__(self): - return str(self.caterer.pk) - - class Meta: - verbose_name = "Caterer Bill Autumn 2022" - verbose_name_plural = "Caterer Bills Autumn 2022" diff --git a/home/models/Semesters/autumn23.py b/home/models/Semesters/autumn23.py deleted file mode 100644 index 15a7cf8..0000000 --- a/home/models/Semesters/autumn23.py +++ /dev/null @@ -1,174 +0,0 @@ -from django.db import models -from django.utils.translation import gettext as _ - -from ..caterer import Caterer -from ..students import Student - - -class PeriodAutumn23(models.Model): - Sno = models.IntegerField( - _("Sno"), default=0, help_text="This contains the serial number of the Period" - ) - start_date = models.DateField( - help_text="This contains the start date of this Period for this semester", - null=True, - blank=True, - ) - end_date = models.DateField( - help_text="This contains the end date of this Period of this semester", - null=True, - blank=True, - ) - - def __str__(self): - return str(self.Sno) - - class Meta: - verbose_name = "Period Details for Autumn 2023" - verbose_name_plural = "Period Details for Autumn 2023" - - -class AllocationAutumn23(models.Model): - """ - Stores the Allocation details - """ - - roll_no = models.ForeignKey( - Student, default=0, on_delete=models.SET_NULL, null=True - ) - student_id = models.CharField( - _("Allocation Id"), - default=None, - max_length=30, - help_text="This contains the Allocation Id", - null=True, - blank=True, - ) - month = models.ForeignKey( - PeriodAutumn23, default=0, on_delete=models.SET_NULL, null=True - ) - caterer_name = models.CharField( - _("Caterer Name"), - max_length=50, - help_text="The text in this text field contains the caterer name.", - default="", - null=True, - blank=True, - ) - high_tea = models.BooleanField( - _("High Tea"), - help_text="This contains the info if high tea is taken or not", - default=False, - null=True, - blank=True, - ) - first_pref = models.CharField( - _("First Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - second_pref = models.CharField( - _("Second Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - third_pref = models.CharField( - _("Third Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - - def __str__(self): - return self.student_id - - class Meta: - verbose_name = "Allocation Details for Autumn 2023" - verbose_name_plural = "Allocation Details for Autumn 2023" - - -class RebateAutumn23(models.Model): - """ - Storing the Rebate Bills of the Students for the Autumn Semester - """ - - email = models.ForeignKey(Student, on_delete=models.SET_NULL, default="", null=True) - - period1_short = models.IntegerField(_("Period 1 Short"), default=0, null=True) - period1_long = models.IntegerField(_("Period 1 Long"), default=0, null=True) - period1_high_tea = models.BooleanField(_("Period 1 High Tea"), default=True) - period1_bill = models.IntegerField( - _("Period 1 Rebate Amount"), default=0, null=True - ) - - period2_short = models.IntegerField(_("Period 2 Short"), default=0, null=True) - period2_long = models.IntegerField(_("Period 2 Long"), default=0, null=True) - period2_high_tea = models.BooleanField(_("Period 2 High Tea"), default=True) - period2_bill = models.IntegerField( - _("Period 2 Rebate Amount"), default=0, null=True - ) - - period3_short = models.IntegerField(_("Period 3 Short"), default=0, null=True) - period3_long = models.IntegerField(_("Period 3 Long"), default=0, null=True) - period3_high_tea = models.BooleanField(_("Period 3 High Tea"), default=True) - period3_bill = models.IntegerField( - _("Period 3 Rebate Amount"), default=0, null=True - ) - - period4_short = models.IntegerField(_("Period 4 Short"), default=0, null=True) - period4_long = models.IntegerField(_("Period 4 Long"), default=0, null=True) - period4_high_tea = models.BooleanField(_("Period 4 High Tea"), default=True) - period4_bill = models.IntegerField( - _("Period 4 Rebate Amount"), default=0, null=True - ) - - period5_short = models.IntegerField(_("Period 5 Short"), default=0, null=True) - period5_long = models.IntegerField(_("Period 5 Long"), default=0, null=True) - period5_high_tea = models.BooleanField(_("Period 5 High Tea"), default=True) - period5_bill = models.IntegerField( - _("Period 5 Rebate Amount"), default=0, null=True - ) - - period6_short = models.IntegerField(_("Period 6 Short"), default=0, null=True) - period6_long = models.IntegerField(_("Period 6 Long"), default=0, null=True) - period6_high_tea = models.BooleanField(_("Period 6 High Tea"), default=True) - period6_bill = models.IntegerField( - _("Period 6 Rebate Amount"), default=0, null=True - ) - - def __str__(self): - return str(self.email.email) - - class Meta: - verbose_name = "Rebate Bill Autumn 2023" - verbose_name_plural = "Rebate Bills Autumn 2023" - - -class CatererBillsAutumn23(models.Model): - """ - Storing the Bills of the Caterers for the Autumn Semester - """ - - caterer = models.ForeignKey(Caterer, on_delete=models.SET_NULL, null=True) - - period1_bills = models.IntegerField(_("Period 1 Bill"), default=0, null=True) - period2_bills = models.IntegerField(_("Period 2 Bill"), default=0, null=True) - period3_bills = models.IntegerField(_("Period 3 Bill"), default=0, null=True) - period4_bills = models.IntegerField(_("Period 4 Bill"), default=0, null=True) - period5_bills = models.IntegerField(_("Period 5 Bill"), default=0, null=True) - period6_bills = models.IntegerField(_("Period 6 Bill"), default=0, null=True) - - def __str__(self): - return str(self.caterer.name) - - class Meta: - verbose_name = "Caterer Bill Autumn 2023" - verbose_name_plural = "Caterer Bills Autumn 2023" diff --git a/home/models/Semesters/spring23.py b/home/models/Semesters/spring23.py index 51c0006..c56e5c6 100644 --- a/home/models/Semesters/spring23.py +++ b/home/models/Semesters/spring23.py @@ -1,100 +1,9 @@ from django.db import models from django.utils.translation import gettext as _ -from ..caterer import Caterer from ..students import Student -class PeriodSpring23(models.Model): - Sno = models.IntegerField( - _("Sno"), default=0, help_text="This contains the serial number of the Period" - ) - start_date = models.DateField( - help_text="This contains the start date of this Period for this semester", - null=True, - blank=True, - ) - end_date = models.DateField( - help_text="This contains the end date of this Period of this semester", - null=True, - blank=True, - ) - - def __str__(self): - return str(self.Sno) - - class Meta: - verbose_name = "Period Details for Spring 2023" - verbose_name_plural = "Period Details for Spring 2023" - - -class AllocationSpring23(models.Model): - """ - Stores the Allocation details - """ - - roll_no = models.ForeignKey( - Student, default=0, on_delete=models.SET_NULL, null=True - ) - student_id = models.CharField( - _("Allocation Id"), - default=None, - max_length=30, - help_text="This contains the Allocation Id", - null=True, - blank=True, - ) - month = models.ForeignKey( - PeriodSpring23, default=0, on_delete=models.SET_NULL, null=True - ) - caterer_name = models.CharField( - _("Caterer Name"), - max_length=50, - help_text="The text in this text field contains the caterer name.", - default="", - null=True, - blank=True, - ) - high_tea = models.BooleanField( - _("High Tea"), - help_text="This contains the info if high tea is taken or not", - default=False, - null=True, - blank=True, - ) - first_pref = models.CharField( - _("First Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - second_pref = models.CharField( - _("Second Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - third_pref = models.CharField( - _("Third Preference"), - default=None, - max_length=10, - help_text="This contians the first preference caterer of the student", - null=True, - blank=True, - ) - - def __str__(self): - return self.student_id - - class Meta: - verbose_name = "Allocation Details for Spring 2023" - verbose_name_plural = "Allocation Details for Spring 2023" - - class RebateSpring23(models.Model): """ Storing the Rebate Bills of the Students for the Spring Semester @@ -150,25 +59,3 @@ def __str__(self): class Meta: verbose_name = "Rebate Bill Spring 2023" verbose_name_plural = "Rebate Bills Spring 2023" - - -class CatererBillsSpring23(models.Model): - """ - Storing the Bills of the Caterers for the Spring Semester - """ - - caterer = models.ForeignKey(Caterer, on_delete=models.SET_NULL, null=True) - - period1_bills = models.IntegerField(_("Period 1 Bill"), default=0, null=True) - period2_bills = models.IntegerField(_("Period 2 Bill"), default=0, null=True) - period3_bills = models.IntegerField(_("Period 3 Bill"), default=0, null=True) - period4_bills = models.IntegerField(_("Period 4 Bill"), default=0, null=True) - period5_bills = models.IntegerField(_("Period 5 Bill"), default=0, null=True) - period6_bills = models.IntegerField(_("Period 6 Bill"), default=0, null=True) - - def __str__(self): - return str(self.caterer.pk) - - class Meta: - verbose_name = "Caterer Bill Spring 2023" - verbose_name_plural = "Caterer Bills Spring 2023" diff --git a/home/models/__init__.py b/home/models/__init__.py index 76942a0..1ac6463 100644 --- a/home/models/__init__.py +++ b/home/models/__init__.py @@ -10,21 +10,9 @@ from .links import Form from .rules import Rule, ShortRebate from .Semesters.autumn22 import ( - AllocationAutumn22, - CatererBillsAutumn22, - PeriodAutumn22, RebateAutumn22, ) -from .Semesters.autumn23 import ( - AllocationAutumn23, - CatererBillsAutumn23, - PeriodAutumn23, - RebateAutumn23, -) from .Semesters.spring23 import ( - AllocationSpring23, - CatererBillsSpring23, - PeriodSpring23, RebateSpring23, ) from .students import ( diff --git a/home/models/students.py b/home/models/students.py index 079308e..72faa51 100644 --- a/home/models/students.py +++ b/home/models/students.py @@ -72,10 +72,8 @@ class Scan(models.Model): Note: this is not implemented yet """ - from .Semesters.spring23 import AllocationSpring23 - student_id = models.ForeignKey( - AllocationSpring23, default=0, on_delete=models.SET_NULL, null=True + Student, default=0, on_delete=models.SET_NULL, null=True ) date = models.DateField(help_text="Date of the scan details") breakfast = models.BooleanField( diff --git a/home/resources.py b/home/resources.py index 47a41ac..eee6281 100644 --- a/home/resources.py +++ b/home/resources.py @@ -4,12 +4,10 @@ from .models import ( Allocation, - AllocationSpring23, CatererBills, Fee, LongRebate, Period, - PeriodSpring23, Rebate, RebateAutumn22, RebateSpring23, @@ -21,7 +19,6 @@ """ File-name: resources.py Functions: StudentResource - AllocationResource RebateResource RebateSpringResource RebateAutumnResource @@ -57,7 +54,7 @@ class Meta: ) -class AllocationNewResource(resources.ModelResource): +class AllocationResource(resources.ModelResource): email__roll_no = fields.Field(attribute="email__roll_no", column_name="Roll No.") email__email = fields.Field(attribute="email__email", column_name="Email") email__name = fields.Field(attribute="email__name", column_name="Name") @@ -255,9 +252,6 @@ class RebateBillsResource(resources.ModelResource): ) email__hostel = fields.Field(attribute="email__hostel", column_name="Hostel") email__room_no = fields.Field(attribute="email__room_no", column_name="Room No.") - allocation1 = fields.Field( - attribute="allocation1", column_name="Allocation for period 1" - ) period1_short = fields.Field( attribute="period1_short", column_name="Short Rebate 1" ) @@ -266,9 +260,6 @@ class RebateBillsResource(resources.ModelResource): attribute="period1_high_tea", column_name="High Tea 1" ) period1_bill = fields.Field(attribute="period1_bill", column_name="Bill 1") - allocation2 = fields.Field( - attribute="allocation2", column_name="Allocation for period 2" - ) period2_short = fields.Field( attribute="period2_short", column_name="Short Rebate 2" ) @@ -277,9 +268,6 @@ class RebateBillsResource(resources.ModelResource): attribute="period2_high_tea", column_name="High Tea 2" ) period2_bill = fields.Field(attribute="period2_bill", column_name="Bill 2") - allocation3 = fields.Field( - attribute="allocation3", column_name="Allocation for period 3" - ) period3_short = fields.Field( attribute="period3_short", column_name="Short Rebate 3" ) @@ -288,9 +276,6 @@ class RebateBillsResource(resources.ModelResource): attribute="period3_high_tea", column_name="High Tea 3" ) period3_bill = fields.Field(attribute="period3_bill", column_name="Bill 3") - allocation4 = fields.Field( - attribute="allocation4", column_name="Allocation for period 4" - ) period4_short = fields.Field( attribute="period4_short", column_name="Short Rebate 4" ) @@ -310,9 +295,6 @@ class RebateBillsResource(resources.ModelResource): attribute="period5_high_tea", column_name="High Tea 5" ) period5_bill = fields.Field(attribute="period5_bill", column_name="Bill 5") - allocation6 = fields.Field( - attribute="allocation6", column_name="Allocation for period 6" - ) period6_short = fields.Field( attribute="period6_short", column_name="Short Rebate 6" ) @@ -387,12 +369,6 @@ class Meta: "period6_high_tea", "period6_bill", "empty", - "allocation1", - "allocation2", - "allocation3", - "allocation4", - "allocation5", - "allocation6", "last_sem_fee", "total", "upcoming_sem_fee", @@ -407,37 +383,31 @@ class Meta: "email__hostel", "email__room_no", "empty", - "allocation1", "period1_short", "period1_long", "period1_high_tea", "period1_bill", "empty", - "allocation2", "period2_short", "period2_long", "period2_high_tea", "period2_bill", "empty", - "allocation3", "period3_short", "period3_long", "period3_high_tea", "period3_bill", "empty", - "allocation4", "period4_short", "period4_long", "period4_high_tea", "period4_bill", "empty", - "allocation5", "period5_short", "period5_long", "period5_high_tea", "period5_bill", "empty", - "allocation6", "period6_short", "period6_long", "period6_high_tea", @@ -495,79 +465,6 @@ def dehydrate_upcoming_sem_due(self, obj): print(e) return 0 - def dehydrate_allocation1(self, obj): - try: - period = PeriodSpring23.objects.get(Sno=1) - allocation = AllocationSpring23.objects.get(roll_no=obj.email, month=period) - if allocation.high_tea: - high_tea = "High Tea" - else: - high_tea = "No High Tea" - return str(allocation.caterer_name) + " " + high_tea - except Exception as e: - logger.error(e) - return "Not yet allocated" - - def dehydrate_allocation2(self, obj): - try: - period = PeriodSpring23.objects.get(Sno=2) - allocation = AllocationSpring23.objects.get(roll_no=obj.email, month=period) - if allocation.high_tea: - high_tea = "High Tea" - else: - high_tea = "No High Tea" - return str(allocation.caterer_name) + " " + high_tea - except: - return "Not yet allocated" - - def dehydrate_allocation3(self, obj): - try: - period = PeriodSpring23.objects.get(Sno=3) - allocation = AllocationSpring23.objects.get(roll_no=obj.email, month=period) - if allocation.high_tea: - high_tea = "High Tea" - else: - high_tea = "No High Tea" - return str(allocation.caterer_name) + " " + high_tea - except: - return "Not yet allocated" - - def dehydrate_allocation4(self, obj): - try: - period = PeriodSpring23.objects.get(Sno=4) - allocation = AllocationSpring23.objects.get(roll_no=obj.email, month=period) - if allocation.high_tea: - high_tea = "High Tea" - else: - high_tea = "No High Tea" - return str(allocation.caterer_name) + " " + high_tea - except: - return "Not yet allocated" - - def dehydrate_allocation5(self, obj): - try: - period = PeriodSpring23.objects.get(Sno=5) - allocation = AllocationSpring23.objects.get(roll_no=obj.email, month=period) - if allocation.high_tea: - high_tea = "High Tea" - else: - high_tea = "No High Tea" - return str(allocation.caterer_name) + " " + high_tea - except: - return "Not yet allocated" - - def dehydrate_allocation6(self, obj): - try: - period = PeriodSpring23.objects.get(Sno=6) - allocation = AllocationSpring23.objects.get(roll_no=obj.email, month=period) - if allocation.high_tea: - high_tea = "High Tea" - else: - high_tea = "No High Tea" - return str(allocation.caterer_name) + " " + high_tea - except: - return "Not yet allocated" - class StudentBillsResource(resources.ModelResource): email__email = fields.Field( @@ -851,7 +748,7 @@ class Meta: fields = ("email",) -class CatererBillsNewResource(resources.ModelResource): +class CatererBillsResource(resources.ModelResource): caterer__name = fields.Field(attribute="caterer__name", column_name="Caterer") semester__name = fields.Field(attribute="semester__name", column_name="Semester") period1_bills = fields.Field( diff --git a/home/views.py b/home/views.py index d700c3b..7aae9c3 100644 --- a/home/views.py +++ b/home/views.py @@ -21,11 +21,7 @@ LeftShortRebate, LongRebate, Period, - PeriodAutumn22, - PeriodSpring23, Rebate, - RebateAutumn22, - RebateSpring23, Rule, Semester, ShortRebate, @@ -508,19 +504,12 @@ def profile(request): def period_data(request): print("period_data") name = request.GET.get("semester") - if name == "autumn22": - period = PeriodAutumn22.objects.all() - elif name == "spring23": - period = PeriodSpring23.objects.all() - else: - semester = Semester.objects.get(name=name) - period = Period.objects.filter(semester=semester) + semester = Semester.objects.get(name=name) + period = Period.objects.filter(semester=semester) period_data = { "semester": name, "data": list(period.values("Sno", "start_date", "end_date")), } - # print(period_data['semester']) - # print(period_data['data']) return JsonResponse(period_data) @@ -531,17 +520,8 @@ def rebate_data(request): student = Student.objects.get(email__iexact=user.email) sno = request.GET.get("period") semester = request.GET.get("semester") - if semester == "autumn22": - rebate = RebateAutumn22.objects.filter(email=student).last() - rebate_bills = get_rebate_bills(rebate, sno) - elif semester == "spring23": - rebate = RebateSpring23.objects.filter(email=student).last() - rebate_bills = get_rebate_bills(rebate, sno) - else: - semester_obj = Semester.objects.get(name=semester) - rebate = StudentBills.objects.filter( - email=student, semester=semester_obj - ).last() - rebate_bills = get_rebate_bills(rebate, sno) + semester_obj = Semester.objects.get(name=semester) + rebate = StudentBills.objects.filter(email=student, semester=semester_obj).last() + rebate_bills = get_rebate_bills(rebate, sno) rebate_data = {"semester": semester, "period": sno, "data": rebate_bills} return JsonResponse(rebate_data)