Правки и улучшения визуала. Добавил функционал отметок.

This commit is contained in:
2025-11-16 23:32:29 +03:00
parent d9cb243388
commit 8994a0e500
30 changed files with 2495 additions and 510 deletions

View File

@@ -192,7 +192,9 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
'source_objitems__lyngsat_source',
'source_objitems__transponder',
'source_objitems__created_by__user',
'source_objitems__updated_by__user'
'source_objitems__updated_by__user',
'marks',
'marks__created_by__user'
).get(id=source_id)
# Get all related ObjItems, sorted by created_at
@@ -327,9 +329,25 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
'mirrors': mirrors,
})
# Get marks for the source
marks_data = []
for mark in source.marks.all().order_by('-timestamp'):
mark_timestamp = '-'
if mark.timestamp:
local_time = timezone.localtime(mark.timestamp)
mark_timestamp = local_time.strftime("%d.%m.%Y %H:%M")
marks_data.append({
'id': mark.id,
'mark': mark.mark,
'timestamp': mark_timestamp,
'created_by': str(mark.created_by) if mark.created_by else '-',
})
return JsonResponse({
'source_id': source_id,
'objitems': objitems_data
'objitems': objitems_data,
'marks': marks_data
})
except Source.DoesNotExist:
return JsonResponse({'error': 'Источник не найден'}, status=404)