Corp/backend/scripts/utils/render_test_page.py
2026-09-07 19:43:48 +03:00

61 lines
1.9 KiB
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.

#!/usr/bin/env python
"""
Создаёт HTML файл с рендером страницы отдела для проверки.
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "eusrr_backend.settings")
import django
django.setup()
from django.contrib.auth import get_user_model
from django.test import RequestFactory
from employees.models import Department
User = get_user_model()
# Получаем отдел и пользователя
dept = Department.objects.filter(id=16).first()
if not dept:
dept = Department.objects.first()
user = User.objects.filter(is_superuser=True).first()
if not dept or not user:
print("Нет данных для рендеринга")
exit(1)
# Создаём request
factory = RequestFactory()
request = factory.get(f"/employees/departments/{dept.id}/")
request.user = user
# Получаем view context
from employees.views_front import department_detail
response = department_detail(request, pk=dept.id)
# Сохраняем HTML
output_file = "department_page_render.html"
with open(output_file, "wb") as f:
f.write(response.content)
print(f"✓ Страница сохранена в {output_file}")
print(f" Размер: {len(response.content)} байт")
# Анализ содержимого
html = response.content.decode("utf-8")
print("\nАнализ:")
print(f" <style> тегов: {html.count('<style>')}")
print(f" <script> тегов: {html.count('<script>')}")
print(f" .team-wheel: {'✓' if '.team-wheel' in html else '✗'}")
print(f" .calendar-wrap: {'✓' if '.calendar-wrap' in html else '✗'}")
print(f" initTeamWheel: {'✓' if 'initTeamWheel' in html else '✗'}")
print(f" FullCalendar: {'✓' if 'FullCalendar' in html else '✗'}")
print(f" dropdown-toggle: {'✓' if 'dropdown-toggle' in html else '✗'}")
print(f" Bootstrap JS: {'✓' if 'bootstrap.bundle.min.js' in html else '✗'}")