Skip to content

Commit

Permalink
rebate name added, long rebate query email added
Browse files Browse the repository at this point in the history
  • Loading branch information
mittal-ishaan committed Nov 7, 2023
1 parent fe77168 commit 0479670
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
28 changes: 15 additions & 13 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.contrib import admin
from django.http import HttpResponse
from django.utils.translation import gettext_lazy as _
from .utils.django_email_server import rebate_mail,caterer_mail
from .utils.django_email_server import rebate_mail,caterer_mail, long_rebate_query_mail
from .utils.rebate_bills_saver import save_short_bill, save_long_bill, update_bills
from .utils.month import fill_periods
from home.models import (
Expand Down Expand Up @@ -399,7 +399,7 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
},
),
)
actions = ["export_as_csv", "disapprove", "approve"]
actions = ["export_as_csv", "disapprove", "approve","send_mail"]

@admin.action(description="Disapprove the students")
def disapprove(self, request, queryset):
Expand Down Expand Up @@ -431,17 +431,13 @@ 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
# )

@admin.action(description="Send query mail to the students")
def send_mail(self, request, queryset):
"""
Send mail action available in the admin page
"""
for obj in queryset:
long_rebate_query_mail(obj.start_date, obj.end_date, obj.email.email)

@admin.register(Rebate)
class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
Expand All @@ -459,6 +455,7 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
list_display = (
"date_applied",
"email",
"name",
"start_date",
"end_date",
"approved",
Expand All @@ -479,6 +476,11 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
},
),
)

@admin.display(description="name")
def name(self, obj):
return obj.email.name

actions = ["export_as_csv", "disapprove", "approve"]

@admin.action(description="Disapprove the students")
Expand Down
12 changes: 12 additions & 0 deletions home/utils/django_email_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def send_html(subject, message, recipient):
left_message = """Note: Bills for {left_start_date} to {left_end_date} will be removed as an when you are allotcated a caterer during this period.
"""

message_long_rebate_query = """
Dear Student,
Your long term rebate application from {start_date} to {end_date} has been recieved but contains some issues.
Kindly send your long rebate application photograph as a reply to this mail itself itself.
"""


def rebate_mail(start_date, end_date, approved, recipient):
subject = subject_rebate
if(approved): message = message_rebate.format(start_date=start_date, end_date=end_date, approved = "approved")
Expand All @@ -75,6 +82,11 @@ def long_rebate_mail(start_date, end_date, approved, recipient, left_start_date,
message = message_long_rebate.format(start_date=start_date, end_date=end_date, approved = "rejected",added="added to")
send(subject, message, recipient)

def long_rebate_query_mail(start_date, end_date, recipient):
subject = "Long Term Rebate Application Query"
message = message_long_rebate_query.format(start_date=start_date, end_date=end_date)
send(subject, message, recipient)

def __send__rebate__email__():
from datetime import date
today = date.today()
Expand Down

0 comments on commit 0479670

Please sign in to comment.