Added email templates

This commit is contained in:
ayxan 2022-12-22 10:55:47 +04:00
parent 0ad9f71f2a
commit b94de6e428
5 changed files with 51 additions and 43 deletions

View File

@ -27,10 +27,9 @@ def send_email(user):
for updated_series in series_counter.new_series_list:
update_series(updated_series)
updated_series.save()
message = render_to_string('new_episodes_notification.html', {
message = render_to_string('email/maximum_usage_notification.html', {
'user': user,
'new_series_list': series_counter.new_series_list,
'error_series_list': series_counter.error_series,
'maximum_usage': str(e)
})
email = EmailMessage(
@ -38,18 +37,27 @@ def send_email(user):
)
email.send()
return
return
if series_len:
for updated_series in series_counter.new_series_list:
update_series(updated_series)
updated_series.series.save()
message = render_to_string('new_episodes_notification.html', {
if series_counter.error_series:
message = render_to_string('email/error_series_notification.html', {
'user': user,
'new_series_list': series_counter.new_series_list,
'error_series_list': series_counter.error_series,
'maximum_usage': ''
'error_series_list': series_counter.error_series
})
email = EmailMessage(
'New Episodes!', message, to=[user.email]
)
email.send()
return
message = render_to_string('email/error_series_notification.html', {
'user': user,
'new_series_list': series_counter.new_series_list
})
email = EmailMessage(
'New Episodes!', message, to=[user.email]

View File

@ -0,0 +1,15 @@
{% autoescape off %}
Hi {{ user.username }},
There are new episodes of the series you recorded.
Some series could not be updated:
{% for e in error_series_list %}
e.title
{% endfor %}
{% for s in new_series_list %}
{{s.series.title}}: watched - {{s.series.watched_season}}-{{s.series.watched_episode}}, last - {{s.last_season}}-{{s.last_episode}}, new episodes count - {{s.new_episodes_count}}
{% endfor %}
{% endautoescape %}

View File

@ -0,0 +1,11 @@
{% autoescape off %}
Hi {{ user.username }},
There are new episodes of the series you recorded.
Some series could not be updated ({{maximum_usage}})
{% for s in new_series_list %}
{{s.series.title}}: watched - {{s.series.watched_season}}-{{s.series.watched_episode}}, last - {{s.last_season}}-{{s.last_episode}}, new episodes count - {{s.new_episodes_count}}
{% endfor %}
{% endautoescape %}

View File

@ -0,0 +1,10 @@
{% autoescape off %}
Hi {{ user.username }},
There are new episodes of the series you recorded.
{% for s in new_series_list %}
{{s.series.title}}: watched - {{s.series.watched_season}}-{{s.series.watched_episode}}, last - {{s.last_season}}-{{s.last_episode}}, new episodes count - {{s.new_episodes_count}}
{% endfor %}
{% endautoescape %}

View File

@ -1,36 +0,0 @@
{% autoescape off %}
Hi {{ user.username }},
There are new episodes of the series you recorded.
{% if maximum_usage %}
Some series could not be updated ({{maximum_usage}})
{% for s in new_series_list %}
{{s.series.title}}: watched - {{s.series.watched_season}}-{{s.series.watched_episode}}
last - {{s.last_season}}-{{s.last_episode}}
new episodes count - {{s.new_episodes_count}}
{% endfor %}
{% else %}
{% if error_series_list %}
Some series could not be updated:
{% for e in error_series_list %}
e.title
{% endfor %}
{% for s in new_series_list %}
{{s.series.title}}: watched - {{s.series.watched_season}}-{{s.series.watched_episode}}
last - {{s.last_season}}-{{s.last_episode}}
new episodes count - {{s.new_episodes_count}}
{% endfor %}
{% else %}
{% for s in new_series_list %}
{{s.series.title}}: watched - {{s.series.watched_season}}-{{s.series.watched_episode}}
last - {{s.last_season}}-{{s.last_episode}}
new episodes count - {{s.new_episodes_count}}
{% endfor %}
{% endif %}
{% endif %}
{% endautoescape %}