aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-10 12:26:40 +0200
committerAlban Gruin2017-09-10 12:26:40 +0200
commit6eef540f3de6b6b7a81b058f99950da40af00359 (patch)
tree3b52a00451d132af64ca3b9480f5dbad66eaf4f2
parent965fb737b5ca4f258cc8f9ff1bd52ca1ce18a635 (diff)
Ajout d’une page contact. L’adresse email est brouillée.
-rw-r--r--templates/contact.html9
-rw-r--r--templates/index.html2
-rw-r--r--templatetags/email.py24
-rw-r--r--urls.py1
-rw-r--r--views.py4
5 files changed, 39 insertions, 1 deletions
diff --git a/templates/contact.html b/templates/contact.html
new file mode 100644
index 0000000..1359a16
--- /dev/null
+++ b/templates/contact.html
@@ -0,0 +1,9 @@
+{% extends "index.html" %}
+{% load email %}
+
+{% block title %}Contacter – {% endblock %}
+
+{% block body %}
+ <h3>Contacter</h3>
+ <p>Pour contacter l’administrateur du service, envoyez un mail à l’adresse suivante :<br/>{{ email|format_email }}.</p>
+{% endblock %}
diff --git a/templates/index.html b/templates/index.html
index 366e6f9..6597158 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -23,7 +23,7 @@
{% endblock %}
</div>
<footer>
- <p>(c) 2017 &ndash; Alban Gruin<br />
+ <p>(c) 2017 &ndash; Alban Gruin &ndash; <a href="{% url "contact" %}">contacter</a><br />
Design inspiré par <a href="https://bestmotherfucking.website/">https://bestmotherfucking.website/</a><br />
Les informations affichées sur ce site sont actualisées tout les jours à minuit CET.
</p>
diff --git a/templatetags/email.py b/templatetags/email.py
new file mode 100644
index 0000000..68dbd84
--- /dev/null
+++ b/templatetags/email.py
@@ -0,0 +1,24 @@
+# Copyright (C) 2017 Alban Gruin
+#
+# celcatsanitizer is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# celcatsanitizer is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with celcatsanitizer. If not, see <http://www.gnu.org/licenses/>.
+
+from django import template
+
+register = template.Library()
+
+@register.filter
+def format_email(address):
+ return address.replace("+", " [plus] ") \
+ .replace("@", " [arobase] ") \
+ .replace(".", " [point] ")
diff --git a/urls.py b/urls.py
index 2e731b5..58cf019 100644
--- a/urls.py
+++ b/urls.py
@@ -18,6 +18,7 @@ from . import feeds, views
urlpatterns = [
url(r"^$", views.index, name="index"),
+ url(r"^contact$", views.contact, name="contact"),
url(r"^(?P<year_slug>[-\w]+)/$", views.mention_list, name="mentions"),
url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/$", views.group_list, name="groups"),
url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/$", views.timetable, name="timetable"),
diff --git a/views.py b/views.py
index f445725..302b375 100644
--- a/views.py
+++ b/views.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with celcatsanitizer. If not, see <http://www.gnu.org/licenses/>.
+from django.conf import settings
from django.shortcuts import get_object_or_404, render
from .models import Timetable, LastUpdate, Group, Course, Year
@@ -65,3 +66,6 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No
grouped_courses = group_courses(courses)
return render(request, "timetable.html", {"group": group, "courses": grouped_courses, "last_update": last_update.date, "year": year, "week": int(week)})
+
+def contact(request):
+ return render(request, "contact.html", {"email": settings.ADMINS[0][1]})