1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- from django.urls.base import reverse
- from django.utils.translation import gettext as _
- from themes import empty_entry_parameters, color_icon_url
- from . import url_login, url_logout, url_register, url_profile
- from . import parameter
-
- ADMIN_ENTRY_UID = 'admin-main'
- LOGIN_ENTRY_UID = 'login-main'
- LOGOUT_ENTRY_UID = 'logout-main'
- PROFILE_ENTRY_UID = 'profile-main'
- REGISTER_ENTRY_UID = 'register-main'
-
-
- def context_adaption(context, request, title):
- context.set_additional_title(title)
- menubar(context[context.MENUBAR], request)
- context[context.NAVIGATIONBAR].append_entry(*empty_entry_parameters(request))
- actionbar(context[context.ACTIONBAR], request)
-
-
- def menubar(bar, request):
- if not request.user.is_authenticated:
- bar.append_entry(*login_entry_parameters(request))
- else:
- bar.append_entry(*logout_entry_parameters(request))
- if request.user.is_staff or request.user.is_superuser:
- bar.append_entry(*admin_entry_parameters(request))
- bar.append_entry(*profile_entry_parameters(request))
-
-
- def actionbar(bar, request):
- bar.append_entry(*login_entry_parameters(request, left=True))
- if parameter.get(parameter.USERS_SELF_REGISTRATION):
- bar.append_entry(*register_entry_parameters(request, left=True))
-
-
- def login_entry_parameters(request, left=False):
- return (
- LOGIN_ENTRY_UID, # uid
- _('Login'), # name
- color_icon_url(request, 'login.png'), # icon
- url_login(request), # url
- left, # left
- False # active
- )
-
-
- def register_entry_parameters(request, left=False):
- return (
- REGISTER_ENTRY_UID, # uid
- _('Register'), # name
- color_icon_url(request, 'register.png'), # icon
- url_register(request), # url
- left, # left
- False # active
- )
-
-
- def logout_entry_parameters(request):
- return (
- LOGOUT_ENTRY_UID, # uid
- _('Logout'), # name
- color_icon_url(request, 'logout.png'), # icon
- url_logout(request), # url
- False, # left
- False, # active
- )
-
-
- def admin_entry_parameters(request):
- return (
- ADMIN_ENTRY_UID, # uid
- _('Administration'), # name
- color_icon_url(request, 'admin.png'), # icon
- reverse('admin:index'), # url
- False, # left
- False # active
- )
-
-
- def profile_entry_parameters(request):
- return (
- PROFILE_ENTRY_UID, # uid
- request.user.username, # name
- color_icon_url(request, 'user.png'), # icon
- url_profile(request), # url
- False, # left
- False # active
- )
|