mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 17:56:32 +01:00
Merge pull request #3301 from volundmush/fix_web_admin
Configurable Django Admin
This commit is contained in:
commit
f3a49bb764
2 changed files with 26 additions and 16 deletions
|
|
@ -1033,6 +1033,24 @@ MIDDLEWARE = [
|
|||
"evennia.web.utils.middleware.SharedLoginMiddleware",
|
||||
]
|
||||
|
||||
# A list of Django apps (see INSTALLED_APPS) that will be listed first (if present)
|
||||
# in the Django web Admin page.
|
||||
DJANGO_ADMIN_APP_ORDER = [
|
||||
"accounts",
|
||||
"objects",
|
||||
"scripts",
|
||||
"comms",
|
||||
"help",
|
||||
"typeclasses",
|
||||
"server",
|
||||
"sites",
|
||||
"flatpages",
|
||||
"auth",
|
||||
]
|
||||
|
||||
# The following apps will be excluded from the Django web Admin page.
|
||||
DJANGO_ADMIN_APP_EXCLUDE = list()
|
||||
|
||||
######################################################################
|
||||
# Evennia components
|
||||
######################################################################
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ of that folder for Django to find them).
|
|||
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin import apps
|
||||
|
||||
|
|
@ -30,20 +31,11 @@ class EvenniaAdminSite(admin.AdminSite):
|
|||
|
||||
site_header = "Evennia web admin"
|
||||
|
||||
app_order = [
|
||||
"accounts",
|
||||
"objects",
|
||||
"scripts",
|
||||
"comms",
|
||||
"help",
|
||||
"typeclasses",
|
||||
"server",
|
||||
"sites",
|
||||
"flatpages",
|
||||
"auth",
|
||||
]
|
||||
|
||||
def get_app_list(self, request):
|
||||
app_list = super().get_app_list(request)
|
||||
def get_app_list(self, request, app_label=None):
|
||||
app_list = super().get_app_list(request, app_label=app_label)
|
||||
app_mapping = {app["app_label"]: app for app in app_list}
|
||||
return [app_mapping.get(app_label) for app_label in self.app_order]
|
||||
out = [app_mapping.pop(app_label) for app_label in settings.DJANGO_ADMIN_APP_ORDER if app_label in app_mapping]
|
||||
for app in settings.DJANGO_ADMIN_APP_EXCLUDE:
|
||||
app_mapping.pop(app, None)
|
||||
out += app_mapping.values()
|
||||
return out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue