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

Improve dashboard recent change feed restriction

parent c52ebde0
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ class DashboardEventView(DetailView): ...@@ -36,7 +36,7 @@ class DashboardEventView(DetailView):
# Newest AKs # Newest AKs
if apps.is_installed("AKSubmission"): 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: for s in submission_changes:
if s.history_type == '+': if s.history_type == '+':
text = _('New AK: %(ak)s.') % {'ak': s.name} text = _('New AK: %(ak)s.') % {'ak': s.name}
...@@ -48,20 +48,25 @@ class DashboardEventView(DetailView): ...@@ -48,20 +48,25 @@ class DashboardEventView(DetailView):
text = _('AK "%(ak)s" deleted.') % {'ak': s.name} text = _('AK "%(ak)s" deleted.') % {'ak': s.name}
icon = ('times', 'fas') 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 # Changes in plan
if apps.is_installed("AKPlan"): if apps.is_installed("AKPlan"):
if not context['event'].plan_hidden: 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: 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={ recent_changes.append({'icon': ('clock', 'far'),
'event_slug': context['event'].slug, 'pk': changed_slot.ak.id}), 'timestamp': changed_slot.updated}) '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... # Sort by change date...
recent_changes.sort(key=lambda x: x['timestamp'], reverse=True) recent_changes.sort(key=lambda x: x['timestamp'], reverse=True)
# ... and restrict to the latest 25 changes # ... 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: else:
context['recent_changes'] = [] context['recent_changes'] = []
......
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