From 6c208952f07c1e41c15e38d9e63deb06c958fc36 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Thu, 9 Jan 2020 22:32:20 +0100
Subject: [PATCH] Change overview view to quick launch variant and show only
 full groups (without parents)

---
 .../apps/chronos/templates/chronos/all.html   | 54 -------------------
 .../templates/chronos/quicklaunch.html        | 24 ++++-----
 aleksis/apps/chronos/views.py                 |  6 +--
 3 files changed, 15 insertions(+), 69 deletions(-)
 delete mode 100644 aleksis/apps/chronos/templates/chronos/all.html

diff --git a/aleksis/apps/chronos/templates/chronos/all.html b/aleksis/apps/chronos/templates/chronos/all.html
deleted file mode 100644
index fd9ce0e2..00000000
--- a/aleksis/apps/chronos/templates/chronos/all.html
+++ /dev/null
@@ -1,54 +0,0 @@
-{% extends 'core/base.html' %}
-
-{% load i18n %}
-
-{% block content %}
-    <h3>{% blocktrans %}All timetables{% endblocktrans %}</h3>
-    <div class="row">
-        <div class="col s12 m4">
-            <h4>{% blocktrans %}Teachers{% endblocktrans %}</h4>
-            <ul class="collection">
-                {% for teacher in teachers %}
-                    <li class="collection-item avatar">
-                        <i class="circle">{{ teacher. }}</i>
-                        <a href="{% url 'timetable_smart_plan' 'teacher' teacher.id %}">{{ teacher.first_name }}
-                            <strong>{{ teacher.name }}</strong></a>
-                    </li>
-                {% endfor %}
-            </ul>
-        </div>
-
-        <div class="col s12 m4">
-            <h4>{% blocktrans%}Groups{% endblocktrans %}</h4>
-            <ul class="collection">
-                {% for group in groups %}
-                    <li class="collection-item avatar">
-                        <i class="circle">{{ group.name }}</i>
-                        <a href="{% url 'timetable_smart_plan' 'group' group.id %}"><strong>{{ group.name }}</strong></a>
-                        <p>
-                            {{ group.text1|default:"" }} – {{ class.text2|default:"" }} <br>
-                            Raum: {{ class.room.name|default:"---" }}
-                        </p>
-                    </li>
-                {% endfor %}
-            </ul>
-        </div>
-
-        <div class="col s12 m4">
-            <h4>{% blocktrans %}Rooms{% endblocktrans %}</h4>
-            <ul class="collection">
-                {% for room in rooms %}
-                    <li class="collection-item avatar">
-                        <i class="circle">{{ room.shortcode }}</i>
-                        <a href="{% url 'timetable_smart_plan' 'room' room.id %}"><strong>{{ room.name }}</strong></a>
-                    </li>
-                {% endfor %}
-            </ul>
-        </div>
-
-
-    </div>
-
-{% endblock %}
-
-
diff --git a/aleksis/apps/chronos/templates/chronos/quicklaunch.html b/aleksis/apps/chronos/templates/chronos/quicklaunch.html
index 2d2215ce..228103b0 100644
--- a/aleksis/apps/chronos/templates/chronos/quicklaunch.html
+++ b/aleksis/apps/chronos/templates/chronos/quicklaunch.html
@@ -6,10 +6,10 @@
         <div class="col s12 m4">
             <h5>Lehrkräfte</h5>
             {% for teacher in teachers %}
-                <a class="waves-effect waves-light btn btn-timetable-quicklaunch"
-                   href="{% url 'timetable_smart_plan' 'teacher' teacher.id %}">
-                    {{ teacher.shortcode }}
-                </a><!-- Shortcode -->
+{#                <a class="waves-effect waves-light btn btn-timetable-quicklaunch"#}
+{#                   href="{% url 'timetable_smart_plan' 'teacher' teacher.id %}">#}
+                    {{ teacher.short_name }}
+{#                </a><!-- Shortcode -->#}
             {% endfor %}
         </div>
 
@@ -17,10 +17,10 @@
             <h5>Klassen</h5>
 
             {% for class in classes %}
-                <a class="waves-effect waves-light btn btn-timetable-quicklaunch"
-                   href="{% url 'timetable_smart_plan' 'class' class.id %}">
-                    {{ class.name }}
-                </a>
+{#                <a class="waves-effect waves-light btn btn-timetable-quicklaunch"#}
+{#                   href="{% url 'timetable_smart_plan' 'class' class.id %}">#}
+                    {{ class.short_name }}
+{#                </a>#}
             {% endfor %}
 
         </div>
@@ -28,10 +28,10 @@
         <div class="col s12 m4">
             <h5>Räume</h5>
             {% for room in rooms %}
-                <a class="waves-effect waves-light btn btn-timetable-quicklaunch"
-                   href="{% url 'timetable_smart_plan' 'room' room.id %}">
-                    {{ room.shortcode }}
-                </a>
+{#                <a class="waves-effect waves-light btn btn-timetable-quicklaunch"#}
+{#                   href="{% url 'timetable_smart_plan' 'room' room.id %}">#}
+                    {{ room.short_name }}
+{#                </a>#}
             {% endfor %}
         </div>
 
diff --git a/aleksis/apps/chronos/views.py b/aleksis/apps/chronos/views.py
index 70c68e58..5e8cd0e9 100644
--- a/aleksis/apps/chronos/views.py
+++ b/aleksis/apps/chronos/views.py
@@ -27,14 +27,14 @@ def all(request: HttpRequest) -> HttpResponse:
     context = {}
 
     teachers = Person.objects.annotate(lessons_count=Count("lessons_as_teacher")).filter(lessons_count__gt=0)
-    groups = Group.objects.annotate(lessons_count=Count("lessons")).filter(lessons_count__gt=0)
+    classes = Group.objects.annotate(lessons_count=Count("lessons")).filter(lessons_count__gt=0, parent_groups=None)
     rooms = Room.objects.annotate(lessons_count=Count("lesson_periods")).filter(lessons_count__gt=0)
 
     context['teachers'] = teachers
-    context['groups'] = groups
+    context['classes'] = classes
     context['rooms'] = rooms
 
-    return render(request, 'chronos/all.html', context)
+    return render(request, 'chronos/quicklaunch.html', context)
 
 
 @login_required
-- 
GitLab