From e171d2fd5921df9d535c928496df5644ffe09481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=9D=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Thu, 20 Nov 2025 09:32:25 +0300 Subject: [PATCH] Fix template syntax errors in page_header integration - Fix department_list.html: use variable for create_url instead of inline yesno with url tag - Fix feed_list.html: properly handle conditional create_url with with blocks - Fix document_list.html: use variable for create_modal instead of inline yesno - Fix request_list_full.html: simplify scope toggle by placing it separately after header Django templates don't allow nested template tags in include parameters, so we now prepare variables beforehand using if/with blocks. --- .../templates/documents/document_list.html | 8 +++++++- .../templates/employees/department_list.html | 7 ++++++- backend/templates/feed/feed_list.html | 9 ++++++++- .../requests_app/request_list_full.html | 20 ++++++++++++++++++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/backend/templates/documents/document_list.html b/backend/templates/documents/document_list.html index 87326ffc..cd1fdb4f 100644 --- a/backend/templates/documents/document_list.html +++ b/backend/templates/documents/document_list.html @@ -15,7 +15,13 @@
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #} - {% include "includes/components/page_header.html" with icon="bi-file-earmark-text" title="Документы" no_search=True scope_urls=scope_urls scope=scope create_modal=perms.documents.add_document|yesno:"#docCreateModal," create_text="Создать документ" create_icon="bi-plus-lg" %} + {% if perms.documents.add_document %} + {% with create_modal_id='docCreateModal' %} + {% else %} + {% with create_modal_id='' %} + {% endif %} + {% include "includes/components/page_header.html" with icon="bi-file-earmark-text" title="Документы" no_search=True scope_urls=scope_urls scope=scope create_modal=create_modal_id create_text="Создать документ" create_icon="bi-plus-lg" %} + {% endwith %} {# ===== Карточка со списком ===== #}
diff --git a/backend/templates/employees/department_list.html b/backend/templates/employees/department_list.html index 51bfc422..cc7ed638 100644 --- a/backend/templates/employees/department_list.html +++ b/backend/templates/employees/department_list.html @@ -17,7 +17,12 @@
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #} - {% include "includes/components/page_header.html" with icon="bi-diagram-3" title="Отделы" count=departments|length count_label="Всего:" search_id="deptFilter" search_placeholder="Поиск по названию или руководителю" create_as_card=True create_url=can_create_departments|yesno:"{% url 'employees:department_create' %}," create_text="Создать отдел" %} + {% if can_create_departments or perms.employees.add_department or request.user.is_staff or request.user.is_superuser %} + {% url 'employees:department_create' as dept_create_url %} + {% else %} + {% with dept_create_url='' %}{% endwith %} + {% endif %} + {% include "includes/components/page_header.html" with icon="bi-diagram-3" title="Отделы" count=departments|length count_label="Всего:" search_id="deptFilter" search_placeholder="Поиск по названию или руководителю" create_as_card=True create_url=dept_create_url create_text="Создать отдел" %}
diff --git a/backend/templates/feed/feed_list.html b/backend/templates/feed/feed_list.html index ca515abf..8c0ed365 100644 --- a/backend/templates/feed/feed_list.html +++ b/backend/templates/feed/feed_list.html @@ -15,7 +15,14 @@
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #} - {% include "includes/components/page_header.html" with icon="bi-megaphone" title="Лента" no_search=True create_url=user.is_authenticated|yesno:"{% if user.is_staff %}{% url 'feed:post_create' %}?type=company{% endif %}," create_text="Новая публикация" create_icon="bi-plus-circle" %} + {% if user.is_authenticated and user.is_staff %} + {% url 'feed:post_create' as post_create_url %} + {% with post_create_url=post_create_url|add:"?type=company" %} + {% else %} + {% with post_create_url='' %} + {% endif %} + {% include "includes/components/page_header.html" with icon="bi-megaphone" title="Лента" no_search=True create_url=post_create_url create_text="Новая публикация" create_icon="bi-plus-circle" %} + {% endwith %} {% if new_employees %}
diff --git a/backend/templates/requests_app/request_list_full.html b/backend/templates/requests_app/request_list_full.html index f56a5c83..ab3b562d 100644 --- a/backend/templates/requests_app/request_list_full.html +++ b/backend/templates/requests_app/request_list_full.html @@ -14,7 +14,25 @@
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #} - {% include "includes/components/page_header.html" with icon="bi-clipboard-check" title="Заявления" no_search=True scope_urls=can_process|yesno:"{ 'mine': '?view=mine'|add:filters.type|yesno:'&type='|add:filters.type|add:filters.status|yesno:'&status='|add:filters.status, 'all': '?view=all'|add:filters.type|yesno:'&type='|add:filters.type|add:filters.status|yesno:'&status='|add:filters.status }," scope=scope has_filters=True filters_target="reqFilters" filters_template="requests_app/_filters.html" create_modal="#reqCreateModal" create_text="Новое заявление" create_icon="bi-plus-lg" %} + {% if can_process or user.is_staff or user.is_superuser %} + {% include "includes/components/page_header.html" with icon="bi-clipboard-check" title="Заявления" no_search=True scope=scope has_filters=True filters_target="reqFilters" filters_template="requests_app/_filters.html" create_modal="reqCreateModal" create_text="Новое заявление" create_icon="bi-plus-lg" %} + + {# Переключатель scope отдельно (вставляется через extra_buttons не работает) #} + + {% else %} + {% include "includes/components/page_header.html" with icon="bi-clipboard-check" title="Заявления" no_search=True has_filters=True filters_target="reqFilters" filters_template="requests_app/_filters.html" create_modal="reqCreateModal" create_text="Новое заявление" create_icon="bi-plus-lg" %} + {% endif %} {# ===== Список ===== #}