From 14968e4b4234a2f36547ddeca6ce42fae8c0ef58 Mon Sep 17 00:00:00 2001
From: Griatch
Date: Thu, 20 May 2021 09:45:14 +0200
Subject: [PATCH] Update adminsite for better config
---
evennia/settings_default.py | 4 +--
evennia/web/admin/accounts.py | 1 +
evennia/web/admin/help.py | 1 +
evennia/web/admin/objects.py | 1 +
evennia/web/admin/scripts.py | 1 +
evennia/web/admin/tags.py | 1 +
evennia/web/admin/urls.py | 2 --
evennia/web/templates/admin/frontpage.html | 38 ++++++++++++++--------
evennia/web/utils/adminsite.py | 37 +++++++++++++++++++++
9 files changed, 69 insertions(+), 17 deletions(-)
create mode 100644 evennia/web/utils/adminsite.py
diff --git a/evennia/settings_default.py b/evennia/settings_default.py
index c9a71904dc..12250293fa 100644
--- a/evennia/settings_default.py
+++ b/evennia/settings_default.py
@@ -956,7 +956,6 @@ INSTALLED_APPS = [
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
- "django.contrib.admin",
"django.contrib.admindocs",
"django.contrib.flatpages",
"django.contrib.sites",
@@ -973,7 +972,8 @@ INSTALLED_APPS = [
"evennia.comms",
"evennia.help",
"evennia.scripts",
- "evennia.web"
+ "evennia.web",
+ "evennia.web.utils.adminsite.EvenniaAdminApp", # replaces django.contrib.admin
]
# The user profile extends the User object with more functionality;
# This should usually not be changed.
diff --git a/evennia/web/admin/accounts.py b/evennia/web/admin/accounts.py
index d655154178..6e949b030e 100644
--- a/evennia/web/admin/accounts.py
+++ b/evennia/web/admin/accounts.py
@@ -248,6 +248,7 @@ class AccountAdmin(BaseUserAdmin):
add_form = AccountCreationForm
inlines = [AccountTagInline, AccountAttributeInline]
readonly_fields = ["db_date_created", "serialized_string"]
+ view_on_site = False
fieldsets = (
(
None,
diff --git a/evennia/web/admin/help.py b/evennia/web/admin/help.py
index 272772c5fe..601253c972 100644
--- a/evennia/web/admin/help.py
+++ b/evennia/web/admin/help.py
@@ -42,6 +42,7 @@ class HelpEntryAdmin(admin.ModelAdmin):
save_as = True
save_on_top = True
list_select_related = True
+ view_on_site = False
form = HelpEntryForm
fieldsets = (
diff --git a/evennia/web/admin/objects.py b/evennia/web/admin/objects.py
index 722bce67dd..9c592c748b 100644
--- a/evennia/web/admin/objects.py
+++ b/evennia/web/admin/objects.py
@@ -146,6 +146,7 @@ class ObjectAdmin(admin.ModelAdmin):
save_as = True
save_on_top = True
list_select_related = True
+ view_on_site = False
list_filter = ("db_typeclass_path",)
# editing fields setup
diff --git a/evennia/web/admin/scripts.py b/evennia/web/admin/scripts.py
index f8dab474b6..126bc87060 100644
--- a/evennia/web/admin/scripts.py
+++ b/evennia/web/admin/scripts.py
@@ -99,6 +99,7 @@ class ScriptAdmin(admin.ModelAdmin):
save_as = True
save_on_top = True
list_select_related = True
+ view_on_site = False
raw_id_fields = ("db_obj",)
fieldsets = (
diff --git a/evennia/web/admin/tags.py b/evennia/web/admin/tags.py
index 42cab804c1..7528f9455f 100644
--- a/evennia/web/admin/tags.py
+++ b/evennia/web/admin/tags.py
@@ -218,6 +218,7 @@ class TagAdmin(admin.ModelAdmin):
fields = ("db_key", "db_category", "db_tagtype", "db_model", "db_data")
list_filter = ("db_tagtype", "db_category", "db_model")
form = TagForm
+ view_on_site = False
fieldsets = (
(
diff --git a/evennia/web/admin/urls.py b/evennia/web/admin/urls.py
index 1b630328f5..daf940b5f5 100644
--- a/evennia/web/admin/urls.py
+++ b/evennia/web/admin/urls.py
@@ -18,8 +18,6 @@ urlpatterns = [
url(r"/doc/", include("django.contrib.admindocs.urls")),
]
-admin.site.site_header = "Evennia web admin"
-
if settings.EVENNIA_ADMIN:
urlpatterns += [
diff --git a/evennia/web/templates/admin/frontpage.html b/evennia/web/templates/admin/frontpage.html
index 204408ba6a..b18b7b93cd 100644
--- a/evennia/web/templates/admin/frontpage.html
+++ b/evennia/web/templates/admin/frontpage.html
@@ -18,8 +18,9 @@
- Accounts can have several characters under them. A user's login and
- password information can be changed here.
+ Accounts represent an out-of-character player and stores
+ configurations and password. An account can control/puppet one or
+ more in-game Objects (usually Characters).
@@ -37,14 +38,24 @@
- Channels are used to redirect and organize player in-game communications.
+ Channels are used for mass communication, chat-room style. The
+ channel object holds subscriptions, options and access. The
+ communications themselves are logged to disk.
+
+
+
+
+ Messages represent a piece of database-base saved communication
+ between sender(s) and receiver(s). By default they are used by
+ page/tell but can be used as building blocks for custom in-game
+ communication systems.
- Add help database help-entries here. Note that command-auto-help and
- file-based help entries (added via FILEHELP_MODULES) are not visible
- here.
+ Database-based Help entries like these can also be added from
+ in-game. Note that command-auto-help and file-based help entries
+ (added via FILEHELP_MODULES) cannot be modified or viewed from here.
@@ -56,11 +67,12 @@
- These are constants saved by the running server. While maybe interesting for
- debugging, you should usually not modify these manually unless you
- really know what you are doing. For example, the
- BASE_*_TYPECLASS fields are stored in order to auto-update
- when their setting changes; they must not be changed manually here.
+ ServerConfigs store variables set by the running server. While possibly
+ interesting for debugging, you should usually not modify these
+ manually unless you really know what you are doing. For
+ example, the BASE_*_TYPECLASS fields are stored in order to
+ auto-update when their setting changes; they must not be
+ changed manually here.
@@ -78,9 +90,9 @@
-
+
Create, edit and publish new web pages without needing to know how to
- code. Select the domain specified by SITE_ID above.
+ code. Make sure to assign to a domain created above.
diff --git a/evennia/web/utils/adminsite.py b/evennia/web/utils/adminsite.py
new file mode 100644
index 0000000000..7b313cf2b6
--- /dev/null
+++ b/evennia/web/utils/adminsite.py
@@ -0,0 +1,37 @@
+"""
+Custom Evennia admin-site, for better customization of the admin-site
+as a whole.
+
+This must be located outside of the admin/ folder because it must be imported
+before any of the app-data (which in turn must be imported in the `__init__.py`
+of that folder for Django to find them).
+
+"""
+
+from django.contrib.admin import apps
+from django.contrib import admin
+
+
+class EvenniaAdminApp(apps.AdminConfig):
+ """
+ This is imported in INSTALLED_APPS instead of django.contrib.admin.
+
+ """
+ default_site = 'evennia.web.utils.adminsite.EvenniaAdminSite'
+
+
+class EvenniaAdminSite(admin.AdminSite):
+ """
+ The main admin site root (replacing the default from Django). When doing
+ admin.register in the admin/ folder, this is what is being registered to.
+
+ """
+ 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)
+ app_mapping = {app["app_label"]: app for app in app_list}
+ return [app_mapping.get(app_label) for app_label in self.app_order]