Files
ACORE/core/utils/htmx.py
T
lokses 78475b58e9 Инфраструктура: Celery, общие утилиты, виджеты, шелл портала
- acore: Celery-приложение (брокер из env, eager без брокера), настройки
  CELERY_*, регистрация всех новых приложений в INSTALLED_APPS, маршруты
- core/utils: render_page (HTMX-фрагмент/полный layout), is_owner/
  is_owner_or_staff; templatetags common_tags (initials, clean_excerpt,
  is_it_staff); UpdateLastSeenMiddleware
- static: people-picker (дерево отделов с аватарками), searchable-select
  (одиночный выбор с поиском), directory-quick-add, it-manager, pagination;
  тема Tailwind v4 пересобрана, лого
- templates: новый шелл index.html (мобильный сайдбар, темы, фон,
  user-dropdown) и login с брендингом

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 17:31:01 +03:00

16 lines
768 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from django.shortcuts import render
def is_htmx_request(request) -> bool:
"""Запрос прислан HTMX (hx-get/hx-post), а не обычной навигацией браузера"""
return request.headers.get('HX-Request') == 'true'
def render_page(request, page_template: str, context: dict = None):
"""Страница портала: HTMX-фрагмент из pages/<page_template> или полный
layout (index.html) с этим же фрагментом внутри — по типу запроса."""
context = context or {}
if is_htmx_request(request):
return render(request, f'pages/{page_template}', context)
return render(request, 'index.html', {'page_template': f'pages/{page_template}', **context})