diff --git a/AKModel/views/status.py b/AKModel/views/status.py index 11173d972caf64c8b7a4e35c531dd9845f2eab3e..11b62083ab7683a5eead25f5ecba4117df5081b9 100644 --- a/AKModel/views/status.py +++ b/AKModel/views/status.py @@ -122,14 +122,15 @@ class EventAKsWidget(TemplateStatusWidget): "text": _("AKs requiring special attention"), "url": reverse_lazy("admin:special-attention", kwargs={"slug": context["event"].slug}), }, - { + ]) + if context["event"].ak_set.count() > 0: + actions.append({ "text": _("Enter Interest"), "url": reverse_lazy("admin:enter-interest", kwargs={"event_slug": context["event"].slug, "pk": context["event"].ak_set.all().first().pk} ), - }, - ]) + }) actions.extend([ { "text": _("Edit Default Slots"), diff --git a/AKPlan/templates/AKPlan/plan_wall.html b/AKPlan/templates/AKPlan/plan_wall.html index 98af938a5b86d4b1dfd2bce35d34ac9c804642f4..ee52854875b26c7b8e6b912a868c7f75a1a02034 100644 --- a/AKPlan/templates/AKPlan/plan_wall.html +++ b/AKPlan/templates/AKPlan/plan_wall.html @@ -51,6 +51,8 @@ start: '{{ start | timezone:event.timezone | date:"Y-m-d H:i:s" }}', end: '{{ end | timezone:event.timezone | date:"Y-m-d H:i:s"}}', }, + slotMinTime: '{{ earliest_start_hour }}:00:00', + slotMaxTime: '{{ latest_end_hour }}:00:00', eventDidMount: function(info) { $(info.el).tooltip({title: info.event.extendedProps.description}); }, diff --git a/AKPlan/views.py b/AKPlan/views.py index 87c513a646dba58661a1a64c50d10121c148ba3b..fdd4e7e80a6bfcb3a1dd5b70e9968c329e574434 100644 --- a/AKPlan/views.py +++ b/AKPlan/views.py @@ -1,3 +1,5 @@ +from datetime import timedelta + from django.conf import settings from django.shortcuts import redirect from django.urls import reverse_lazy @@ -81,11 +83,11 @@ class PlanScreenView(PlanIndexView): return redirect(reverse_lazy("plan:plan_overview", kwargs={"event_slug": self.event.slug})) return s - """ def get_queryset(self): - # Determine interesting range (some hours ago until some hours in the future as specified in the settings) now = datetime.now().astimezone(self.event.timezone) + # Wall during event: Adjust, show only parts in the future if self.event.start < now < self.event.end: + # Determine interesting range (some hours ago until some hours in the future as specified in the settings) self.start = now - timedelta(hours=settings.PLAN_WALL_HOURS_RETROSPECT) else: self.start = self.event.start @@ -93,13 +95,31 @@ class PlanScreenView(PlanIndexView): # Restrict AK slots to relevant ones # This will automatically filter all rooms not needed for the selected range in the orginal get_context method - return super().get_queryset().filter(start__gt=self.start) - """ + akslots = super().get_queryset().filter(start__gt=self.start) + + # Find the earliest hour AKs start and end (handle 00:00 as 24:00) + self.earliest_start_hour = 23 + self.latest_end_hour = 1 + for akslot in akslots.all(): + start_hour = akslot.start.astimezone(self.event.timezone).hour + if start_hour < self.earliest_start_hour: + # Use hour - 1 to improve visibility of date change + self.earliest_start_hour = max(start_hour - 1, 0) + end_hour = akslot.end.astimezone(self.event.timezone).hour + # Special case: AK starts before but ends after midnight -- show until midnight + if end_hour < start_hour: + self.latest_end_hour = 24 + elif end_hour > self.latest_end_hour: + # Always use hour + 1, since AK may end at :xy and not always at :00 + self.latest_end_hour = min(end_hour + 1, 24) + return akslots def get_context_data(self, *, object_list=None, **kwargs): context = super().get_context_data(object_list=object_list, **kwargs) - context["start"] = self.event.start + context["start"] = self.start context["end"] = self.event.end + context["earliest_start_hour"] = self.earliest_start_hour + context["latest_end_hour"] = self.latest_end_hour return context