Browse Source

Merge branch 'cz_sort' into develop

export_seznamu_prednasek
Jonas Havelka 3 years ago
parent
commit
50910817cb
  1. 23
      mamweb/admin.py

23
mamweb/admin.py

@ -1,4 +1,6 @@
import locale
from django.contrib import admin
from django.contrib.admin import AdminSite
from django.contrib.flatpages.models import FlatPage
# Note: we are renaming the original Admin and Form as we import them!
@ -24,3 +26,24 @@ class FlatPageAdmin(FlatPageAdminOld):
admin.site.unregister(FlatPage)
admin.site.register(FlatPage, FlatPageAdmin)
locale.setlocale(locale.LC_COLLATE, 'cs_CZ.UTF-8')
# https://books.agiliq.com/projects/django-admin-cookbook/en/latest/set_ordering.html
# FIXME zpraseno pomocí toho, že Python umí bez problému přepisovat funkce
def get_app_list(self, request):
"""
Return a sorted list of all the installed apps that have been
registered in this site.
"""
app_dict = self._build_app_dict(request)
# Sort the apps alphabetically.
app_list = sorted(app_dict.values(), key=lambda x: locale.strxfrm('!') if (x['name'] == "Seminar") else locale.strxfrm(x['name'].lower()))
# Sort the models alphabetically within each app.
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()))
return app_list
AdminSite.get_app_list = get_app_list

Loading…
Cancel
Save