From c88e6d2aa962253b4b13b8ff1d61bad6d48b1cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?= <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de> Date: Wed, 17 Aug 2022 23:01:07 +0200 Subject: [PATCH] Improve view for AKs requiring special attention Make sure missing availabilities are only reported for AKs and not wishes Improve efficiency --- AKScheduling/views.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/AKScheduling/views.py b/AKScheduling/views.py index da7ff91a..0e7c1ac7 100644 --- a/AKScheduling/views.py +++ b/AKScheduling/views.py @@ -78,14 +78,17 @@ class SpecialAttentionAKsAdminView(AdminViewMixin, DetailView): aks_without_slots = [] for ak in aks: - if ak.wish and ak.akslot_set.count() > 0: - ak_wishes_with_slots.append(ak) - if not ak.wish and ak.akslot_set.count() == 0: - aks_without_slots.append(ak) if ak.notes != "": aks_with_comment.append(ak) - if ak.availabilities.count() == 0: - aks_without_availabilities.append(ak) + + if ak.wish: + if ak.akslot_set.count() > 0: + ak_wishes_with_slots.append(ak) + else: + if ak.akslot_set.count() == 0: + aks_without_slots.append(ak) + if ak.availabilities.count() == 0: + aks_without_availabilities.append(ak) context["aks_with_comment"] = aks_with_comment context["ak_wishes_with_slots"] = ak_wishes_with_slots -- GitLab