Skip to content
Snippets Groups Projects
  • Benjamin Hättasch's avatar
    2b7f9314
    Improve AKModel · 2b7f9314
    Benjamin Hättasch authored
    Add or complete docstrings
    Remove code smells
    Disable irrelevant warnings
    Update translations to changed line numbers and line breaks
    Move duplicated code for event field pre-population and event timezone adaption to mixins
    2b7f9314
    History
    Improve AKModel
    Benjamin Hättasch authored
    Add or complete docstrings
    Remove code smells
    Disable irrelevant warnings
    Update translations to changed line numbers and line breaks
    Move duplicated code for event field pre-population and event timezone adaption to mixins
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
site.py 1.06 KiB
from django.contrib.admin import AdminSite
from django.utils.translation import gettext_lazy as _
# from django.urls import path

from AKModel.models import Event


class AKAdminSite(AdminSite):
    """
    Custom admin interface definition (extend the admin functionality of Django)
    """
    index_template = "admin/ak_index.html"
    site_header = f"AKPlanning - {_('Administration')}"
    index_title = _('Administration')

    def get_urls(self):
        """
        Get URLs -- add further views that are not related to a certain model here if needed
        """
        urls = super().get_urls()
        urls += [
            # path('...', self.admin_view(...)),
        ]
        return urls

    def index(self, request, extra_context=None):
        # Override index page rendering to provide extra context (the list of active events)
        # to be used in the adapted template
        if extra_context is None:
            extra_context = {}
        extra_context["active_events"] = Event.objects.filter(active=True)
        return super().index(request, extra_context)