Skip to content
Snippets Groups Projects
Commit 23f9149d authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Show constraint violations as widget on status page

parent e8dc6ab1
No related branches found
No related tags found
No related merge requests found
...@@ -112,12 +112,6 @@ class EventAKsWidget(TemplateStatusWidget): ...@@ -112,12 +112,6 @@ class EventAKsWidget(TemplateStatusWidget):
] ]
if apps.is_installed("AKScheduling"): if apps.is_installed("AKScheduling"):
actions.extend([ actions.extend([
{
"text": format_html('{} <span class="badge bg-secondary">{}</span>',
_("Constraint Violations"),
context["event"].constraintviolation_set.count()),
"url": reverse_lazy("admin:constraint-violations", kwargs={"slug": context["event"].slug}),
},
{ {
"text": _("AKs requiring special attention"), "text": _("AKs requiring special attention"),
"url": reverse_lazy("admin:special-attention", kwargs={"slug": context["event"].slug}), "url": reverse_lazy("admin:special-attention", kwargs={"slug": context["event"].slug}),
......
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-16 16:30+0200\n" "POT-Creation-Date: 2024-04-25 00:24+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -61,52 +61,52 @@ msgid "Constraint Violations for" ...@@ -61,52 +61,52 @@ msgid "Constraint Violations for"
msgstr "" msgstr ""
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:44 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:44
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:100 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:105
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:236 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:240
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:371 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:375
msgid "No violations" msgid "No violations"
msgstr "Keine Verletzungen" msgstr "Keine Verletzungen"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:77 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:82
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:342 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:346
msgid "Violation(s)" msgid "Violation(s)"
msgstr "Verletzung(en)" msgstr "Verletzung(en)"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:80 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:85
msgid "Auto reload?" msgid "Auto reload?"
msgstr "Automatisch neu laden?" msgstr "Automatisch neu laden?"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:84 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:89
msgid "Reload now" msgid "Reload now"
msgstr "Jetzt neu laden" msgstr "Jetzt neu laden"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:90 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:95
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:225 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:228
msgid "Violation" msgid "Violation"
msgstr "Verletzung" msgstr "Verletzung"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:91 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:96
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:365 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:369
msgid "Problem" msgid "Problem"
msgstr "Problem" msgstr "Problem"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:92 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:97
msgid "Details" msgid "Details"
msgstr "Details" msgstr "Details"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:93 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:98
msgid "Since" msgid "Since"
msgstr "Seit" msgstr "Seit"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:106 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:111
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:238 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:256
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:328 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:332
#: AKScheduling/templates/admin/AKScheduling/special_attention.html:48 #: AKScheduling/templates/admin/AKScheduling/special_attention.html:48
#: AKScheduling/templates/admin/AKScheduling/unscheduled.html:34 #: AKScheduling/templates/admin/AKScheduling/unscheduled.html:34
msgid "Event Status" msgid "Event Status"
msgstr "Event-Status" msgstr "Event-Status"
#: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:108 #: AKScheduling/templates/admin/AKScheduling/constraint_violations.html:113
msgid "Scheduling" msgid "Scheduling"
msgstr "Scheduling" msgstr "Scheduling"
...@@ -116,39 +116,39 @@ msgstr "Abschicken" ...@@ -116,39 +116,39 @@ msgstr "Abschicken"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:11 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:11
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:21 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:21
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:325 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:329
msgid "Scheduling for" msgid "Scheduling for"
msgstr "Scheduling für" msgstr "Scheduling für"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:124 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:135
msgid "Name of new ak track" msgid "Name of new ak track"
msgstr "Name des neuen AK-Tracks" msgstr "Name des neuen AK-Tracks"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:140 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:151
msgid "Could not create ak track" msgid "Could not create ak track"
msgstr "Konnte neuen AK-Track nicht anlegen" msgstr "Konnte neuen AK-Track nicht anlegen"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:166 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:177
msgid "Could not update ak track name" msgid "Could not update ak track name"
msgstr "Konnte Namen des AK-Tracks nicht ändern" msgstr "Konnte Namen des AK-Tracks nicht ändern"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:172 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:183
msgid "Do you really want to delete this ak track?" msgid "Do you really want to delete this ak track?"
msgstr "Soll dieser AK-Track wirklich gelöscht werden?" msgstr "Soll dieser AK-Track wirklich gelöscht werden?"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:186 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:197
msgid "Could not delete ak track" msgid "Could not delete ak track"
msgstr "AK-Track konnte nicht gelöscht werden" msgstr "AK-Track konnte nicht gelöscht werden"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:198 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:216
msgid "Manage AK Tracks" msgid "Manage AK Tracks"
msgstr "AK-Tracks verwalten" msgstr "AK-Tracks verwalten"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:199 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:217
msgid "Add ak track" msgid "Add ak track"
msgstr "AK-Track hinzufügen" msgstr "AK-Track hinzufügen"
#: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:204 #: AKScheduling/templates/admin/AKScheduling/manage_tracks.html:222
msgid "AKs without track" msgid "AKs without track"
msgstr "AKs ohne Track" msgstr "AKs ohne Track"
...@@ -168,31 +168,31 @@ msgstr "Event (horizontal)" ...@@ -168,31 +168,31 @@ msgstr "Event (horizontal)"
msgid "Event (Vertical)" msgid "Event (Vertical)"
msgstr "Event (vertikal)" msgstr "Event (vertikal)"
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:267 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:271
msgid "Please choose AK" msgid "Please choose AK"
msgstr "Bitte AK auswählen" msgstr "Bitte AK auswählen"
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:287 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:291
msgid "Could not create slot" msgid "Could not create slot"
msgstr "Konnte Slot nicht anlegen" msgstr "Konnte Slot nicht anlegen"
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:303 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:307
msgid "Add slot" msgid "Add slot"
msgstr "Slot hinzufügen" msgstr "Slot hinzufügen"
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:311 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:315
msgid "Add" msgid "Add"
msgstr "Hinzufügen" msgstr "Hinzufügen"
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:312 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:316
msgid "Cancel" msgid "Cancel"
msgstr "Abbrechen" msgstr "Abbrechen"
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:339 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:343
msgid "Unscheduled" msgid "Unscheduled"
msgstr "Nicht gescheduled" msgstr "Nicht gescheduled"
#: AKScheduling/templates/admin/AKScheduling/scheduling.html:364 #: AKScheduling/templates/admin/AKScheduling/scheduling.html:368
msgid "Level" msgid "Level"
msgstr "Level" msgstr "Level"
...@@ -220,6 +220,24 @@ msgstr "" ...@@ -220,6 +220,24 @@ msgstr ""
msgid "AKs without slots" msgid "AKs without slots"
msgstr "AKs ohne Slots" msgstr "AKs ohne Slots"
#: AKScheduling/templates/admin/AKScheduling/status/cvs.html:6
msgid ""
"\n"
" <h3>Constraint Violation</h3>\n"
" "
msgid_plural ""
"\n"
" <h3>Constraint Violations</h3>\n"
" "
msgstr[0] ""
"\n"
" <h3>Constraintverletzung</h3>\n"
" "
msgstr[1] ""
"\n"
" <h3>Constraintverletzungen</h3>\n"
" "
#: AKScheduling/templates/admin/AKScheduling/unscheduled.html:7 #: AKScheduling/templates/admin/AKScheduling/unscheduled.html:7
msgid "Unscheduled AK Slots" msgid "Unscheduled AK Slots"
msgstr "Noch nicht geschedulte AK-Slots" msgstr "Noch nicht geschedulte AK-Slots"
...@@ -228,19 +246,19 @@ msgstr "Noch nicht geschedulte AK-Slots" ...@@ -228,19 +246,19 @@ msgstr "Noch nicht geschedulte AK-Slots"
msgid "Count" msgid "Count"
msgstr "Anzahl" msgstr "Anzahl"
#: AKScheduling/views.py:148 #: AKScheduling/views.py:150
msgid "Interest updated" msgid "Interest updated"
msgstr "Interesse aktualisiert" msgstr "Interesse aktualisiert"
#: AKScheduling/views.py:199 #: AKScheduling/views.py:201
msgid "Wishes" msgid "Wishes"
msgstr "Wünsche" msgstr "Wünsche"
#: AKScheduling/views.py:217 #: AKScheduling/views.py:219
msgid "Cleanup: Delete unscheduled slots for wishes" msgid "Cleanup: Delete unscheduled slots for wishes"
msgstr "Aufräumen: Noch nicht geplante Slots für Wünsche löschen" msgstr "Aufräumen: Noch nicht geplante Slots für Wünsche löschen"
#: AKScheduling/views.py:224 #: AKScheduling/views.py:226
#, python-brace-format #, python-brace-format
msgid "" msgid ""
"The following {count} unscheduled slots of wishes will be deleted:\n" "The following {count} unscheduled slots of wishes will be deleted:\n"
...@@ -252,15 +270,15 @@ msgstr "" ...@@ -252,15 +270,15 @@ msgstr ""
"\n" "\n"
" {slots}" " {slots}"
#: AKScheduling/views.py:231 #: AKScheduling/views.py:233
msgid "Unscheduled slots for wishes successfully deleted" msgid "Unscheduled slots for wishes successfully deleted"
msgstr "Noch nicht geplante Slots für Wünsche erfolgreich gelöscht" msgstr "Noch nicht geplante Slots für Wünsche erfolgreich gelöscht"
#: AKScheduling/views.py:245 #: AKScheduling/views.py:247
msgid "Create default availabilities for AKs" msgid "Create default availabilities for AKs"
msgstr "Standardverfügbarkeiten für AKs anlegen" msgstr "Standardverfügbarkeiten für AKs anlegen"
#: AKScheduling/views.py:252 #: AKScheduling/views.py:254
#, python-brace-format #, python-brace-format
msgid "" msgid ""
"The following {count} AKs don't have any availability information. Create " "The following {count} AKs don't have any availability information. Create "
...@@ -273,16 +291,20 @@ msgstr "" ...@@ -273,16 +291,20 @@ msgstr ""
"\n" "\n"
" {aks}" " {aks}"
#: AKScheduling/views.py:272 #: AKScheduling/views.py:274
#, python-brace-format #, python-brace-format
msgid "Could not create default availabilities for AK: {ak}" msgid "Could not create default availabilities for AK: {ak}"
msgstr "Konnte keine Verfügbarkeit anlegen für AK: {ak}" msgstr "Konnte keine Verfügbarkeit anlegen für AK: {ak}"
#: AKScheduling/views.py:277 #: AKScheduling/views.py:279
#, python-brace-format #, python-brace-format
msgid "Created default availabilities for {count} AKs" msgid "Created default availabilities for {count} AKs"
msgstr "Standardverfügbarkeiten für {count} AKs angelegt" msgstr "Standardverfügbarkeiten für {count} AKs angelegt"
#: AKScheduling/views.py:290
msgid "Constraint Violations"
msgstr "Constraintverletzungen"
#~ msgid "Bitte AK auswählen" #~ msgid "Bitte AK auswählen"
#~ msgstr "Please sel" #~ msgstr "Please sel"
......
{% load i18n %}
<div class="text-center">
<a href="{% url 'admin:constraint-violations' slug=event.slug %}">
<h1>{{ constraint_violations_count }}</h1>
{% blocktrans count constraint_violations_count=constraint_violations_count %}
<h3>Constraint Violation</h3>
{% plural %}
<h3>Constraint Violations</h3>
{% endblocktrans %}
</a>
</div>
...@@ -5,6 +5,8 @@ from django.urls import reverse_lazy ...@@ -5,6 +5,8 @@ from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views.generic import ListView, DetailView, UpdateView from django.views.generic import ListView, DetailView, UpdateView
from AKModel.metaviews import status_manager
from AKModel.metaviews.status import TemplateStatusWidget
from AKModel.models import AKSlot, AKTrack, Event, AK, AKCategory from AKModel.models import AKSlot, AKTrack, Event, AK, AKCategory
from AKModel.metaviews.admin import EventSlugMixin, FilterByEventSlugMixin, AdminViewMixin, IntermediateAdminView from AKModel.metaviews.admin import EventSlugMixin, FilterByEventSlugMixin, AdminViewMixin, IntermediateAdminView
from AKScheduling.forms import AKInterestForm, AKAddSlotForm from AKScheduling.forms import AKInterestForm, AKAddSlotForm
...@@ -277,3 +279,22 @@ class AvailabilityAutocreateView(EventSlugMixin, IntermediateAdminView): ...@@ -277,3 +279,22 @@ class AvailabilityAutocreateView(EventSlugMixin, IntermediateAdminView):
_("Created default availabilities for {count} AKs").format(count=success_count) _("Created default availabilities for {count} AKs").format(count=success_count)
) )
return super().form_valid(form) return super().form_valid(form)
@status_manager.register(name="scheduling_constraint_violations")
class CVWidget(TemplateStatusWidget):
"""
Status page widget: Constraint violations
"""
required_context_type = "event"
title = _("Constraint Violations")
template_name = "admin/AKScheduling/status/cvs.html"
def render_status(self, context: {}) -> str:
return "success" if context["constraint_violations_count"] == 0 else "warning"
def get_context_data(self, context) -> dict:
context = super().get_context_data(context)
context["constraint_violations_count"] = (context["event"].constraintviolation_set
.filter(manually_resolved=False).count())
return context
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment