Compare commits

..

No commits in common. "ee2c859a9eb5c78a36b2de31644148589cf0f154" and "047c9489fef5d3ace4f5ff2b84fad39a791fdde6" have entirely different histories.

5 changed files with 8 additions and 15 deletions

View File

@ -71,7 +71,7 @@ class APIV1CreateTestCase(BaseAPIV1TestCase):
# Expect this first request to fail, since user has no shared access on the intervention, we want to create
# a compensation for
response = self._run_create_request(url, post_body)
self.assertEqual(response.status_code, 400, msg=response.content)
self.assertEqual(response.status_code, 500, msg=response.content)
content = json.loads(response.content)
self.assertGreater(len(content.get("errors", [])), 0, msg=response.content)

View File

@ -6,9 +6,7 @@ Created on: 21.01.22
"""
import json
from json import JSONDecodeError
from django.core.exceptions import ObjectDoesNotExist
from django.http import JsonResponse, HttpRequest
from api.utils.serializer.v1.compensation import CompensationAPISerializerV1
@ -68,12 +66,8 @@ class AbstractAPIViewV1(AbstractAPIView):
body = request.body.decode("utf-8")
body = json.loads(body)
created_id = self.serializer.create_model_from_json(body, self.user)
except (JSONDecodeError,
AssertionError,
ValueError,
PermissionError,
ObjectDoesNotExist) as e:
return self._return_error_response(e, 400)
except Exception as e:
return self._return_error_response(e, 500)
return JsonResponse({"id": created_id})
def put(self, request: HttpRequest, id=None):

View File

@ -81,7 +81,9 @@ class AbstractAPIView(View):
Returns:
"""
content = [f"{error.__class__.__name__}: {str(error)}"]
content = [error.__str__()]
if hasattr(error, "messages"):
content = error.messages
return JsonResponse(
{
"errors": content

View File

@ -407,10 +407,7 @@ class Geometry(BaseResource):
"""
output_geom = input_geom
if not isinstance(input_geom, MultiPolygon):
try:
output_geom = MultiPolygon(input_geom, srid=DEFAULT_SRID_RLP)
except TypeError as e:
raise AssertionError(f"Only (Multi)Polygon allowed! Could not convert {input_geom.geom_type} to MultiPolygon")
output_geom = MultiPolygon(input_geom, srid=DEFAULT_SRID_RLP)
return output_geom
@staticmethod

View File

@ -33,7 +33,7 @@ class KonovaExceptionReporter(ExceptionReporter):
"""
whitelist = [
"is_email",
"unicode_hint",
"unicdoe_hint",
"frames",
"request",
"user_str",