rework objitem model
This commit is contained in:
@@ -92,23 +92,24 @@ from django.views.generic import View
|
||||
|
||||
class GetLocationsView(View):
|
||||
def get(self, request, sat_id):
|
||||
locations = ObjItem.objects.filter(id_vch_load__id_satellite=sat_id)
|
||||
locations = ObjItem.objects.filter(parameters_obj__id_satellite=sat_id)
|
||||
if not locations:
|
||||
return JsonResponse({'error': 'Объектов не найдено'}, status=400)
|
||||
|
||||
features = []
|
||||
for loc in locations:
|
||||
param = loc.parameters_obj.get()
|
||||
features.append({
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [loc.id_geo.coords[0], loc.id_geo.coords[1]]
|
||||
"coordinates": [loc.geo_obj.coords[0], loc.geo_obj.coords[1]]
|
||||
},
|
||||
"properties": {
|
||||
"pol": loc.id_vch_load.polarization.name,
|
||||
"freq": loc.id_vch_load.frequency*1000000,
|
||||
"pol": param.polarization.name,
|
||||
"freq": param.frequency*1000000,
|
||||
"name": f"{loc.name}",
|
||||
"id": loc.id_geo.id
|
||||
"id": loc.geo_obj.id
|
||||
}
|
||||
})
|
||||
|
||||
@@ -153,12 +154,19 @@ class ShowMapView(UserPassesTestMixin, View):
|
||||
points = []
|
||||
if ids:
|
||||
id_list = [int(x) for x in ids.split(',') if x.isdigit()]
|
||||
locations = ObjItem.objects.filter(id__in=id_list)
|
||||
locations = ObjItem.objects.filter(id__in=id_list).prefetch_related(
|
||||
'parameters_obj__id_satellite',
|
||||
'parameters_obj__polarization',
|
||||
'parameters_obj__modulation',
|
||||
'parameters_obj__standard',
|
||||
'geo_obj'
|
||||
)
|
||||
for obj in locations:
|
||||
param = obj.parameters_obj.get()
|
||||
points.append({
|
||||
'name': f"{obj.name}",
|
||||
'freq': f"{obj.id_vch_load.frequency} [{obj.id_vch_load.freq_range}] МГц",
|
||||
'point': (obj.id_geo.coords.x, obj.id_geo.coords.y)
|
||||
'freq': f"{param.frequency} [{param.freq_range}] МГц",
|
||||
'point': (obj.geo_obj.coords.x, obj.geo_obj.coords.y)
|
||||
})
|
||||
else:
|
||||
return redirect('admin')
|
||||
@@ -222,10 +230,10 @@ class LinkVchSigmaView(FormView):
|
||||
def form_valid(self, form):
|
||||
freq = form.cleaned_data['value1']
|
||||
freq_range = form.cleaned_data['value2']
|
||||
ku_range = float(form.cleaned_data['ku_range'])
|
||||
# ku_range = float(form.cleaned_data['ku_range'])
|
||||
sat_id = form.cleaned_data['sat_choice']
|
||||
# print(freq, freq_range, ku_range, sat_id.pk)
|
||||
count_all, link_count = compare_and_link_vch_load(sat_id, freq, freq_range, ku_range)
|
||||
count_all, link_count = compare_and_link_vch_load(sat_id, freq, freq_range, 1)
|
||||
messages.success(self.request, f"Привязано {link_count} из {count_all} объектов")
|
||||
return redirect('link_vch_sigma')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user