Skip to content
Snippets Groups Projects
Select Git revision
  • 53e284c1a5b534cc9390b36481c33eaa0be8abcf
  • main default protected
  • renovate/django-5.x
  • koma/feature/preference-polling-form
4 results

views.py

Blame
  • Benjamin Hättasch's avatar
    Benjamin Hättasch authored and Nadja Geisler committed
    This view can be used to sort aks into tracks using drag and drop. You can also create new ak tracks or delete them.
    
    Add js dependency for drag and drop of lists.
    Activate add, update, delete methids to AKTrack API and update method to AK API.
    Add and link (on status page) new admin view for management.
    Add tags list property to AK model.
    Introduce translations for AKScheduling app.
    Update translations.
    07288968
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    views.py 1.73 KiB
    from django.views.generic import ListView
    from django.utils.translation import gettext_lazy as _
    
    from AKModel.models import AKSlot, AKTrack
    from AKModel.views import AdminViewMixin, FilterByEventSlugMixin
    
    
    class UnscheduledSlotsAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
        template_name = "admin/AKScheduling/unscheduled.html"
        model = AKSlot
        context_object_name = "akslots"
    
        def get_context_data(self, **kwargs):
            context = super().get_context_data(**kwargs)
            context["title"] = f"{_('Unscheduled AK Slots')} for {context['event']}"
            return context
    
        def get_queryset(self):
            return super().get_queryset().filter(start=None)
    
    
    class SchedulingAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
        template_name = "admin/AKScheduling/scheduling.html"
        model = AKSlot
        context_object_name = "slots_unscheduled"
    
        def get_queryset(self):
            return super().get_queryset().filter(start__isnull=True)
    
        def get_context_data(self, *, object_list=None, **kwargs):
            context = super().get_context_data(object_list=object_list, **kwargs)
            context["title"] = f"{_('Scheduling')} for {context['event']}"
    
            context["event"] = self.event
            context["start"] = self.event.start
            context["end"] = self.event.end
    
            return context
    
    
    class TrackAdminView(AdminViewMixin, FilterByEventSlugMixin, ListView):
        template_name = "admin/AKScheduling/manage_tracks.html"
        model = AKTrack
        context_object_name = "tracks"
    
        def get_context_data(self, *, object_list=None, **kwargs):
            context = super().get_context_data(object_list=object_list, **kwargs)
            context["aks_without_track"] = self.event.ak_set.filter(track=None)
            return context