mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
from django.utils import timezone
|
|
from djoser import email
|
|
|
|
|
|
class ActivationEmail(email.ActivationEmail):
|
|
template_name = "email_activation.html"
|
|
|
|
|
|
class PasswordResetEmail(email.PasswordResetEmail):
|
|
template_name = "password_change.html"
|
|
|
|
# TODO: Fix email template values not filling in properly
|
|
|
|
|
|
class SubscriptionAvailedEmail(email.BaseEmailMessage):
|
|
template_name = "subscription_availed.html"
|
|
|
|
def get_context_data(self):
|
|
context = super().get_context_data()
|
|
context["user"] = context.get("user")
|
|
context["subscription_plan"] = context.get("subscription_plan")
|
|
context["subscription"] = context.get("subscription")
|
|
context["price_paid"] = context.get("price_paid")
|
|
context["date"] = timezone.now().strftime("%B %d, %I:%M %p")
|
|
context.update(self.context)
|
|
return context
|
|
|
|
|
|
class SubscriptionRefundedEmail(email.BaseEmailMessage):
|
|
template_name = "subscription_refunded.html"
|
|
|
|
def get_context_data(self):
|
|
context = super().get_context_data()
|
|
context["user"] = context.get("user")
|
|
context["subscription_plan"] = context.get("subscription_plan")
|
|
context["refund"] = context.get("refund")
|
|
context["date"] = timezone.now().strftime("%B %d, %I:%M %p")
|
|
context.update(self.context)
|
|
return context
|
|
|
|
|
|
class SubscriptionCancelledEmail(email.BaseEmailMessage):
|
|
template_name = "subscription_cancelled.html"
|
|
|
|
def get_context_data(self):
|
|
context = super().get_context_data()
|
|
context["user"] = context.get("user")
|
|
context["subscription_plan"] = context.get("subscription_plan")
|
|
context["date"] = timezone.now().strftime("%B %d, %I:%M %p")
|
|
context.update(self.context)
|
|
return context
|