how a about no error 500 when locating?
This commit is contained in:
parent
580c4f0b85
commit
13197b1291
2 changed files with 2 additions and 10 deletions
|
@ -1,5 +1,3 @@
|
||||||
import json
|
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework.decorators import list_route
|
from rest_framework.decorators import list_route
|
||||||
|
@ -84,14 +82,7 @@ class RoutingViewSet(ViewSet):
|
||||||
@list_route(methods=('POST', ))
|
@list_route(methods=('POST', ))
|
||||||
def locate(self, request, *args, **kwargs):
|
def locate(self, request, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
scan_data = json.loads(request.body)
|
location = Locator.load().locate(request.data, locations_for_request(request))
|
||||||
except json.JSONDecodeError:
|
|
||||||
return Response({
|
|
||||||
'errors': (_('Invalid JSON'), ),
|
|
||||||
}, status=400)
|
|
||||||
|
|
||||||
try:
|
|
||||||
location = Locator.load().locate(scan_data, locations_for_request(request))
|
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
return Response({
|
return Response({
|
||||||
'errors': (_('Invalid scan data.'),),
|
'errors': (_('Invalid scan data.'),),
|
||||||
|
|
|
@ -211,6 +211,7 @@ class LocatorPoint(namedtuple('LocatorPoint', ('x', 'y', 'values'))):
|
||||||
raise cls.invalid_scan
|
raise cls.invalid_scan
|
||||||
if 'last' in keys and (not isinstance(data['last'], int) or data['last'] <= 0):
|
if 'last' in keys and (not isinstance(data['last'], int) or data['last'] <= 0):
|
||||||
raise cls.invalid_scan
|
raise cls.invalid_scan
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
class LocatorStation:
|
class LocatorStation:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue