|
ID: {{ source.id }}
+ Имя объекта: {{ source.objitem_name }}
Дата создания: {{ source.created_at|date:"d.m.Y H:i" }}
Кол-во объектов: {{ source.source_objitems.count }}
{% if source.coords_average %}
diff --git a/dbapp/mainapp/views/api.py b/dbapp/mainapp/views/api.py
index 9c02782..b68fef0 100644
--- a/dbapp/mainapp/views/api.py
+++ b/dbapp/mainapp/views/api.py
@@ -209,7 +209,10 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
if geo_date_from:
try:
geo_date_from_obj = datetime.strptime(geo_date_from, "%Y-%m-%d")
- objitems = objitems.filter(geo_obj__timestamp__gte=geo_date_from_obj)
+ objitems = objitems.filter(
+ geo_obj__isnull=False,
+ geo_obj__timestamp__gte=geo_date_from_obj
+ )
except (ValueError, TypeError):
pass
@@ -218,7 +221,10 @@ class SourceObjItemsAPIView(LoginRequiredMixin, View):
geo_date_to_obj = datetime.strptime(geo_date_to, "%Y-%m-%d")
# Add one day to include entire end date
geo_date_to_obj = geo_date_to_obj + timedelta(days=1)
- objitems = objitems.filter(geo_obj__timestamp__lt=geo_date_to_obj)
+ objitems = objitems.filter(
+ geo_obj__isnull=False,
+ geo_obj__timestamp__lt=geo_date_to_obj
+ )
except (ValueError, TypeError):
pass
diff --git a/dbapp/mainapp/views/marks.py b/dbapp/mainapp/views/marks.py
index ba899b4..67d810e 100644
--- a/dbapp/mainapp/views/marks.py
+++ b/dbapp/mainapp/views/marks.py
@@ -46,13 +46,19 @@ class ObjectMarksListView(LoginRequiredMixin, ListView):
context['satellites'] = Satellite.objects.all().order_by('name')
# Добавить информацию о возможности редактирования для каждой отметки
+ # и получить имя первого объекта для каждого источника
for source in context['sources']:
+ # Получить имя первого объекта
+ first_objitem = source.source_objitems.first()
+ source.objitem_name = first_objitem.name if first_objitem and first_objitem.name else '-'
+
for mark in source.marks.all():
mark.editable = mark.can_edit()
return context
+
class AddObjectMarkView(LoginRequiredMixin, View):
"""
API endpoint для добавления отметки источника.
|