Поправил кубсат и добавил библиотеку luxon

This commit is contained in:
2025-12-11 11:27:01 +03:00
parent f79efd88e5
commit f5875e5b87
4 changed files with 86 additions and 22 deletions

View File

@@ -80,8 +80,17 @@ class KubsatView(LoginRequiredMixin, FormView):
# Сериализуем заявки в JSON для Tabulator
import json
from django.utils import timezone
requests_json_data = []
for req in requests_list:
# Конвертируем даты в локальный часовой пояс для отображения
planned_at_local = None
planned_at_iso = None
if req.planned_at:
planned_at_local = timezone.localtime(req.planned_at)
planned_at_iso = planned_at_local.isoformat()
requests_json_data.append({
'id': req.id,
'source_id': req.source_id,
@@ -90,9 +99,18 @@ class KubsatView(LoginRequiredMixin, FormView):
'status_display': req.get_status_display(),
'priority': req.priority,
'priority_display': req.get_priority_display(),
'request_date': req.request_date.strftime('%d.%m.%Y') if req.request_date else '-',
'card_date': req.card_date.strftime('%d.%m.%Y') if req.card_date else '-',
'planned_at': req.planned_at.strftime('%d.%m.%Y %H:%M') if req.planned_at else '-',
# Даты в ISO формате для правильной сортировки
'request_date': req.request_date.isoformat() if req.request_date else None,
'card_date': req.card_date.isoformat() if req.card_date else None,
'planned_at': planned_at_iso,
# Отформатированные даты для отображения
'request_date_display': req.request_date.strftime('%d.%m.%Y') if req.request_date else '-',
'card_date_display': req.card_date.strftime('%d.%m.%Y') if req.card_date else '-',
'planned_at_display': (
planned_at_local.strftime('%d.%m.%Y') if planned_at_local and planned_at_local.hour == 0 and planned_at_local.minute == 0
else planned_at_local.strftime('%d.%m.%Y %H:%M') if planned_at_local
else '-'
),
'downlink': float(req.downlink) if req.downlink else None,
'uplink': float(req.uplink) if req.uplink else None,
'transfer': float(req.transfer) if req.transfer else None,