Skip to content

Commit

Permalink
add small action for short rebate
Browse files Browse the repository at this point in the history
  • Loading branch information
mittal-ishaan committed Nov 19, 2024
1 parent e3aa828 commit bc75f4d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,24 @@ def find_overlapping_records(self, request, queryset):

return response

def check_negative_days(self, request, queryset):
response = HttpResponse(content_type="text/csv")
response["Content-Disposition"] = 'attachment; filename="Rebate.csv"'

writer = csv.writer(response)
for obj in queryset:
if (obj.end_date - obj.start_date).days < 0:
writer.writerow(
[
obj.email,
obj.start_date,
obj.end_date,
getattr(obj.email, "name", None),
]
)

return response

export_as_csv.short_description = "Export Rebate details to CSV"


Expand Down

0 comments on commit bc75f4d

Please sign in to comment.