aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-07 22:22:46 +0200
committerAlban Gruin2017-09-07 22:22:46 +0200
commitf18b2cc4f4aa7b2ed2d7801c19ddf75acbb6abc2 (patch)
treebcff554a2e98460075780e339141f7adf289704c
parenta79e87a3ecfd505846c04f7949b1036a102430ed (diff)
Remplacement de la page d’acceuil par la liste des années, menant sur
une liste de mentions, puis une liste de groupes, etc etc.
-rw-r--r--templates/index.html18
-rw-r--r--templates/mention_list.html14
-rw-r--r--templates/timetables_list.html9
-rw-r--r--urls.py7
-rw-r--r--views.py11
5 files changed, 47 insertions, 12 deletions
diff --git a/templates/index.html b/templates/index.html
index d834884..09bb0f6 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -58,13 +58,17 @@ li.course {
<header>
<h1><a href="{% url "index" %}">celcatsanitizer</a></h1>
</header>
- <div class="content">{% block body %}{% for timetable in timetables %}
- <section id="{{ timetable.slug }}">
- <h3><a href="{{ timetable.url }}">{{ timetable.name }}</a></h3>
- <ul>{% for group in groups %}{% if group.timetable.id == timetable.id %}
- <li><a class="text"{% if group.weeks is not None %} href="{% url "timetable" timetable.slug group.slug %}"{% endif %}>{{ group.name }}</a> &ndash; {% for week in group.weeks %}<a href="{% url "timetable" timetable.slug group.slug week.year week|dt_week %}">{{ week|dt_prettyprint }}</a> {% empty %}<em>aucun cours</em>{% endfor %}</li>{% endif %}{% endfor %}
- </ul>
- </section>{% endfor %}{% endblock %}
+ <div class="content">
+ {% block body %}
+ <h3>Choisissez votre année</h3>
+ <ul>
+ {% for year in years %}
+ <li><a href="{% url "mentions" year.year %}">{{ year.year }}</a> <small>({{ year.count }})</small></li>
+ {% empty %}
+ <p><em>Aucun emploi du temps à afficher</em></p>
+ {% endfor %}
+ </ul>
+ {% endblock %}
</div>
<footer>
<p>(c) 2017 &ndash; Alban Gruin<br />
diff --git a/templates/mention_list.html b/templates/mention_list.html
new file mode 100644
index 0000000..3c455af
--- /dev/null
+++ b/templates/mention_list.html
@@ -0,0 +1,14 @@
+{% extends "index.html" %}
+
+{% block title %}{{ year }} &ndash; {% endblock %}
+
+{% block body %}
+ <h3>Choisissez votre mention</h3>
+ <ul>
+{% for timetable in timetables %}
+ <li><a href="#">{{ timetable.name }}</a></li>
+{% empty %}
+ <p>Aucun emploi du temps à afficher</p>
+{% endfor %}
+ </ul>
+{% endblock %}
diff --git a/templates/timetables_list.html b/templates/timetables_list.html
new file mode 100644
index 0000000..d4c3579
--- /dev/null
+++ b/templates/timetables_list.html
@@ -0,0 +1,9 @@
+{% extends "index.html" %}
+
+{% block body %}{% for timetable in timetables %}
+ <section id="{{ timetable.slug }}">
+ <h3><a href="{{ timetable.url }}">{{ timetable.name }}</a></h3>
+ <ul>{% for group in groups %}{% if group.timetable.id == timetable.id %}
+ <li><a class="text"{% if group.weeks is not None %} href="{% url "timetable" timetable.slug group.slug %}"{% endif %}>{{ group.name }}</a> &ndash; {% for week in group.weeks %}<a href="{% url "timetable" timetable.slug group.slug week.year week|dt_week %}">{{ week|dt_prettyprint }}</a> {% empty %}<em>aucun cours</em>{% endfor %}</li>{% endif %}{% endfor %}
+ </ul>
+ </section>{% endfor %}{% endblock %}
diff --git a/urls.py b/urls.py
index 3faa78d..c9deef1 100644
--- a/urls.py
+++ b/urls.py
@@ -15,16 +15,15 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.conf.urls import url
-
-from . import views
-from .feeds import IcalFeed
+from . import feeds, views
urlpatterns = [
url(r"^$", views.index, name="index"),
+ url(r"^(?P<year>[-\w]+)/$", views.mention_list, name="mentions"),
url(r"^(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/$", views.timetable, name="timetable"),
url(r"^(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/(?P<year>[0-9]{4})/(?P<week>[0-4]?[0-9]|5[0-3])/$", views.timetable, name="timetable"),
url(r"^(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/(?P<year>[0-9]{4})/(?P<week>[0-4]?[0-9]|5[0-3])/subscribe$", views.subscribe, name="subscribe"),
- url(r"^(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/calendar.ics$", IcalFeed(), name="ics"),
+ url(r"^(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/calendar.ics$", feeds.IcalFeed(), name="ics"),
url(r"^subscriptions/confirm/(?P<token>[0-9a-f]{40})$", views.confirm_subscription, name="confirm"),
url(r"^subscriptions/cancel/(?P<token>[0-9a-f]{40})$", views.cancel_subscription, name="cancel"),
]
diff --git a/views.py b/views.py
index 176f174..363fddb 100644
--- a/views.py
+++ b/views.py
@@ -18,12 +18,21 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.core.mail import send_mail
from django.conf import settings
from django.template import Context, loader
+from django.db.models import Count
from .forms import SubscribeForm
from .models import Timetable, LastUpdate, Group, Subscription, Course
from .utils import get_current_week, get_week, group_courses
def index(request):
+ years = Timetable.objects.order_by("year").values("year").annotate(count=Count("year"))
+ return render(request, "index.html", {"years": years})
+
+def mention_list(request, year):
+ timetables = Timetable.objects.order_by("name").filter(year=year)
+ return render(request, "mention_list.html", {"year": year, "timetables": timetables})
+
+def timetables_list(request):
timetables = Timetable.objects.order_by("name")
groups = Group.objects.get_relevant_groups().order_by("name")
@@ -44,7 +53,7 @@ def index(request):
if hasattr(group, "weeks"):
group.weeks.sort()
- return render(request, "index.html", {"timetables": timetables, "groups": groups})
+ return render(request, "timetables_list.html", {"timetables": timetables, "groups": groups})
def timetable(request, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None: