aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-02-13 19:39:41 +0100
committerAlban Gruin2017-02-13 19:39:41 +0100
commitde405f2212fa64ad2a6a11f6d18186571021ad8c (patch)
treed5cc35ff2d96219809eafa15ee08e9ce0238c60d
parentd91081d8539988aaca426022c3f28ad78a024bea (diff)
Regroupement des deux mails d'emploi du temps dans une seule template, c'est plus propre
-rw-r--r--management/commands/sendmails.py11
-rw-r--r--templates/mail/mail_noevent.txt2
-rw-r--r--templates/mail/mail_timetable.txt2
3 files changed, 4 insertions, 11 deletions
diff --git a/management/commands/sendmails.py b/management/commands/sendmails.py
index e30bb1b..9a05a9c 100644
--- a/management/commands/sendmails.py
+++ b/management/commands/sendmails.py
@@ -40,7 +40,6 @@ class Command(BaseCommand):
mails = []
footer = loader.get_template("mail/mail_footer.txt")
- no_event = loader.get_template("mail/mail_noevent.txt")
timetable = loader.get_template("mail/mail_timetable.txt")
print("Generating messages...")
@@ -48,13 +47,9 @@ class Command(BaseCommand):
if subscription.group.id not in content:
courses = Course.objects.get_courses_for_group(subscription.group, begin__gte=start, begin__lt=end)
- if len(courses) > 0:
- grouped_courses = group_courses(courses)
- context = Context({"courses": grouped_courses, "week": week})
- content[subscription.group.id] = timetable.render(context)
- else:
- context = Context({"group": subscription.group, "week": week})
- content[subscription.group.id] = no_event.render(context)
+ grouped_courses = group_courses(courses)
+ context = Context({"courses": grouped_courses, "group": subscription.group, "week": week})
+ content[subscription.group.id] = timetable.render(context)
context = Context({"admins": settings.ADMINS, "token": subscription.token, "domain": settings.DEFAULT_DOMAIN})
mail_content = content[subscription.group.id] + footer.render(context)
diff --git a/templates/mail/mail_noevent.txt b/templates/mail/mail_noevent.txt
deleted file mode 100644
index dc01189..0000000
--- a/templates/mail/mail_noevent.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Aucun cours pour le groupe {{ group }} pendant la semaine {{ week }}.
-
diff --git a/templates/mail/mail_timetable.txt b/templates/mail/mail_timetable.txt
index 65b5c01..06a2b1c 100644
--- a/templates/mail/mail_timetable.txt
+++ b/templates/mail/mail_timetable.txt
@@ -2,5 +2,5 @@
{% for course in day %}
* {{ course.name }} ({{ course.type }}), de {{ course.begin|date:"H:i" }} à {{ course.end|date:"H:i" }}{% if course.rooms.all|length > 0 %}
Salle{% if course.rooms.all|length > 1 %}s{% endif %} {% for room in course.rooms.all %}{{ room }} {% endfor %}{% endif %}
-{% endfor %}
+{% endfor %}{% empty %}Aucun cours pour le groupe {{ group }} pendant la semaine {{ week }}.
{% endfor %}{% endautoescape %}