diff options
| -rw-r--r-- | templates/index.html | 65 | ||||
| -rw-r--r-- | templates/timetable.html | 28 | ||||
| -rw-r--r-- | views.py | 9 | 
3 files changed, 70 insertions, 32 deletions
| diff --git a/templates/index.html b/templates/index.html index 7b43411..2305acf 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,22 +1,57 @@ -{% load dt_week %} -<!DOCTYPE html> +{% load dt_week %}<!DOCTYPE html>  <html lang="fr">    <head>      <meta charset="utf-8" /> -    <title>celcatsanitizer</title> +    <meta name="viewport" content="width=device-width, initial-scale=1" /> +    <title>{% block title %}{% endblock %}celcatsanitizer</title> +    <style> +body { +    max-width: 60em; +    margin: 1em auto; +    padding: 0 .62em; +    font: 1.2em/1.62em sans-serif; +} + +h1, h2, h3 { +    line-height: 1.2em; +} + +.content { +    max-width: 50em; +    margin: 0 auto; +} + +@media print { +    body, .content { +        max-width: none; +    } +} + +li { +    line-height: 1.2em; +    margin-bottom: 5px; +} + +li.course { +     margin-bottom: 20px; +} +    </style>    </head>    <body> -    <h1>celcatsanitizer</h1> -    {% for timetable in timetables %} -    <h3>{{ timetable.name }}</h3> -    <ul> -      {% for group in groups %} -      {% if group.timetable.id == timetable.id %} -      <li>{{ group.name }} – {% for week in group.weeks %}<a href="{% url "timetable" timetable.slug week.year week|dt_week group.slug %}">{{ week|dt_prettyprint }}</a> {% endfor %}</li> -      {#<li><a href="{% url "timetable" timetable.slug 2017 52 group.slug %}">{{ group.name }}</a></li>#} -      {% endif %} -      {% endfor %} -    </ul> -    {% endfor %} +    <header> +      <h1>celcatsanitizer</h1> +    </header> +    <div class="content">{% block body %}{% for timetable in timetables %} +      <section id="{{ timetable.slug }}"> +        <h3>{{ timetable.name }}</h3> +        <ul>{% for group in groups %}{% if group.timetable.id == timetable.id %} +          <li>{{ group.name }} – {% for week in group.weeks %}<a href="{% url "timetable" timetable.slug week.year week|dt_week group.slug %}">{{ week|dt_prettyprint }}</a> {% endfor %}</li>{% endif %}{% endfor %} +        </ul> +      </section>{% endfor %}{% endblock %} +    </div> +    <footer> +      <p>(c) 2017 – Alban Gruin<br /> +      Design inspiré par <a href="https://bestmotherfucking.website/">https://bestmotherfucking.website/</a></p> +    </footer>    </body>  </html> diff --git a/templates/timetable.html b/templates/timetable.html index 23de166..f4be3a3 100644 --- a/templates/timetable.html +++ b/templates/timetable.html @@ -1,16 +1,12 @@ -<!DOCTYPE html> -<html lang="fr"> -  <head> -    <meta charset="utf-8" /> -    <title>{{ timetable.name }} – {{ group.name }} – celcatsanitizer</title> -  </head> -  <body> -    <h1>celcatsanitizer</h1> -    <h3>{{ timetable.name }} – {{ group.name }}</h3> -    <ul> -      {% for course in courses %} -      <li>{{ course.name }}</li> -      {% endfor %} -    </ul> -  </body> -</html> +{% extends "index.html" %} + +{% block title %}{{ timetable.name }} – {{ group.name }} – Semaine {{ week }} – {% endblock %} + +{% block body %} +      <h2>{{ timetable.name }} – {{ group.name }} – Semaine {{ week }}</h2>{% for day in courses %} +      <section> +        <h3>{{ day.0.begin|date:"l j F o" }} – de {{ day.0.begin|date:"H:i" }} à {% with day|last as last %}{{ last.end|date:"H:i" }}{% endwith %}</h3> +        <ul>{% for course in day %} +          <li class="course"><b>{{ course.name }}</b>, de {{ course.begin|date:"H:i" }} à {{ course.end|date:"H:i" }}{% if course.rooms.all|length > 0 %}<br /><em>Salle{% if course.rooms.all|length > 1 %}s{% endif %} {% for room in course.rooms.all %}{{ room }} {% endfor %}</em>{% endif %}</li>{% endfor %} +        </ul> +      </section>{% endfor %}{% endblock %} @@ -30,4 +30,11 @@ def timetable(request, timetable_slug, year, week, group_slug):      group = get_object_or_404(Group, slug=group_slug, timetable=timetable)      courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) -    return render_to_response("timetable.html", {"timetable": timetable, "group": group, "courses": courses}) +    grouped_courses = [] +    for i, course in enumerate(courses): +        if i == 0 or courses[i - 1].begin.day != course.begin.day: +            grouped_courses.append([course]) +        else: +            grouped_courses[-1].append(course) + +    return render_to_response("timetable.html", {"timetable": timetable, "group": group, "courses": grouped_courses, "week": week}) | 
