Skip to content

Commit

Permalink
fix(projects,contact): catch 404 exception when getting object
Browse files Browse the repository at this point in the history
Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
MyPyDavid committed Jan 22, 2025
1 parent bcd512e commit 99f98f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rdmo/projects/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ def visibility(self, request, pk=None):
throttle_classes=[EmailThrottle])
def contact(self, request, pk):
if settings.PROJECT_CONTACT:
try:
project = self.get_object()
except Http404:
return Response(status=status.HTTP_404_NOT_FOUND)

if request.method == 'POST':
subject = request.data.get('subject')
message = request.data.get('message')
Expand All @@ -347,11 +352,10 @@ def contact(self, request, pk):
'message': [_('This field may not be blank.')] if not message else []
})
else:
project = self.get_object()
project.catalog.prefetch_elements()
return Response(get_contact_message(request, project))
else:
return 404
return Response(status=status.HTTP_404_NOT_FOUND)

@action(detail=False, url_path='upload-accept', permission_classes=(IsAuthenticated, ))
def upload_accept(self, request):
Expand Down

0 comments on commit 99f98f6

Please sign in to comment.