Skip to content

Commit bc75f4d

Browse files
committed
add small action for short rebate
1 parent e3aa828 commit bc75f4d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

home/admin.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,24 @@ def find_overlapping_records(self, request, queryset):
540540

541541
return response
542542

543+
def check_negative_days(self, request, queryset):
544+
response = HttpResponse(content_type="text/csv")
545+
response["Content-Disposition"] = 'attachment; filename="Rebate.csv"'
546+
547+
writer = csv.writer(response)
548+
for obj in queryset:
549+
if (obj.end_date - obj.start_date).days < 0:
550+
writer.writerow(
551+
[
552+
obj.email,
553+
obj.start_date,
554+
obj.end_date,
555+
getattr(obj.email, "name", None),
556+
]
557+
)
558+
559+
return response
560+
543561
export_as_csv.short_description = "Export Rebate details to CSV"
544562

545563

0 commit comments

Comments
 (0)