Исправил отображения объектов в источниках

This commit is contained in:
2025-11-16 00:16:50 +03:00
parent 9a816e62c2
commit d9cb243388
13 changed files with 1198 additions and 48 deletions

View File

@@ -186,7 +186,13 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
'source_objitems__parameter_obj__id_satellite',
'source_objitems__parameter_obj__polarization',
'source_objitems__parameter_obj__modulation',
'source_objitems__geo_obj'
'source_objitems__parameter_obj__standard',
'source_objitems__geo_obj',
'source_objitems__geo_obj__mirrors',
'source_objitems__lyngsat_source',
'source_objitems__transponder',
'source_objitems__created_by__user',
'source_objitems__updated_by__user'
).get(id=source_id)
# Get all related ObjItems, sorted by created_at
@@ -202,9 +208,12 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
polarization = '-'
bod_velocity = '-'
modulation = '-'
standard = '-'
snr = '-'
parameter_id = None
if param:
parameter_id = param.id
if hasattr(param, 'id_satellite') and param.id_satellite:
satellite_name = param.id_satellite.name
frequency = f"{param.frequency:.3f}" if param.frequency is not None else '-'
@@ -214,6 +223,8 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
bod_velocity = f"{param.bod_velocity:.0f}" if param.bod_velocity is not None else '-'
if hasattr(param, 'modulation') and param.modulation:
modulation = param.modulation.name
if hasattr(param, 'standard') and param.standard:
standard = param.standard.name
snr = f"{param.snr:.0f}" if param.snr is not None else '-'
# Get geo data
@@ -235,6 +246,56 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
lat = f"{latitude}N" if latitude > 0 else f"{abs(latitude)}S"
geo_coords = f"{lat} {lon}"
# Get created/updated info
created_at = '-'
if objitem.created_at:
local_time = timezone.localtime(objitem.created_at)
created_at = local_time.strftime("%d.%m.%Y %H:%M")
updated_at = '-'
if objitem.updated_at:
local_time = timezone.localtime(objitem.updated_at)
updated_at = local_time.strftime("%d.%m.%Y %H:%M")
created_by = str(objitem.created_by) if objitem.created_by else '-'
updated_by = str(objitem.updated_by) if objitem.updated_by else '-'
# Check for LyngSat
has_lyngsat = hasattr(objitem, 'lyngsat_source') and objitem.lyngsat_source is not None
lyngsat_id = objitem.lyngsat_source.id if has_lyngsat else None
# Check for Transponder
has_transponder = hasattr(objitem, 'transponder') and objitem.transponder is not None
transponder_id = objitem.transponder.id if has_transponder else None
transponder_info = '-'
if has_transponder:
try:
downlink = objitem.transponder.downlink if objitem.transponder.downlink else '-'
freq_range_t = objitem.transponder.frequency_range if objitem.transponder.frequency_range else '-'
transponder_info = f"{downlink}:{freq_range_t}"
except Exception:
transponder_info = '-'
# Check for Sigma
has_sigma = False
sigma_info = '-'
if param and hasattr(param, 'sigma_parameter'):
sigma_count = param.sigma_parameter.count()
if sigma_count > 0:
has_sigma = True
sigma_info = f"{sigma_count}"
# Get comment, is_average, and mirrors from geo_obj
comment = '-'
is_average = '-'
mirrors = '-'
if hasattr(objitem, 'geo_obj') and objitem.geo_obj:
comment = objitem.geo_obj.comment or '-'
is_average = 'Да' if objitem.geo_obj.is_average else 'Нет'
# Get mirrors list
mirrors_list = list(objitem.geo_obj.mirrors.values_list('name', flat=True))
mirrors = ', '.join(mirrors_list) if mirrors_list else '-'
objitems_data.append({
'id': objitem.id,
'name': objitem.name or '-',
@@ -244,10 +305,26 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
'polarization': polarization,
'bod_velocity': bod_velocity,
'modulation': modulation,
'standard': standard,
'snr': snr,
'geo_timestamp': geo_timestamp,
'geo_location': geo_location,
'geo_coords': geo_coords
'geo_coords': geo_coords,
'created_at': created_at,
'updated_at': updated_at,
'created_by': created_by,
'updated_by': updated_by,
'comment': comment,
'is_average': is_average,
'has_lyngsat': has_lyngsat,
'lyngsat_id': lyngsat_id,
'has_transponder': has_transponder,
'transponder_id': transponder_id,
'transponder_info': transponder_info,
'has_sigma': has_sigma,
'sigma_info': sigma_info,
'parameter_id': parameter_id,
'mirrors': mirrors,
})
return JsonResponse({