diff --git a/api/cases/tests/test_case_ecju_queries.py b/api/cases/tests/test_case_ecju_queries.py index b4f4926577..fb236eb65c 100644 --- a/api/cases/tests/test_case_ecju_queries.py +++ b/api/cases/tests/test_case_ecju_queries.py @@ -15,6 +15,7 @@ from api.audit_trail.serializers import AuditSerializer from api.cases.enums import ECJUQueryType from api.cases.models import EcjuQuery +from api.core.exceptions import NotFoundError from api.compliance.tests.factories import ComplianceSiteCaseFactory from api.licences.enums import LicenceStatus from api.licences.tests.factories import StandardLicenceFactory diff --git a/api/cases/views/views.py b/api/cases/views/views.py index 65355a0bc0..b00412c126 100644 --- a/api/cases/views/views.py +++ b/api/cases/views/views.py @@ -646,18 +646,15 @@ def put(self, request, pk, ecju_pk): payload={"ecju_response": data.get("response")}, ) - # if an exporter responds to a query, create a mention notification + # If an exporter responds to a query, create a mention notification # for the case worker that lets them know the query has been responded to if not is_govuser_request: - try: - exporter_user_full_name = ExporterUser.objects.get(baseuser_ptr_id=request.user.pk).full_name - create_system_mention( - case=ecju_query.case, - case_note_text=f"{exporter_user_full_name} has responded to a query.", - mention_user=ecju_query.raised_by_user, - ) - except ExporterUser.DoesNotExist: - raise NotFoundError({"user": f"ExporterUser not found for pk: {request.user.pk}"}) + exporter_user_full_name = ExporterUser.objects.get(baseuser_ptr_id=request.user.pk).full_name + create_system_mention( + case=ecju_query.case, + case_note_text=f"{exporter_user_full_name} has responded to a query.", + mention_user=ecju_query.raised_by_user, + ) return JsonResponse(data={"ecju_query": serializer.data}, status=status.HTTP_200_OK)