Улучшение и добавления
This commit is contained in:
@@ -306,10 +306,14 @@ class ObjItemListView(LoginRequiredMixin, View):
|
||||
distance_geo_kup = "-"
|
||||
distance_geo_valid = "-"
|
||||
distance_kup_valid = "-"
|
||||
mirrors_list = []
|
||||
|
||||
if hasattr(obj, "geo_obj") and obj.geo_obj:
|
||||
geo_timestamp = obj.geo_obj.timestamp
|
||||
geo_location = obj.geo_obj.location
|
||||
|
||||
# Get mirrors
|
||||
mirrors_list = list(obj.geo_obj.mirrors.values_list('name', flat=True))
|
||||
|
||||
if obj.geo_obj.coords:
|
||||
longitude = obj.geo_obj.coords.coords[0]
|
||||
@@ -417,6 +421,7 @@ class ObjItemListView(LoginRequiredMixin, View):
|
||||
"standard": standard_name,
|
||||
"has_sigma": has_sigma,
|
||||
"sigma_info": sigma_info,
|
||||
"mirrors": ", ".join(mirrors_list) if mirrors_list else "-",
|
||||
"obj": obj,
|
||||
}
|
||||
)
|
||||
@@ -588,6 +593,10 @@ class ObjItemFormView(
|
||||
self.process_timestamp(geo_instance)
|
||||
|
||||
geo_instance.save()
|
||||
|
||||
# Save ManyToMany relationship for mirrors
|
||||
if geo_form.is_valid():
|
||||
geo_instance.mirrors.set(geo_form.cleaned_data["mirrors"])
|
||||
|
||||
def get_or_create_geo_instance(self):
|
||||
"""Gets or creates Geo instance."""
|
||||
|
||||
Reference in New Issue
Block a user