Overhauled entire project config, added notifications, email templates, optimized stripe subscriptions, redis caching, and webdriver utilities

This commit is contained in:
Keannu Christian Bernasol 2024-05-10 23:15:29 +08:00
parent 7cbe8fd720
commit 99dfcef67b
84 changed files with 4300 additions and 867 deletions

View file

6
backend/emails/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class EmailsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'emails'

View file

@ -0,0 +1,49 @@
from djoser import email
from django.utils import timezone
class ActivationEmail(email.ActivationEmail):
template_name = 'templates/email_activation.html'
class PasswordResetEmail(email.PasswordResetEmail):
template_name = 'templates/password_change.html'
class SubscriptionAvailedEmail(email.BaseEmailMessage):
template_name = "templates/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 = "templates/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 = "templates/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

View file

@ -0,0 +1,28 @@
{% load i18n %}
{% block subject %}
{% blocktrans %}Account activation on {{ site_name }}{% endblocktrans %}
{% endblock subject %}
{% block text_body %}
{% blocktrans %}You're receiving this email because you need to finish activation process on {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page to activate account:" %}
{{ protocol }}://{{ domain }}/{{ url|safe }}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endblock text_body %}
{% block html_body %}
<p>{% blocktrans %}You're receiving this email because you need to finish activation process on {{ site_name }}.{% endblocktrans %}</p>
<p>{% trans "Please go to the following page to activate account:" %}</p>
<p><a href="{{ protocol }}://{{ domain }}/{{ url|safe }}">{{ protocol }}://{{ domain }}/{{ url|safe }}</a></p>
<p>{% trans "Thanks for using our site!" %}</p>
<p>{% blocktrans %}The {{ site_name }} team{% endblocktrans %}</p>
{% endblock html_body %}

View file

@ -0,0 +1,29 @@
{% load i18n %}
{% block subject %}
{% blocktrans %}Password reset on {{ site_name }}{% endblocktrans %}
{% endblock subject %}
{% block text_body %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{{ protocol }}://{{ domain }}/{{ url|safe }}
{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endblock text_body %}
{% block html_body %}
<p>{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}</p>
<p>{% trans "Please go to the following page and choose a new password:" %}</p>
<a href="{{ protocol }}://{{ domain }}/{{ url|safe }}">{{ protocol }}://{{ domain }}/{{ url|safe }}</a>
<p>{% trans "Your username, in case you've forgotten:" %} <b>{{ user.get_username }}</b></p>
<p>{% trans "Thanks for using our site!" %}</p>
<p>{% blocktrans %}The {{ site_name }} team{% endblocktrans %}</p>
{% endblock html_body %}

View file

@ -0,0 +1,20 @@
{% load i18n %}
{% block subject %}
{% blocktrans %}Subscription Availed on {{ site_name }}{% endblocktrans %}
{% endblock subject %}
{% block text_body %}
{% blocktrans %}You're receiving this email because you availed the {{ subscription_plan.name }} amounting to {{ price_paid.amount }}{{ price_paid.currency}} at {{ site_name }}.{% endblocktrans %}
{% trans "Thanks for using our site!" %}
{% endblock text_body %}
{% block html_body %}
<p>{% blocktrans %}You're receiving this email because you availed the {{ subscription_plan.name }} at {{ site_name }}.{% endblocktrans %}</p>
<p>{% trans "Thanks for using our site!" %}</p>
{% endblock html_body %}

View file

@ -0,0 +1,24 @@
{% load i18n %}
{% block subject %}
{% blocktrans %}Subscription Cancelled on {{ site_name }}{% endblocktrans %}
{% endblock subject %}
{% block text_body %}
{% blocktrans %}You're receiving this email because your subscription for the {{ subscription_plan.name }} Plan has been cancelled at {{ site_name }}.{% endblocktrans %}
{% trans "Thanks for using our site!" %}
{% endblock text_body %}
{% block html_body %}
<p>
{% blocktrans %}
You're receiving this email because your subscription for the {{ subscription_plan.name }} Plan has been cancelled at {{ site_name }}.
{% endblocktrans %}
</p>
<p>{% trans "Thanks for using our site!" %}</p>
{% endblock html_body %}

View file

@ -0,0 +1,20 @@
{% load i18n %}
{% block subject %}
{% blocktrans %}Subscription Refunded on {{ site_name }}{% endblocktrans %}
{% endblock subject %}
{% block text_body %}
{% blocktrans %}You're receiving this email because your subscription for the {{ subscription_plan.name }} Plan has been refunded at {{ site_name }}. You have been refunded {{ refund.amount }}{{ refund.currency }}{% endblocktrans %}
{% trans "Thanks for using our site!" %}
{% endblock text_body %}
{% block html_body %}
<p>{% blocktrans %}You're receiving this email because your subscription for the {{ subscription_plan.name }} Plan has been refunded at {{ site_name }}. You have been refunded {{ refund.amount }}{{ refund.currency }}{% endblocktrans %}</p>
<p>{% trans "Thanks for using our site!" %}</p>
{% endblock html_body %}