Skip to content

Commit

Permalink
caterer bills table generation action
Browse files Browse the repository at this point in the history
  • Loading branch information
mittal-ishaan committed Sep 26, 2023
1 parent 53573d2 commit 28f444b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
11 changes: 10 additions & 1 deletion home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ class about_Admin(admin.ModelAdmin):
),
)
# In future can create an admin action to directly generate the table for caterer v=bills for a semester.
actions = ["generate_table"]

@admin.action(description="Generate the table for caterer Bills")
def generate_table(self,request,queryset):
semester = Semester.objects.filter().last()
for caterer in queryset:
caterer_bill,_ = CatererBills.objects.get_or_create(caterer=caterer,semester=semester)
caterer_bill.save()



@admin.register(Form)
class about_Admin(admin.ModelAdmin):
Expand Down Expand Up @@ -1119,7 +1129,6 @@ class about_admin(admin.ModelAdmin):
(None,{"fields": ("name",)},),)



@admin.register(Fee)
class about_Admin(admin.ModelAdmin):
model = Fee
Expand Down
11 changes: 9 additions & 2 deletions home/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def update_bill(sender, instance, created, **kwargs):
start_date= instance.start_date
end_date = instance.end_date
days = count(start_date, end_date)
print("Signal called for Short Rebate")
save_short_bill(email,allocation.period,days,allocation.high_tea, allocation.caterer)
new_rebate = TodayRebate(date=instance.date_applied,Caterer=allocation.caterer.name,allocation_id = allocation,start_date=start_date,end_date=end_date)
new_rebate.save()
Expand Down Expand Up @@ -123,4 +122,12 @@ def create_unregistered(sender, instance,created, **kwargs):
for student in Student.objects.all():
unregistered,_ = UnregisteredStudent.objects.get_or_create(email=str(student.email))
unregistered.period = instance
unregistered.save()
unregistered.save()

@receiver(post_save, sender=Semester)
def create_catererBills(sender, instance, created, **kwargs):
if created:
caterer = instance.name
semester = Semester.objects.filter().last()
caterer_bill,_ = CatererBills.objects.get_or_create(caterer=caterer,semester=semester)
caterer_bill.save()
2 changes: 1 addition & 1 deletion home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def rebate(request):
period = period_obj
)
key = str(allocation_id.student_id)
except:
except Exception as e:
key="You are not allocated for current period, please contact the dining warden to allocate you to a caterer"
except Student.DoesNotExist:
key = "Signed in account does not does not have any allocation ID"
Expand Down

0 comments on commit 28f444b

Please sign in to comment.