diff --git a/evennia/settings_default.py b/evennia/settings_default.py index 9ae396b329..e83b0e9fa3 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -288,11 +288,11 @@ DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' # default webclient options (without user changing it) WEBCLIENT_OPTIONS = { # Gags prompts in output window and puts them on the input bar - "gagprompt": True, + "gagprompt": True, # Shows help files in a new popup window instead of in-pane - "helppopup": False, + "helppopup": False, # Shows notifications of new messages as popup windows - "notification_popup": False, + "notification_popup": False, # Plays a sound for notifications of new messages "notification_sound": False } diff --git a/evennia/web/admin/__init__.py b/evennia/web/admin/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/evennia/accounts/admin.py b/evennia/web/admin/accounts.py similarity index 99% rename from evennia/accounts/admin.py rename to evennia/web/admin/accounts.py index a00169eb26..7161a0a9f7 100644 --- a/evennia/accounts/admin.py +++ b/evennia/web/admin/accounts.py @@ -213,12 +213,12 @@ class AccountAttributeInline(AttributeInline): related_field = "accountdb" +@admin.register(AccountDB) class AccountDBAdmin(BaseUserAdmin): """ This is the main creation screen for Users/accounts """ - list_display = ("username", "email", "is_staff", "is_superuser") form = AccountDBChangeForm add_form = AccountDBCreationForm @@ -362,4 +362,4 @@ class AccountDBAdmin(BaseUserAdmin): return HttpResponseRedirect(reverse("admin:accounts_accountdb_change", args=[obj.id])) -admin.site.register(AccountDB, AccountDBAdmin) +# admin.site.register(AccountDB, AccountDBAdmin) diff --git a/evennia/comms/admin.py b/evennia/web/admin/comms.py similarity index 100% rename from evennia/comms/admin.py rename to evennia/web/admin/comms.py diff --git a/evennia/web/website/views/admin.py b/evennia/web/admin/frontpage.py similarity index 86% rename from evennia/web/website/views/admin.py rename to evennia/web/admin/frontpage.py index b5986c3cb6..d34ace2d34 100644 --- a/evennia/web/website/views/admin.py +++ b/evennia/web/admin/frontpage.py @@ -13,12 +13,14 @@ from django.contrib.admin.views.decorators import staff_member_required def evennia_admin(request): """ Helpful Evennia-specific admin page. + """ - return render(request, "evennia_admin.html", {"accountdb": AccountDB}) + return render(request, "admin/frontpage.html", {"accountdb": AccountDB}) def admin_wrapper(request): """ Wrapper that allows us to properly use the base Django admin site, if needed. + """ return staff_member_required(site.index)(request) diff --git a/evennia/help/admin.py b/evennia/web/admin/help.py similarity index 100% rename from evennia/help/admin.py rename to evennia/web/admin/help.py diff --git a/evennia/objects/admin.py b/evennia/web/admin/objects.py similarity index 100% rename from evennia/objects/admin.py rename to evennia/web/admin/objects.py diff --git a/evennia/scripts/admin.py b/evennia/web/admin/scripts.py similarity index 100% rename from evennia/scripts/admin.py rename to evennia/web/admin/scripts.py diff --git a/evennia/typeclasses/admin.py b/evennia/web/admin/typeclasses.py similarity index 100% rename from evennia/typeclasses/admin.py rename to evennia/web/admin/typeclasses.py diff --git a/evennia/web/admin/urls.py b/evennia/web/admin/urls.py new file mode 100644 index 0000000000..c272db4037 --- /dev/null +++ b/evennia/web/admin/urls.py @@ -0,0 +1,30 @@ +""" +Rerouting admin frontpage to evennia version. + +These patterns are all under the admin/* namespace. + +""" +from django.conf import settings +from django.contrib import admin +from django.conf.urls import url, include +from . import frontpage + + +urlpatterns = [ + # Django original admin page. Make this URL is always available, whether + # we've chosen to use Evennia's custom admin or not. + url(r"/django/", frontpage.admin_wrapper, name="django_admin"), + # Admin docs + url(r"/doc/", include("django.contrib.admindocs.urls")), +] + +if settings.EVENNIA_ADMIN: + urlpatterns += [ + # Our override for the admin. + url("^/$", frontpage.evennia_admin, name="evennia_admin"), + # Makes sure that other admin pages get loaded. + url(r"^/", admin.site.urls), + ] +else: + # Just include the normal Django admin. + urlpatterns += [url(r"^/", admin.site.urls)] diff --git a/evennia/web/templates/website/evennia_admin.html b/evennia/web/templates/admin/frontpage.html similarity index 99% rename from evennia/web/templates/website/evennia_admin.html rename to evennia/web/templates/admin/frontpage.html index 4d52266ee9..95d985f4b0 100644 --- a/evennia/web/templates/website/evennia_admin.html +++ b/evennia/web/templates/admin/frontpage.html @@ -16,7 +16,6 @@

Game entities

-

Accounts

Accounts can have several characters under them. A user's login and diff --git a/evennia/web/urls.py b/evennia/web/urls.py index b3c803385d..30617b6066 100644 --- a/evennia/web/urls.py +++ b/evennia/web/urls.py @@ -30,6 +30,8 @@ urlpatterns = [ path("", include("evennia.web.website.urls")), # webclient path("webclient/", include("evennia.web.webclient.urls")), + # admin + path("admin", include("evennia.web.admin.urls")), # favicon path("favicon.ico", RedirectView.as_view(url="/media/images/favicon.ico", permanent=False)), ] diff --git a/evennia/web/utils/general_context.py b/evennia/web/utils/general_context.py index b1296c06fe..8c5ed61cfc 100644 --- a/evennia/web/utils/general_context.py +++ b/evennia/web/utils/general_context.py @@ -1,15 +1,26 @@ -# -# This file defines global variables that will always be -# available in a view context without having to repeatedly -# include it. For this to work, this file is included in -# the settings file, in the TEMPLATE_CONTEXT_PROCESSORS -# tuple. -# +""" +This file defines global variables that will always be available in a view +context without having to repeatedly include it. + +For this to work, this file is included in the settings file, in the +TEMPLATE_CONTEXT_PROCESSORS tuple. + +""" + import os from django.conf import settings from evennia.utils.utils import get_evennia_version +# Setup lists of the most relevant apps so +# the adminsite becomes more readable. + +ACCOUNT_RELATED = ["Accounts"] +GAME_ENTITIES = ["Objects", "Scripts", "Comms", "Help"] +GAME_SETUP = ["Permissions", "Config"] +CONNECTIONS = ["Irc"] +WEBSITE = ["Flatpages", "News", "Sites"] + # Determine the site name and server version def set_game_name_and_slogan(): """ @@ -18,6 +29,7 @@ def set_game_name_and_slogan(): Notes: This function is used for unit testing the values of the globals. + """ global GAME_NAME, GAME_SLOGAN, SERVER_VERSION try: @@ -31,18 +43,6 @@ def set_game_name_and_slogan(): GAME_SLOGAN = SERVER_VERSION -set_game_name_and_slogan() - -# Setup lists of the most relevant apps so -# the adminsite becomes more readable. - -ACCOUNT_RELATED = ["Accounts"] -GAME_ENTITIES = ["Objects", "Scripts", "Comms", "Help"] -GAME_SETUP = ["Permissions", "Config"] -CONNECTIONS = ["Irc"] -WEBSITE = ["Flatpages", "News", "Sites"] - - def set_webclient_settings(): """ As with set_game_name_and_slogan above, this sets global variables pertaining @@ -50,6 +50,7 @@ def set_webclient_settings(): Notes: Used for unit testing. + """ global WEBCLIENT_ENABLED, WEBSOCKET_CLIENT_ENABLED, WEBSOCKET_PORT, WEBSOCKET_URL WEBCLIENT_ENABLED = settings.WEBCLIENT_ENABLED @@ -64,13 +65,15 @@ def set_webclient_settings(): WEBSOCKET_URL = settings.WEBSOCKET_CLIENT_URL +set_game_name_and_slogan() set_webclient_settings() # The main context processor function def general_context(request): """ - Returns common Evennia-related context stuff, which - is automatically added to context of all views. + Returns common Evennia-related context stuff, which is automatically added + to context of all views. + """ account = None if request.user.is_authenticated: diff --git a/evennia/web/website/urls.py b/evennia/web/website/urls.py index c2e8b7c8ff..dd00e43cef 100644 --- a/evennia/web/website/urls.py +++ b/evennia/web/website/urls.py @@ -7,7 +7,7 @@ from django.contrib import admin from django.conf.urls import url, include from django import views as django_views from .views import (index, errors, accounts, help as helpviews, channels, - characters, admin as adminviews) + characters) urlpatterns = [ # website front page @@ -52,26 +52,8 @@ urlpatterns = [ url(r"^characters/delete/(?P[\w\d\-]+)/(?P[0-9]+)/$", characters.CharacterDeleteView.as_view(), name="character-delete"), - - # Django original admin page. Make this URL is always available, whether - # we've chosen to use Evennia's custom admin or not. - - url(r"django_admin/", adminviews.admin_wrapper, name="django_admin"), - - # Admin docs - url(r"^admin/doc/", include("django.contrib.admindocs.urls")), ] -if settings.EVENNIA_ADMIN: - urlpatterns += [ - # Our override for the admin. - url("^admin/$", adminviews.evennia_admin, name="evennia_admin"), - # Makes sure that other admin pages get loaded. - url(r"^admin/", admin.site.urls), - ] -else: - # Just include the normal Django admin. - urlpatterns += [url(r"^admin/", admin.site.urls)] # This sets up the server if the user want to run the Django # test server (this should normally not be needed). diff --git a/evennia/web/website/views/index.py b/evennia/web/website/views/index.py index 7c5c5f1604..77b00ce2ab 100644 --- a/evennia/web/website/views/index.py +++ b/evennia/web/website/views/index.py @@ -22,7 +22,7 @@ def _gamestats(): fpage_account_limit = 4 # A QuerySet of the most recently connected accounts. - recent_users = AccountDB.objects.get_recently_connected_accounts()[:fpage_account_limit] + recent_users = AccountDB.objects.get_recently_connected_accounts() nplyrs_conn_recent = len(recent_users) or "none" nplyrs = AccountDB.objects.num_total_accounts() or "none" nplyrs_reg_recent = len(AccountDB.objects.get_recently_created_accounts()) or "none" @@ -44,7 +44,7 @@ def _gamestats(): pagevars = { "page_title": "Front Page", - "accounts_connected_recent": recent_users, + "accounts_connected_recent": recent_users[:fpage_account_limit], "num_accounts_connected": nsess or "no one", "num_accounts_registered": nplyrs or "no", "num_accounts_connected_recent": nplyrs_conn_recent or "no",