diff --git a/src/series/tasks.py b/src/series/tasks.py index 59e7430..4867db0 100644 --- a/src/series/tasks.py +++ b/src/series/tasks.py @@ -27,17 +27,15 @@ 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( 'New Episodes!', message, to=[user.email] ) email.send() - return return if series_len: @@ -45,11 +43,21 @@ def send_email(user): 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 + }) + 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, - 'error_series_list': series_counter.error_series, - 'maximum_usage': '' + 'new_series_list': series_counter.new_series_list }) email = EmailMessage( 'New Episodes!', message, to=[user.email] diff --git a/src/series/templates/email/error_series_notification.html b/src/series/templates/email/error_series_notification.html new file mode 100644 index 0000000..7169471 --- /dev/null +++ b/src/series/templates/email/error_series_notification.html @@ -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 %} \ No newline at end of file diff --git a/src/series/templates/email/maximum_usage_notification.html b/src/series/templates/email/maximum_usage_notification.html new file mode 100644 index 0000000..6b2a9d9 --- /dev/null +++ b/src/series/templates/email/maximum_usage_notification.html @@ -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 %} \ No newline at end of file diff --git a/src/series/templates/email/new_series_notification.html b/src/series/templates/email/new_series_notification.html new file mode 100644 index 0000000..08e8a65 --- /dev/null +++ b/src/series/templates/email/new_series_notification.html @@ -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 %} \ No newline at end of file diff --git a/src/series/templates/new_episodes_notification.html b/src/series/templates/new_episodes_notification.html deleted file mode 100644 index aea0f8c..0000000 --- a/src/series/templates/new_episodes_notification.html +++ /dev/null @@ -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 %} \ No newline at end of file