aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--models.py2
-rw-r--r--templates/group_list.html16
-rw-r--r--templates/index.html4
-rw-r--r--templates/mention_list.html4
-rw-r--r--urls.py4
-rw-r--r--views.py17
6 files changed, 26 insertions, 21 deletions
diff --git a/models.py b/models.py
index f10f649..0fe9b87 100644
--- a/models.py
+++ b/models.py
@@ -45,7 +45,7 @@ class Timetable(models.Model):
slug = models.SlugField(max_length=64, unique=True, default="")
def __str__(self):
- return self.name
+ return self.year.name + " " + self.name
class Meta:
diff --git a/templates/group_list.html b/templates/group_list.html
index d4c3579..d8d7227 100644
--- a/templates/group_list.html
+++ b/templates/group_list.html
@@ -1,9 +1,11 @@
{% extends "index.html" %}
+{% load dt_week %}
-{% 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 %}
+{% block body %}
+ <h3><a href="{{ timetable.url }}">{{ timetable }}</a></h3>
+ <ul>
+ {% for group in groups %}
+ <li><a class="text"{% if group.weeks is not None %} href="{% url "timetable" timetable.slug group.slug %}"{% endif %}>{{ group }}</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>
+ {% endfor %}
+ </ul>
+{% endblock %}
diff --git a/templates/index.html b/templates/index.html
index 09bb0f6..e33f92a 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,4 +1,4 @@
-{% load dt_week %}<!DOCTYPE html>
+<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
@@ -63,7 +63,7 @@ li.course {
<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>
+ <li><a href="{% url "mentions" year.slug %}">{{ year }}</a></li>
{% empty %}
<p><em>Aucun emploi du temps à afficher</em></p>
{% endfor %}
diff --git a/templates/mention_list.html b/templates/mention_list.html
index 142a17a..71cfaac 100644
--- a/templates/mention_list.html
+++ b/templates/mention_list.html
@@ -3,10 +3,10 @@
{% block title %}{{ year }} &ndash; {% endblock %}
{% block body %}
- <h3>Choisissez votre mention</h3>
+ <h3>{{ year }} &ndash; Choisissez votre mention</h3>
<ul>
{% for timetable in timetables %}
- <li><a href="{% url "groups" year timetable.slug %}">{{ timetable.name }}</a></li>
+ <li><a href="{% url "groups" year.slug timetable.slug %}">{{ timetable }}</a></li>
{% empty %}
<p>Aucun emploi du temps à afficher</p>
{% endfor %}
diff --git a/urls.py b/urls.py
index 5731b44..4803b6a 100644
--- a/urls.py
+++ b/urls.py
@@ -19,8 +19,8 @@ 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<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<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"),
diff --git a/views.py b/views.py
index 141dde8..ea3a5be 100644
--- a/views.py
+++ b/views.py
@@ -21,24 +21,27 @@ 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 .models import Timetable, LastUpdate, Group, Subscription, Course, Year
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"))
+ years = Year.objects.order_by("name")
return render(request, "index.html", {"years": years})
-def mention_list(request, year):
+def mention_list(request, year_slug):
+ year = get_object_or_404(Year, slug=year_slug)
timetables = Timetable.objects.order_by("name").filter(year=year)
+
return render(request, "mention_list.html", {"year": year, "timetables": timetables})
-def group_list(request, year, timetable_slug):
+def group_list(request, year_slug, timetable_slug):
+ get_object_or_404(Year, slug=year_slug)
timetable = get_object_or_404(Timetable, slug=timetable_slug)
- groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name")
+ groups = Group.objects.get_relevant_groups().order_by("name")
year, week = get_current_week()
start, _ = get_week(year, week)
- groups_weeks = Course.objects.get_weeks(begin__gte=start).values("groups__timetable", "groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week")
+ groups_weeks = Course.objects.get_weeks(begin__gte=start).values("group__timetable", "groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week")
for group in groups:
for group_week in groups_weeks:
@@ -53,7 +56,7 @@ def group_list(request, year, timetable_slug):
if hasattr(group, "weeks"):
group.weeks.sort()
- return render(request, "group_list.html", {"timetables": timetables, "groups": groups})
+ return render(request, "group_list.html", {"timetable": timetable, "groups": groups})
def timetable(request, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None: