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.
This commit is contained in:
admin i 2025-11-20 09:32:25 +03:00
parent 8618b7022f
commit e171d2fd59
4 changed files with 40 additions and 4 deletions

View File

@ -15,7 +15,13 @@
<div class="container ios-page">
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #}
{% 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 %}
{# ===== Карточка со списком ===== #}
<div class="feed-card mb-3">

View File

@ -17,7 +17,12 @@
<div class="col-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="Создать отдел" %}
<div class="feed-card">
<div id="deptList" class="py-1">

View File

@ -15,7 +15,14 @@
<div class="col-12">
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #}
{% 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 %}
<div class="feed-new mb-3">

View File

@ -14,7 +14,25 @@
<div class="container ios-page">
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #}
{% 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 не работает) #}
<div class="mb-3 d-flex justify-content-end">
<div class="btn-group" role="group" aria-label="Область">
<a href="?view=mine{% if filters.type %}&type={{ filters.type }}{% endif %}{% if filters.status %}&status={{ filters.status }}{% endif %}"
class="btn btn-outline-secondary btn-sm {% if scope == 'mine' %}active{% endif %}">
Мои
</a>
<a href="?view=all{% if filters.type %}&type={{ filters.type }}{% endif %}{% if filters.status %}&status={{ filters.status }}{% endif %}"
class="btn btn-outline-secondary btn-sm {% if scope == 'all' %}active{% endif %}">
Все
</a>
</div>
</div>
{% 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 %}
{# ===== Список ===== #}
<div id="reqList" class="feed-card mb-3">