Skip to content
Snippets Groups Projects
Select Git revision
  • 84584d74b2f151ac6047de4cb0d4eebc0882bad2
  • renovate/django-split-settings-1.x
  • renovate/djangorestframework-3.x
  • main
  • 520-improve-trackmanager
  • 520-fix-scheduling
  • 520-akowner
  • 520-status
  • 520-message-resolved
  • 520-improve-scheduling-2
  • renovate/django-bootstrap5-24.x
  • 520-improve-submission
  • 520-improve-scheduling
  • 520-improve-wall
  • 520-fix-event-wizard-datepicker
  • 520-upgrades
  • renovate/tzdata-2023.x
  • renovate/django-5.x
  • renovate/fontawesomefree-6.x
  • renovate/sphinx-rtd-theme-2.x
  • renovate/sphinxcontrib-apidoc-0.x
21 results

forms.py

Blame
  • Forked from KIF / AKPlanning
    Source project has a limited visibility.
    • Benjamin Hättasch's avatar
      f28e9606
      Implement admin actions for constraint violations · f28e9606
      Benjamin Hättasch authored and Nadja Geisler's avatar Nadja Geisler committed
      Add three admin actions to mark CVs as resolved, or set the level to 'warning' or 'violation' -- each including a preview/confirmation step
      Introduce a generic view inheriting from the generic admin intermediate view to handle confirmations for admin actions (performing on multiple, freely selected items)
      This implements #154
      f28e9606
      History
      Implement admin actions for constraint violations
      Benjamin Hättasch authored and Nadja Geisler's avatar Nadja Geisler committed
      Add three admin actions to mark CVs as resolved, or set the level to 'warning' or 'violation' -- each including a preview/confirmation step
      Introduce a generic view inheriting from the generic admin intermediate view to handle confirmations for admin actions (performing on multiple, freely selected items)
      This implements #154
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    views.py 2.93 KiB
    from django.apps import apps
    from django.urls import reverse_lazy
    from django.utils.decorators import method_decorator
    from django.views.decorators.csrf import ensure_csrf_cookie
    from django.views.generic import TemplateView, DetailView
    from django.utils.translation import gettext_lazy as _
    
    from AKModel.models import Event, AK, AKSlot
    from AKPlanning import settings
    
    
    class DashboardView(TemplateView):
        template_name = 'AKDashboard/dashboard.html'
    
        @method_decorator(ensure_csrf_cookie)
        def dispatch(self, *args, **kwargs):
            return super().dispatch(*args, **kwargs)
    
        def get_context_data(self, **kwargs):
            context = super().get_context_data(**kwargs)
            context['events'] = Event.objects.filter(public=True)
            return context
    
    
    class DashboardEventView(DetailView):
        template_name = 'AKDashboard/dashboard_event.html'
        context_object_name = 'event'
        model = Event
    
        def get_context_data(self, **kwargs):
            context = super().get_context_data(**kwargs)
    
            # Show feed of recent changes (if activated)
            if settings.DASHBOARD_SHOW_RECENT:
                recent_changes = []
    
                # Newest AKs
                if apps.is_installed("AKSubmission"):
                    submission_changes = AK.history.filter(event=context['event'])[:50]
                    for s in submission_changes:
                        if s.history_type == '+':
                            text = _('New AK: %(ak)s.') % {'ak': s.name}
                            icon = ('plus-square', 'far')
                        elif s.history_type == '~':
                            text = _('AK "%(ak)s" edited.') % {'ak': s.name}
                            icon = ('pen-square', 'fas')
                        else:
                            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})
    
                # 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]
                        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})
    
                # 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]
            else:
                context['recent_changes'] = []
    
            return context