1
0
Fork 0

Fix assignment of variable in scheduling_stations view

Signed-off-by: Alfredos-Panagiotis Damkalis <fredy@fredy.gr>
merge-requests/780/head
Alfredos-Panagiotis Damkalis 2019-09-30 18:54:45 +03:00
parent cf28114f54
commit 900b732478
1 changed files with 11 additions and 17 deletions

View File

@ -647,34 +647,28 @@ def scheduling_stations(request):
uuid = request.POST.get('transmitter', None) uuid = request.POST.get('transmitter', None)
if uuid is None: if uuid is None:
data = [{'error': 'You should select a Transmitter.'}] data = [{'error': 'You should select a Transmitter.'}]
json_response = JsonResponse(data, safe=False) return JsonResponse(data, safe=False)
else: else:
try: try:
transmitter = get_transmitter_by_uuid(uuid) transmitter = get_transmitter_by_uuid(uuid)
if not transmitter: if not transmitter:
data = [{'error': 'You should select a Transmitter.'}] data = [{'error': 'You should select a valid Transmitter.'}]
json_response = JsonResponse(data, safe=False) return JsonResponse(data, safe=False)
else: else:
downlink = transmitter[0]['downlink_low'] downlink = transmitter[0]['downlink_low']
if downlink is None: if downlink is None:
data = [{'error': 'You should select a valid Transmitter.'}] data = [{'error': 'You should select a valid Transmitter.'}]
json_response = JsonResponse(data, safe=False) return JsonResponse(data, safe=False)
except DBConnectionError as e: except DBConnectionError as e:
data = [{'error': e.message}] data = [{'error': e.message}]
json_response = JsonResponse(data, safe=False) return JsonResponse(data, safe=False)
if not json_response: stations = Station.objects.filter(status__gt=0)
stations = Station.objects.filter(status__gt=0) available_stations = get_available_stations(stations, downlink, request.user)
available_stations = get_available_stations(stations, downlink, request.user) data = {
import sys 'stations': StationSerializer(available_stations, many=True).data,
sys.stdout.flush() }
data = { return JsonResponse(data, safe=False)
'stations': StationSerializer(available_stations, many=True).data,
}
json_response = JsonResponse(data, safe=False)
return json_response
@ajax_required @ajax_required