Skip to content

Commit

Permalink
imports django ObjectDoesNotExist error for updating, creating in pos…
Browse files Browse the repository at this point in the history
…t method of spatial view api re #10704
  • Loading branch information
whatisgalen committed Mar 22, 2024
1 parent fc862fe commit b26056e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions arches/app/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from django.forms.models import model_to_dict
from django.urls import reverse
from django.utils.translation import get_language, gettext as _
from django.core.exceptions import ObjectDoesNotExist
from django.core.files.base import ContentFile
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
Expand Down Expand Up @@ -1756,9 +1757,15 @@ def post(self, request):
if "geometrynodeid" not in json_data:
return JSONErrorResponse(_("No Geometry Nodeid provided"), status=400)
else:
geom_node = models.Node.objects.get(nodeid=json_data["geometrynodeid"])
try:
geom_node = models.Node.objects.get(nodeid=json_data["geometrynodeid"])
except ObjectDoesNotExist:
return JSONErrorResponse(_("No Node exists for supplied geometrynodeid"), status=400)
if "language" in json_data:
lang = models.Language.objects.get(code=json_data["language"])
try:
lang = models.Language.objects.get(code=json_data["language"])
except ObjectDoesNotExist:
return JSONErrorResponse(_("No Language exists for supplied language code"), status=400)
else:
graph_x_pubs = models.GraphXPublishedGraph.objects.filter(graph=geom_node.graph)
pubs = models.PublishedGraph.objects.filter(publication__in=graph_x_pubs)
Expand Down

0 comments on commit b26056e

Please sign in to comment.