aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-07 22:40:57 +0200
committerAlban Gruin2017-09-07 22:40:57 +0200
commit36b4c60aacae827b5ff8b6125bdfd70d7cf2a3a0 (patch)
treeea056fedf7819b9342e02d44b48f0dd89229deee
parentf18b2cc4f4aa7b2ed2d7801c19ddf75acbb6abc2 (diff)
J’ai fait des trucs mais je me suis rendu compte que c’est pas
terrible, du coup je fais un commit tout pété mais ça va vite changer vous inquiétez pas.
-rw-r--r--templates/group_list.html (renamed from templates/timetables_list.html)0
-rw-r--r--templates/mention_list.html2
-rw-r--r--urls.py3
-rw-r--r--views.py8
4 files changed, 7 insertions, 6 deletions
diff --git a/templates/timetables_list.html b/templates/group_list.html
index d4c3579..d4c3579 100644
--- a/templates/timetables_list.html
+++ b/templates/group_list.html
diff --git a/templates/mention_list.html b/templates/mention_list.html
index 3c455af..142a17a 100644
--- a/templates/mention_list.html
+++ b/templates/mention_list.html
@@ -6,7 +6,7 @@
<h3>Choisissez votre mention</h3>
<ul>
{% for timetable in timetables %}
- <li><a href="#">{{ timetable.name }}</a></li>
+ <li><a href="{% url "groups" year timetable.slug %}">{{ timetable.name }}</a></li>
{% empty %}
<p>Aucun emploi du temps à afficher</p>
{% endfor %}
diff --git a/urls.py b/urls.py
index c9deef1..5731b44 100644
--- a/urls.py
+++ b/urls.py
@@ -20,10 +20,11 @@ from . import feeds, views
urlpatterns = [
url(r"^$", views.index, name="index"),
url(r"^(?P<year>[-\w]+)/$", views.mention_list, name="mentions"),
+ url(r"^(?P<year>[-\w]+)/(?P<timetable_slug>[-\w]+)/$", views.group_list, name="groups"),
url(r"^(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/$", views.timetable, name="timetable"),
+ url(r"^(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/calendar.ics$", feeds.IcalFeed(), name="ics"),
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$", 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 363fddb..141dde8 100644
--- a/views.py
+++ b/views.py
@@ -32,9 +32,9 @@ 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")
+def group_list(request, year, timetable_slug):
+ timetable = get_object_or_404(Timetable, slug=timetable_slug)
+ groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name")
year, week = get_current_week()
start, _ = get_week(year, week)
@@ -53,7 +53,7 @@ def timetables_list(request):
if hasattr(group, "weeks"):
group.weeks.sort()
- return render(request, "timetables_list.html", {"timetables": timetables, "groups": groups})
+ return render(request, "group_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: