From fd8e3e3ecb4363f2084e2a1fa3fc6c3f0966ae12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?= <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de> Date: Fri, 14 May 2021 10:59:05 +0200 Subject: [PATCH] Improve dashboard recent change feed restriction --- AKDashboard/views.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/AKDashboard/views.py b/AKDashboard/views.py index 1f4f5527..9d9518d8 100644 --- a/AKDashboard/views.py +++ b/AKDashboard/views.py @@ -36,7 +36,7 @@ class DashboardEventView(DetailView): # Newest AKs if apps.is_installed("AKSubmission"): - submission_changes = AK.history.filter(event=context['event'])[:50] + submission_changes = AK.history.filter(event=context['event'])[:int(settings.DASHBOARD_RECENT_MAX)] for s in submission_changes: if s.history_type == '+': text = _('New AK: %(ak)s.') % {'ak': s.name} @@ -48,20 +48,25 @@ class DashboardEventView(DetailView): text = _('AK "%(ak)s" deleted.') % {'ak': s.name} icon = ('times', 'fas') - recent_changes.append({'icon': icon, 'text': text, 'link': reverse_lazy('submit:ak_detail', kwargs={'event_slug': context['event'].slug, 'pk': s.id}), 'timestamp': s.history_date}) + recent_changes.append({'icon': icon, 'text': text, 'link': reverse_lazy('submit:ak_detail', kwargs={ + 'event_slug': context['event'].slug, 'pk': s.id}), 'timestamp': s.history_date}) # Changes in plan if apps.is_installed("AKPlan"): if not context['event'].plan_hidden: - last_changed_slots = AKSlot.objects.filter(event=context['event']).order_by('-updated')[:50] + last_changed_slots = AKSlot.objects.filter(event=context['event']).order_by('-updated')[ + :int(settings.DASHBOARD_RECENT_MAX)] for changed_slot in last_changed_slots: - recent_changes.append({'icon': ('clock', 'far'), 'text': _('AK "%(ak)s" (re-)scheduled.') % {'ak': changed_slot.ak.name}, 'link': reverse_lazy('submit:ak_detail', kwargs={ - 'event_slug': context['event'].slug, 'pk': changed_slot.ak.id}), 'timestamp': changed_slot.updated}) + recent_changes.append({'icon': ('clock', 'far'), + 'text': _('AK "%(ak)s" (re-)scheduled.') % {'ak': changed_slot.ak.name}, + 'link': reverse_lazy('submit:ak_detail', kwargs={ + 'event_slug': context['event'].slug, 'pk': changed_slot.ak.id}), + 'timestamp': changed_slot.updated}) # Sort by change date... recent_changes.sort(key=lambda x: x['timestamp'], reverse=True) # ... and restrict to the latest 25 changes - context['recent_changes'] = recent_changes[:settings.DASHBOARD_RECENT_MAX] + context['recent_changes'] = recent_changes[:int(settings.DASHBOARD_RECENT_MAX)] else: context['recent_changes'] = [] -- GitLab