|
@ -5,7 +5,6 @@ jako první) adminu k Semináři. |
|
|
""" |
|
|
""" |
|
|
import locale |
|
|
import locale |
|
|
from django.contrib import admin |
|
|
from django.contrib import admin |
|
|
from django.contrib.admin import AdminSite |
|
|
|
|
|
from django.contrib.flatpages.models import FlatPage |
|
|
from django.contrib.flatpages.models import FlatPage |
|
|
|
|
|
|
|
|
# Note: we are renaming the original Admin and Form as we import them! |
|
|
# Note: we are renaming the original Admin and Form as we import them! |
|
@ -33,31 +32,28 @@ admin.site.register(FlatPage, FlatPageAdmin) |
|
|
|
|
|
|
|
|
locale.setlocale(locale.LC_COLLATE, 'cs_CZ.UTF-8') |
|
|
locale.setlocale(locale.LC_COLLATE, 'cs_CZ.UTF-8') |
|
|
|
|
|
|
|
|
# https://books.agiliq.com/projects/django-admin-cookbook/en/latest/set_ordering.html |
|
|
# Ref: https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#overriding-default-admin-site |
|
|
# FIXME zpraseno pomocí toho, že Python umí bez problému přepisovat funkce |
|
|
# Používá se z mamweb/apps.py |
|
|
def get_app_list(self, request, app_label=None): |
|
|
class MamwebAdminSite(admin.AdminSite): |
|
|
""" |
|
|
# Přeuspořádání modelů |
|
|
Return a sorted list of all the installed apps that have been |
|
|
# Ref: https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#django.contrib.admin.AdminSite.get_app_list |
|
|
registered in this site. |
|
|
def get_app_list(self, request, app_label=None): |
|
|
""" |
|
|
orig_app_list = super().get_app_list(request, app_label) |
|
|
|
|
|
apps_by_label = {app['label']: app for app in orig_app_list} |
|
|
app_dict = self._build_app_dict(request, label=app_label) |
|
|
|
|
|
aplikace_nahore = [ |
|
|
aplikace_nahore = [ |
|
|
'seminar', |
|
|
'seminar', |
|
|
'personalni', |
|
|
'personalni', |
|
|
'novinky', |
|
|
'novinky', |
|
|
'korektury', |
|
|
'korektury', |
|
|
'various', |
|
|
'various', |
|
|
'prednasky', |
|
|
'prednasky', |
|
|
'soustredeni', |
|
|
'soustredeni', |
|
|
] |
|
|
] |
|
|
app_list = [app_dict[label] for label in aplikace_nahore] + [app_dict[label] for label in app_dict if label not in aplikace_nahore] |
|
|
app_list = [apps_by_label[label] for label in aplikace_nahore] + [apps_by_label[label] for label in apps_by_label if label not in aplikace_nahore] |
|
|
|
|
|
|
|
|
|
|
|
# TreeNody na konec |
|
|
# Sort the models alphabetically within each app. |
|
|
for app in app_list: |
|
|
for app in app_list: |
|
|
app['models'].sort(key=lambda x: locale.strxfrm('žž' + x['name'].lower()) if (x['name'].endswith("(Node)")) else locale.strxfrm(x['name'].lower())) |
|
|
app['models'].sort(key=lambda x: locale.strxfrm('žž' + x['name'].lower()) if (x['name'].endswith("(Node)")) else locale.strxfrm(x['name'].lower())) |
|
|
|
|
|
|
|
|
return app_list |
|
|
return app_list |
|
|
|
|
|
|
|
|
|
|
|
AdminSite.get_app_list = get_app_list |
|
|
|
|
|