Skip to content

Commit

Permalink
update email configs and templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeniy-Golodnykh committed Jan 19, 2025
1 parent ded0c4b commit 755f92b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 42 deletions.
1 change: 1 addition & 0 deletions blackfox/blackfox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'users.email.email_context_processor',
],
},
},
Expand Down
34 changes: 14 additions & 20 deletions blackfox/templates/email/activation.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
{% load i18n %}

{% block subject %}
{% blocktrans %}Account activation on BlackFox Nutrition website{% endblocktrans %}
{% blocktrans %}Активация аккаунта на сайте BlackFox Nutrition{% endblocktrans %}
{% endblock subject %}

{% block text_body %}
{% blocktrans %}You're receiving this email because you need to finish activation process on BlackFox Nutrition website.{% endblocktrans %}

{% trans "Please go to the following page to activate account:" %}
https://www.blackfoxnutrition.ru/{{ 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 BlackFox Nutrition website.{% endblocktrans %}</p>

<p>{% trans "Please go to the following page to activate account:" %}</p>
<p><a href="https://www.blackfoxnutrition.ru/{{ url|safe }}">https://www.blackfoxnutrition.ru/{{ url|safe }}</a></p>

<p>{% trans "Thanks for using our site!" %}</p>

<p>{% blocktrans %}The BlackFox Nutrition team{% endblocktrans %}</p>
<div style="max-width: 900px; margin: 0; border-radius: 5px; padding: 20px; font-family: Arial, sans-serif; background-color: #f9f9f9; color: #333;">
<h2>{% blocktrans %}Активация аккаунта{% endblocktrans %}</h2>
<p>{% blocktrans %}{{ first_name }}, здравствуйте!{% endblocktrans %}</p>
<p>{% blocktrans %}Cпасибо за регистрацию на сайте <b>BlackFox Nutrition</b>. Чтобы активировать вашу учетную запись, пожалуйста, нажмите на кнопку ниже:{% endblocktrans %}</p>
<a href="https://www.blackfoxnutrition.ru/{{ url|safe }}" style="display: inline-block; padding: 10px 20px; color: #fff; background-color: #007BFF; text-decoration: none; border-radius: 5px;">
{% blocktrans %}Активировать аккаунт{% endblocktrans %}
</a>
<p>{% blocktrans %}Если вы не регистрировались на нашем сайте, просто проигнорируйте это письмо.{% endblocktrans %}</p>
<p>{% blocktrans %}Спасибо, что выбрали нас!{% endblocktrans %}</p>
<footer style="margin-top: 20px; font-size: 0.9em; color: #777;">
{% blocktrans %}&copy; BlackFox Nutrition, {{ year }} г. Все права защищены.{% endblocktrans %}
</footer>
</div>
{% endblock html_body %}
36 changes: 14 additions & 22 deletions blackfox/templates/email/password_reset.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
{% load i18n %}

{% block subject %}
{% blocktrans %}Password reset on BlackFox Nutrition website{% endblocktrans %}
{% blocktrans %}Сброс пароля на сайте BlackFox Nutrition{% endblocktrans %}
{% endblock subject %}

{% block text_body %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at BlackFox Nutrition website.{% endblocktrans %}

{% trans "Please go to the following page and choose a new password:" %}
https://www.blackfoxnutrition.ru/{{ url|safe }}
{% trans "Your email, in case you've forgotten:" %} {{ user.get_username }}

{% trans "Thanks for using our site!" %}

{% blocktrans %}The BlackFox Nutrition 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 BlackFox Nutrition website.{% endblocktrans %}</p>

<p>{% trans "Please go to the following page and choose a new password:" %}</p>
<a href="https://www.blackfoxnutrition.ru/{{ url|safe }}">https://www.blackfoxnutrition.ru/{{ url|safe }}</a>
<p>{% trans "Your email, in case you've forgotten:" %} <b>{{ user.get_username }}</b></p>

<p>{% trans "Thanks for using our site!" %}</p>

<p>{% blocktrans %}The BlackFox Nutrition team{% endblocktrans %}</p>
<div style="max-width: 900px; margin: 0; border-radius: 5px; padding: 20px; font-family: Arial, sans-serif; background-color: #f9f9f9; color: #333;">
<h2>{% blocktrans %}Сброс пароля{% endblocktrans %}</h2>
<p>{% blocktrans %}{{ first_name }}, здравствуйте!{% endblocktrans %}</p>
<p>{% blocktrans %}Вы запросили сброс пароля для вашей учетной записи на сайте <b>BlackFox Nutrition</b>. Чтобы установить новый пароль, пожалуйста, нажмите на кнопку ниже:{% endblocktrans %}</p>
<a href="https://www.blackfoxnutrition.ru/{{ url|safe }}" style="display: inline-block; padding: 10px 20px; color: #fff; background-color: #007BFF; text-decoration: none; border-radius: 5px;">
{% blocktrans %}Сбросить пароль{% endblocktrans %}
</a>
<p>{% blocktrans %}Если вы не запрашивали сброс пароля, просто проигнорируйте это письмо. Ваш текущий пароль останется без изменений.{% endblocktrans %}</p>
<p>{% blocktrans %}Спасибо, что используете наш сервис!{% endblocktrans %}</p>
<footer style="margin-top: 20px; font-size: 0.9em; color: #777;">
{% blocktrans %}&copy; BlackFox Nutrition, {{ year }} г. Все права защищены.{% endblocktrans %}
</footer>
</div>
{% endblock html_body %}
15 changes: 15 additions & 0 deletions blackfox/users/email.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import datetime

from django.contrib.auth import get_user_model
from djoser import email

User = get_user_model()


class ActivationEmail(email.ActivationEmail):
'''Override activation email with template.'''
Expand All @@ -11,3 +16,13 @@ class PasswordResetEmail(email.PasswordResetEmail):
'''Override reset password email with template.'''

template_name = 'email/password_reset.html'


def email_context_processor(request):
if not hasattr(request, 'data'):
return {}
email = request.data.get('email')
return {
'first_name': User.objects.filter(email=email).first().first_name,
'year': datetime.datetime.now().year
} if email else {}

0 comments on commit 755f92b

Please sign in to comment.