views/prediction_windows: Add comments
Signed-off-by: Fabian P. Schmidt <kerel@mailbox.org>merge-requests/832/head
parent
4539cc4af0
commit
fab37d905b
|
@ -376,18 +376,22 @@ def prediction_windows(request):
|
||||||
|
|
||||||
params = prediction_windows_parse_parameters(request)
|
params = prediction_windows_parse_parameters(request)
|
||||||
|
|
||||||
|
# Check the selected satellite exists and is alive
|
||||||
try:
|
try:
|
||||||
sat = Satellite.objects.filter(status='alive').get(norad_cat_id=params['sat_norad_id'])
|
sat = Satellite.objects.filter(status='alive').get(norad_cat_id=params['sat_norad_id'])
|
||||||
except Satellite.DoesNotExist:
|
except Satellite.DoesNotExist:
|
||||||
data = [{'error': 'You should select a Satellite first.'}]
|
data = [{'error': 'You should select a Satellite first.'}]
|
||||||
return JsonResponse(data, safe=False)
|
return JsonResponse(data, safe=False)
|
||||||
|
|
||||||
|
# Check there is a TLE available for this satellite
|
||||||
try:
|
try:
|
||||||
tle = LatestTle.objects.get(satellite_id=sat.id)
|
tle = LatestTle.objects.get(satellite_id=sat.id)
|
||||||
except LatestTle.DoesNotExist:
|
except LatestTle.DoesNotExist:
|
||||||
data = [{'error': 'No TLEs for this satellite yet.'}]
|
data = [{'error': 'No TLEs for this satellite yet.'}]
|
||||||
return JsonResponse(data, safe=False)
|
return JsonResponse(data, safe=False)
|
||||||
|
|
||||||
|
# Check the selected transmitter exists, and if yes,
|
||||||
|
# store this transmitter in the downlink variable
|
||||||
try:
|
try:
|
||||||
transmitter = get_transmitter_by_uuid(params['transmitter'])
|
transmitter = get_transmitter_by_uuid(params['transmitter'])
|
||||||
if not transmitter:
|
if not transmitter:
|
||||||
|
@ -398,6 +402,7 @@ def prediction_windows(request):
|
||||||
data = [{'error': error.message}]
|
data = [{'error': error.message}]
|
||||||
return JsonResponse(data, safe=False)
|
return JsonResponse(data, safe=False)
|
||||||
|
|
||||||
|
# Fetch all available ground stations
|
||||||
stations = Station.objects.filter(status__gt=0).prefetch_related(
|
stations = Station.objects.filter(status__gt=0).prefetch_related(
|
||||||
Prefetch(
|
Prefetch(
|
||||||
'observations',
|
'observations',
|
||||||
|
@ -407,6 +412,7 @@ def prediction_windows(request):
|
||||||
)
|
)
|
||||||
|
|
||||||
if params['station_ids'] and params['station_ids'] != ['']:
|
if params['station_ids'] and params['station_ids'] != ['']:
|
||||||
|
# Filter ground stations based on the given selection
|
||||||
stations = stations.filter(id__in=params['station_ids'])
|
stations = stations.filter(id__in=params['station_ids'])
|
||||||
if not stations:
|
if not stations:
|
||||||
if len(params['station_ids']) == 1:
|
if len(params['station_ids']) == 1:
|
||||||
|
|
Loading…
Reference in New Issue