-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from volunteers-for-city-projects/feature/inc…
…omes_approve_send_email Feature/incomes approve send email
- Loading branch information
Showing
5 changed files
with
132 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from templated_mail.mail import BaseEmailMessage | ||
|
||
|
||
class IncomesApproveEmail(BaseEmailMessage): | ||
template_name = 'email/incomes_approve.html' | ||
|
||
def get_context_data(self): | ||
context = super().get_context_data() | ||
|
||
user = context.get('user') | ||
project = context.get('project') | ||
date_time = context.get('date_time') | ||
context.update({ | ||
'user': user, | ||
'project': project, | ||
'date_time': date_time, | ||
}) | ||
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from celery import shared_task | ||
from django.contrib.auth import get_user_model | ||
from django.utils import timezone | ||
from djoser.compat import get_user_email | ||
|
||
from .email import IncomesApproveEmail | ||
|
||
User = get_user_model() | ||
|
||
|
||
@shared_task | ||
def incomes_approve_send_email(instance_pk, ctx): | ||
from projects.models import ProjectParticipants # noqa | ||
date_time = timezone.now() | ||
instance = ProjectParticipants.objects.filter( | ||
pk=instance_pk).select_related('volunteer__user', 'project').first() | ||
ctx.update({ | ||
'user': instance.volunteer.user, | ||
'project': instance.project, | ||
'date_time': date_time, | ||
}) | ||
to = [get_user_email(instance.volunteer.user)] | ||
IncomesApproveEmail(context=ctx).send(to) |
26 changes: 26 additions & 0 deletions
26
backend/notifications/templates/email/incomes_approve.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% load i18n %} | ||
|
||
{% block subject %} | ||
Заявка принята на {{ site_name }} | ||
{% endblock subject %} | ||
|
||
{% block text_body %} | ||
Уважаемый {% if user.get_full_name %} {{ user.get_full_name }} {% else %} Волонтер {% endif %}, | ||
уведомляем, что ваша заявка на участие в проекте: {{ project.name }} одобрена | ||
организатором. | ||
|
||
{% trans "Thanks for using our site!" %} | ||
|
||
{% blocktrans %}The {{ site_name }} team{% endblocktrans %} | ||
{% endblock text_body %} | ||
|
||
{% block html_body %} | ||
<p>Уважаемый {% if user.get_full_name %} {{ user.get_full_name }} {% else %} Волонтер {% endif %}, | ||
уведомляем, что ваша заявка на участие в проекте: {{ project.name }} одобрена | ||
организатором. | ||
|
||
<p>{% trans "Thanks for using our site!" %}</p> | ||
|
||
<p>{% blocktrans %}The {{ site_name }} team{% endblocktrans %}</p> | ||
|
||
{% endblock html_body %} |