Поправил кубсат и добавил библиотеку luxon
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -8,6 +8,7 @@ from django.views import View
|
||||
from django.views.generic import ListView, CreateView, UpdateView
|
||||
from django.urls import reverse_lazy
|
||||
from django.db.models import Q
|
||||
from django.utils import timezone
|
||||
|
||||
from mainapp.models import SourceRequest, SourceRequestStatusHistory, Source, Satellite
|
||||
from mainapp.forms import SourceRequestForm
|
||||
@@ -200,7 +201,7 @@ class SourceRequestBulkDeleteView(LoginRequiredMixin, View):
|
||||
|
||||
return JsonResponse({
|
||||
'success': True,
|
||||
'message': f'Удалено заявок: {deleted_count}',
|
||||
'message': 'Заявки удалены',
|
||||
'deleted_count': deleted_count
|
||||
})
|
||||
except json.JSONDecodeError:
|
||||
@@ -292,7 +293,14 @@ class SourceRequestExportView(LoginRequiredMixin, View):
|
||||
ws.cell(row=row_num, column=2, value=req.card_date.strftime('%d.%m.%Y') if req.card_date else '')
|
||||
|
||||
# Дата проведения
|
||||
ws.cell(row=row_num, column=3, value=req.planned_at.strftime('%d.%m.%y %H:%M') if req.planned_at else '')
|
||||
planned_at_local = timezone.localtime(req.planned_at) if req.planned_at else None
|
||||
planned_at_str = ''
|
||||
if planned_at_local:
|
||||
if planned_at_local.hour == 0 and planned_at_local.minute == 0:
|
||||
planned_at_str = planned_at_local.strftime('%d.%m.%y')
|
||||
else:
|
||||
planned_at_str = planned_at_local.strftime('%d.%m.%y %H:%M')
|
||||
ws.cell(row=row_num, column=3, value=planned_at_str)
|
||||
|
||||
# Спутник
|
||||
satellite_str = ''
|
||||
@@ -413,7 +421,7 @@ class SourceRequestAPIView(LoginRequiredMixin, View):
|
||||
history.append({
|
||||
'old_status': h.get_old_status_display() if h.old_status else '-',
|
||||
'new_status': h.get_new_status_display(),
|
||||
'changed_at': h.changed_at.strftime('%d.%m.%Y %H:%M') if h.changed_at else '-',
|
||||
'changed_at': timezone.localtime(h.changed_at).strftime('%d.%m.%Y %H:%M') if h.changed_at else '-',
|
||||
'changed_by': str(h.changed_by) if h.changed_by else '-',
|
||||
})
|
||||
|
||||
@@ -423,13 +431,18 @@ class SourceRequestAPIView(LoginRequiredMixin, View):
|
||||
'status_display': req.get_status_display(),
|
||||
'priority': req.priority,
|
||||
'priority_display': req.get_priority_display(),
|
||||
'planned_at': req.planned_at.strftime('%d.%m.%Y %H:%M') if req.planned_at else '-',
|
||||
'planned_at': (
|
||||
timezone.localtime(req.planned_at).strftime('%d.%m.%Y')
|
||||
if req.planned_at and timezone.localtime(req.planned_at).hour == 0 and timezone.localtime(req.planned_at).minute == 0
|
||||
else timezone.localtime(req.planned_at).strftime('%d.%m.%Y %H:%M') if req.planned_at
|
||||
else '-'
|
||||
),
|
||||
'request_date': req.request_date.strftime('%d.%m.%Y') if req.request_date else '-',
|
||||
'status_updated_at': req.status_updated_at.strftime('%d.%m.%Y %H:%M') if req.status_updated_at else '-',
|
||||
'status_updated_at': timezone.localtime(req.status_updated_at).strftime('%d.%m.%Y %H:%M') if req.status_updated_at else '-',
|
||||
'gso_success': req.gso_success,
|
||||
'kubsat_success': req.kubsat_success,
|
||||
'comment': req.comment or '-',
|
||||
'created_at': req.created_at.strftime('%d.%m.%Y %H:%M') if req.created_at else '-',
|
||||
'created_at': timezone.localtime(req.created_at).strftime('%d.%m.%Y %H:%M') if req.created_at else '-',
|
||||
'created_by': str(req.created_by) if req.created_by else '-',
|
||||
'history': history,
|
||||
})
|
||||
@@ -464,7 +477,7 @@ class SourceRequestDetailAPIView(LoginRequiredMixin, View):
|
||||
history.append({
|
||||
'old_status': h.get_old_status_display() if h.old_status else '-',
|
||||
'new_status': h.get_new_status_display(),
|
||||
'changed_at': h.changed_at.strftime('%d.%m.%Y %H:%M') if h.changed_at else '-',
|
||||
'changed_at': timezone.localtime(h.changed_at).strftime('%d.%m.%Y %H:%M') if h.changed_at else '-',
|
||||
'changed_by': str(h.changed_by) if h.changed_by else '-',
|
||||
})
|
||||
|
||||
@@ -499,13 +512,18 @@ class SourceRequestDetailAPIView(LoginRequiredMixin, View):
|
||||
'status_display': req.get_status_display(),
|
||||
'priority': req.priority,
|
||||
'priority_display': req.get_priority_display(),
|
||||
'planned_at': req.planned_at.strftime('%Y-%m-%dT%H:%M') if req.planned_at else '',
|
||||
'planned_at_display': req.planned_at.strftime('%d.%m.%Y %H:%M') if req.planned_at else '-',
|
||||
'planned_at': timezone.localtime(req.planned_at).strftime('%Y-%m-%dT%H:%M') if req.planned_at else '',
|
||||
'planned_at_display': (
|
||||
timezone.localtime(req.planned_at).strftime('%d.%m.%Y')
|
||||
if req.planned_at and timezone.localtime(req.planned_at).hour == 0 and timezone.localtime(req.planned_at).minute == 0
|
||||
else timezone.localtime(req.planned_at).strftime('%d.%m.%Y %H:%M') if req.planned_at
|
||||
else '-'
|
||||
),
|
||||
'request_date': req.request_date.isoformat() if req.request_date else None,
|
||||
'request_date_display': req.request_date.strftime('%d.%m.%Y') if req.request_date else '-',
|
||||
'card_date': req.card_date.isoformat() if req.card_date else None,
|
||||
'card_date_display': req.card_date.strftime('%d.%m.%Y') if req.card_date else '-',
|
||||
'status_updated_at': req.status_updated_at.strftime('%d.%m.%Y %H:%M') if req.status_updated_at else '-',
|
||||
'status_updated_at': timezone.localtime(req.status_updated_at).strftime('%d.%m.%Y %H:%M') if req.status_updated_at else '-',
|
||||
'downlink': req.downlink,
|
||||
'uplink': req.uplink,
|
||||
'transfer': req.transfer,
|
||||
@@ -513,7 +531,7 @@ class SourceRequestDetailAPIView(LoginRequiredMixin, View):
|
||||
'gso_success': req.gso_success,
|
||||
'kubsat_success': req.kubsat_success,
|
||||
'comment': req.comment or '',
|
||||
'created_at': req.created_at.strftime('%d.%m.%Y %H:%M') if req.created_at else '-',
|
||||
'created_at': timezone.localtime(req.created_at).strftime('%d.%m.%Y %H:%M') if req.created_at else '-',
|
||||
'created_by': str(req.created_by) if req.created_by else '-',
|
||||
'history': history,
|
||||
# Координаты ГСО
|
||||
|
||||
Reference in New Issue
Block a user