Skip to content
Snippets Groups Projects
Commit 780f6b34 authored by Nadja Geisler's avatar Nadja Geisler :sunny:
Browse files

Merge branch 'meta-performance' into 'main'

Speedup of AKPlan

See merge request !115
parents 982dceec 18278269
No related branches found
No related tags found
1 merge request!115Speedup of AKPlan
Pipeline #81891 passed
......@@ -25,7 +25,8 @@ class EventSlugMixin:
def _load_event(self):
# Find event based on event slug
self.event = get_object_or_404(Event, slug=self.kwargs.get("event_slug", None))
if self.event is None:
self.event = get_object_or_404(Event, slug=self.kwargs.get("event_slug", None))
def get(self, request, *args, **kwargs):
self._load_event()
......
......@@ -81,7 +81,7 @@
{% block content %}
<div class="float-right">
<ul class="nav nav-pills">
{% if event.room_set.count > 0 %}
{% if rooms|length > 0 %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
aria-haspopup="true"
......@@ -94,13 +94,13 @@
</div>
</li>
{% endif %}
{% if event.aktrack_set.count > 0 %}
{% if tracks|length > 0 %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
aria-haspopup="true"
aria-expanded="false">{% trans "Tracks" %}</a>
<div class="dropdown-menu">
{% for t in event.aktrack_set.all %}
{% for t in tracks %}
<a class="dropdown-item"
href="{% url "plan:plan_track" event_slug=event.slug pk=t.pk %}">{{ t }}</a>
{% endfor %}
......
......@@ -16,7 +16,7 @@
{% block encode %}
[
{% for slot in room.akslot_set.all %}
{% for slot in slots %}
{% if slot.start %}
{'title': '{{ slot.ak }}',
'start': '{{ slot.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}',
......
......@@ -18,7 +18,7 @@ class PlanIndexView(FilterByEventSlugMixin, ListView):
def get_queryset(self):
# Ignore slots not scheduled yet
return super().get_queryset().filter(start__isnull=False)
return super().get_queryset().filter(start__isnull=False).select_related('ak', 'room', 'ak__category')
def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs)
......@@ -54,6 +54,8 @@ class PlanIndexView(FilterByEventSlugMixin, ListView):
if settings.PLAN_SHOW_HIERARCHY:
context["buildings"] = sorted(buildings)
context["tracks"] = self.event.aktrack_set.all()
return context
......@@ -94,6 +96,11 @@ class PlanRoomView(FilterByEventSlugMixin, DetailView):
model = Room
context_object_name = "room"
def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs)
context["slots"] = AKSlot.objects.filter(room=context['room']).select_related('ak', 'ak__category', 'ak__track')
return context
class PlanTrackView(FilterByEventSlugMixin, DetailView):
template_name = "AKPlan/plan_track.html"
......@@ -102,9 +109,5 @@ class PlanTrackView(FilterByEventSlugMixin, DetailView):
def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs)
context["slots"] = []
for ak in context["track"].ak_set.all():
context["slots"].extend(ak.akslot_set.all())
context["slots"] = AKSlot.objects.filter(event=self.event, ak__track=context['track']).select_related('ak', 'room', 'ak__category')
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