CMS-Mode implemented
This commit is contained in:
parent
915f9ed243
commit
17f051bbf5
@ -6,6 +6,7 @@ from django.conf import settings
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from pages import access
|
from pages import access
|
||||||
|
import pages.parameter
|
||||||
from .help import actionbar as actionbar_add_help
|
from .help import actionbar as actionbar_add_help
|
||||||
import mycreole
|
import mycreole
|
||||||
import pages
|
import pages
|
||||||
@ -22,6 +23,11 @@ INDEX_UID = 'index'
|
|||||||
NAVIGATION_ENTRY_UID = 'navigation-%s'
|
NAVIGATION_ENTRY_UID = 'navigation-%s'
|
||||||
|
|
||||||
|
|
||||||
|
def cms_mode_active(request):
|
||||||
|
user_logged_in = request.user.is_authenticated
|
||||||
|
return pages.parameter.get(pages.parameter.CMS_MODE) and not user_logged_in
|
||||||
|
|
||||||
|
|
||||||
def context_adaption(context, request, **kwargs):
|
def context_adaption(context, request, **kwargs):
|
||||||
caller_name = inspect.currentframe().f_back.f_code.co_name
|
caller_name = inspect.currentframe().f_back.f_code.co_name
|
||||||
try:
|
try:
|
||||||
@ -56,6 +62,7 @@ def navigationbar(context, request, caller_name, **kwargs):
|
|||||||
|
|
||||||
def menubar(context, request, caller_name, **kwargs):
|
def menubar(context, request, caller_name, **kwargs):
|
||||||
bar = context[context.MENUBAR]
|
bar = context[context.MENUBAR]
|
||||||
|
if not cms_mode_active(request):
|
||||||
menubar_users(bar, request)
|
menubar_users(bar, request)
|
||||||
add_help_menu(request, bar, "current_help_page" in kwargs)
|
add_help_menu(request, bar, "current_help_page" in kwargs)
|
||||||
add_index_menu(request, bar, kwargs.get("rel_path", ''))
|
add_index_menu(request, bar, kwargs.get("rel_path", ''))
|
||||||
@ -64,6 +71,7 @@ def menubar(context, request, caller_name, **kwargs):
|
|||||||
|
|
||||||
def actionbar(context, request, caller_name, **kwargs):
|
def actionbar(context, request, caller_name, **kwargs):
|
||||||
bar = context[context.ACTIONBAR]
|
bar = context[context.ACTIONBAR]
|
||||||
|
if not cms_mode_active(request):
|
||||||
if caller_name == 'page':
|
if caller_name == 'page':
|
||||||
if access.write_page(request, kwargs["rel_path"]):
|
if access.write_page(request, kwargs["rel_path"]):
|
||||||
add_edit_menu(request, bar, kwargs["rel_path"])
|
add_edit_menu(request, bar, kwargs["rel_path"])
|
||||||
|
36
pages/parameter.py
Normal file
36
pages/parameter.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import config
|
||||||
|
from django.conf import settings
|
||||||
|
import importlib
|
||||||
|
import os
|
||||||
|
|
||||||
|
CMS_MODE = "CMS_MODE"
|
||||||
|
|
||||||
|
|
||||||
|
def no_access(*args, **kwargs):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULTS = {
|
||||||
|
CMS_MODE: True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def __get_object_by_name__(object_name):
|
||||||
|
class_data = object_name.split(".")
|
||||||
|
module_path = ".".join(class_data[:-1])
|
||||||
|
class_str = class_data[-1]
|
||||||
|
#
|
||||||
|
module = importlib.import_module(module_path)
|
||||||
|
return getattr(module, class_str)
|
||||||
|
|
||||||
|
|
||||||
|
def get(key):
|
||||||
|
# take data from config, settings or defaults
|
||||||
|
try:
|
||||||
|
data = getattr(config, key)
|
||||||
|
except AttributeError:
|
||||||
|
try:
|
||||||
|
data = getattr(settings, key)
|
||||||
|
except AttributeError:
|
||||||
|
data = DEFAULTS.get(key)
|
||||||
|
return data
|
@ -20,6 +20,7 @@ from django.contrib import admin
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
import pages.views
|
import pages.views
|
||||||
|
import users
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
@ -37,6 +38,7 @@ urlpatterns = [
|
|||||||
path('mycreole/', include('mycreole.urls')),
|
path('mycreole/', include('mycreole.urls')),
|
||||||
# users
|
# users
|
||||||
path('users/', include('users.urls')),
|
path('users/', include('users.urls')),
|
||||||
|
path('login/', users.views.login, name='users-login-root'),
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user