From 2ffcd27fb46a325b95bfc7dda3bc05302b87222e Mon Sep 17 00:00:00 2001 From: Ishaan Mittal Date: Thu, 4 Jan 2024 12:42:18 +0530 Subject: [PATCH] rebate resources corrected --- home/admin.py | 11 +--------- home/resources.py | 54 +++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/home/admin.py b/home/admin.py index bac0832..1358e44 100644 --- a/home/admin.py +++ b/home/admin.py @@ -474,16 +474,7 @@ def export_as_csv(self, request, queryset): export_as_csv.short_description = "Export Rebate details to CSV" - # def save_model(self, request, obj, form, change): - # super().save_model(request, obj, form, change) - # update_bill(instance=obj, sender=obj.__class__, created=change) - - # def save_related(self, request, form, formsets, change): - # super().save_related(request, form, formsets, change) - # print("save related") - # update_bill( - # sender=form.instance.__class__, instance=form.instance, created=change - # ) + def unregister_student(obj): for caterer in Caterer.objects.all(): diff --git a/home/resources.py b/home/resources.py index 8cd46cd..0b5b670 100644 --- a/home/resources.py +++ b/home/resources.py @@ -129,31 +129,31 @@ class RebateResource(resources.ModelResource): ) # def get_approved_value(self, obj): email = fields.Field(attribute="email", column_name="Email") - allocation_id__roll_no__name = fields.Field( - attribute="allocation_id__roll_no__name", column_name="Name" + name = fields.Field( + attribute="email__name", column_name="Name" ) - allocation_id__roll_no__roll_no = fields.Field( - attribute="allocation_id__roll_no__roll_no", column_name="Roll No." + roll_no = fields.Field( + attribute="email__roll_no", column_name="Roll No." ) - allocation_id__roll_no__department = fields.Field( - attribute="allocation_id__roll_no__department", column_name="Department" + department = fields.Field( + attribute="email__department", column_name="Department" ) - allocation_id__roll_no__degree = fields.Field( - attribute="allocation_id__roll_no__degree", column_name="Degree" + degree = fields.Field( + attribute="email__degree", column_name="Degree" ) - allocation_id__roll_no__hostel = fields.Field( - attribute="allocation_id__roll_no__hostel", column_name="Hostel" + hostel = fields.Field( + attribute="email__hostel", column_name="Hostel" ) - allocation_id__roll_no__room_no = fields.Field( - attribute="allocation_id__roll_no__room_no", column_name="Room No." + room_no = fields.Field( + attribute="email__room_no", column_name="Room No." ) allocation_id__caterer_name = fields.Field( - attribute="allocation_id__caterer_name", column_name="Caterer Alloted" + attribute="allocation_id__caterer__name", column_name="Caterer Alloted" ) allocation_id__high_tea = fields.Field( attribute="allocation_id__high_tea", column_name="High Tea" ) - date_applied = fields.Field(attribute="date_applied", column_name="date_applied") + date_applied = fields.Field(attribute="date_applied", column_name="Date Applied") start_date = fields.Field(attribute="start_date", column_name="Start Date") end_date = fields.Field(attribute="end_date", column_name="End Date") approved = fields.Field(attribute="approved", column_name="Approved") @@ -162,12 +162,12 @@ class Meta: model = Rebate fields = ( "email", - "allocation_id__roll_no__name", - "allocation_id__roll_no__roll_no", - "allocation_id__roll_no__department", - "allocation_id__roll_no__degree", - "allocation_id__roll_no__hostel", - "allocation_id__roll_no__room_no", + "name", + "roll_no", + "department", + "degree", + "hostel", + "room_no", "allocation_id__high_tea", "allocation_id__caterer_name", "allocation_id__student_id", @@ -178,12 +178,12 @@ class Meta: ) export_order = [ "email", - "allocation_id__roll_no__name", - "allocation_id__roll_no__roll_no", - "allocation_id__roll_no__department", - "allocation_id__roll_no__degree", - "allocation_id__roll_no__hostel", - "allocation_id__roll_no__room_no", + "name", + "roll_no", + "department", + "degree", + "hostel", + "room_no", "allocation_id__high_tea", "allocation_id__student_id", "date_applied", @@ -201,7 +201,7 @@ class LongRebateResource(resources.ModelResource): email__degree = fields.Field(attribute="email__degree", column_name="Degree") email__hostel = fields.Field(attribute="email__hostel", column_name="Hostel") email__room_no = fields.Field(attribute="email__room_no", column_name="Room No.") - date_applied = fields.Field(attribute="date_applied", column_name="date_applied") + date_applied = fields.Field(attribute="date_applied", column_name="Date Applied") days = fields.Field(attribute="days", column_name="days") start_date = fields.Field(attribute="start_date", column_name="Start Date") end_date = fields.Field(attribute="end_date", column_name="End Date")