diff --git a/access_controller/urls.py b/access_controller/urls.py
index e174717..ec94163 100644
--- a/access_controller/urls.py
+++ b/access_controller/urls.py
@@ -19,7 +19,7 @@ from django.urls import path, include
from main.views import main_page, profile_page, CustomRegistrationView, CustomLoginView
from main.views import work_page, work_hand_over, work_become_engineer, \
- AdminPageView, statistic_page
+ AdminPageView, statistic_page, testing_page
from main.urls import router
@@ -37,7 +37,7 @@ urlpatterns = [
path('accounts/', include('django_registration.backends.activation.urls')),
path('accounts/login/', include('django.contrib.auth.urls')),
path('control/', AdminPageView.as_view(), name='control'),
- path('statistic/', statistic_page, name='statistic')
+ path('statistic/', statistic_page, name='statistic'),
]
urlpatterns += [
diff --git a/main/templates/base/menu.html b/main/templates/base/menu.html
index 92aaec1..cdf13bd 100644
--- a/main/templates/base/menu.html
+++ b/main/templates/base/menu.html
@@ -10,11 +10,23 @@
{% if request.user.is_authenticated %}
diff --git a/main/views.py b/main/views.py
index 18d7e52..9951dcf 100644
--- a/main/views.py
+++ b/main/views.py
@@ -121,6 +121,15 @@ class CustomRegistrationView(RegistrationView):
return reverse_lazy('django_registration_disallowed')
+def setup_context(profile_lit: bool = False, control_lit: bool = False, work_lit: bool = False):
+ context = {
+ 'profile_lit': profile_lit,
+ 'control_lit': control_lit,
+ 'work_lit': work_lit,
+ }
+ return context
+
+
@login_required()
def profile_page(request: WSGIRequest) -> HttpResponse:
"""
@@ -131,11 +140,12 @@ def profile_page(request: WSGIRequest) -> HttpResponse:
"""
user_profile: UserProfile = request.user.userprofile
update_profile(user_profile)
- context = {
+ context = setup_context(profile_lit=True)
+ context.update({
'profile': user_profile,
'pagename': 'Страница профиля',
'ZENDESK_ROLES': ZENDESK_ROLES,
- }
+ })
return render(request, 'pages/profile.html', context)
@@ -171,13 +181,14 @@ def work_page(request: WSGIRequest, id: int) -> HttpResponse:
elif user.custom_role_id == ZENDESK_ROLES['light_agent']:
light_agents.append(user)
- context = {
+ context = setup_context(work_lit=True)
+ context.update({
'engineers': engineers,
'agents': light_agents,
'messages': messages.get_messages(request),
'licences_remaining': max(0, ZENDESK_MAX_AGENTS - len(engineers)),
'pagename': 'Управление правами'
- }
+ })
return render(request, 'pages/work.html', context)
return redirect("login")
@@ -284,13 +295,17 @@ class AdminPageView(LoginRequiredMixin, PermissionRequiredMixin,SuccessMessageMi
"""
Функция формирования контента страницы администратора (с проверкой прав доступа)
"""
- context = super().get_context_data(**kwargs)
+ context = setup_context(control_lit=True)
+ context.update(super().get_context_data(**kwargs))
users = get_list_or_404(
UserProfile, role='agent')
- context['users'] = users
- context['ZENDESK_ROLES'] = ZENDESK_ROLES
- context['engineers'], context['light_agents'] = count_users(get_users_list())
- context['licences_remaining'] = max(0, ZENDESK_MAX_AGENTS - context['engineers'])
+ context.update({
+ 'users': users,
+ 'ZENDESK_ROLES': ZENDESK_ROLES,
+ 'engineers': count_users(get_users_list()),
+ 'light_agents': count_users(get_users_list()),
+ 'licences_remaining': max(0, ZENDESK_MAX_AGENTS - context['engineers']),
+ })
return context # TODO: need to get profile page url