diff --git a/local_db/data_access.py b/local_db/data_access.py index 45d1af74..521e7706 100644 --- a/local_db/data_access.py +++ b/local_db/data_access.py @@ -154,14 +154,12 @@ def get_file_approvals(self, request_id): def approve_file(self, request_id, user, relpath): with transaction.atomic(): - try: - request_file = RequestFileMetadata.objects.get( - filegroup__request_id=request_id, relpath=relpath - ) - except RequestFileMetadata.DoesNotExist: - raise BusinessLogicLayer.FileNotFound( - f"file {relpath} not part of a request {request_id}" - ) + # nb. the business logic layer approve_file() should confirm that this path + # is part of the request before calling this method + request_file = RequestFileMetadata.objects.get( + filegroup__request_id=request_id, relpath=relpath + ) + review, _ = FileReview.objects.get_or_create( file=request_file, reviewer=user ) @@ -170,14 +168,10 @@ def approve_file(self, request_id, user, relpath): def reject_file(self, request_id, user, relpath): with transaction.atomic(): - try: - request_file = RequestFileMetadata.objects.get( - filegroup__request_id=request_id, relpath=relpath - ) - except RequestFileMetadata.DoesNotExist: - raise BusinessLogicLayer.FileNotFound( - f"file {relpath} not part of a request {request_id}" - ) + request_file = RequestFileMetadata.objects.get( + filegroup__request_id=request_id, relpath=relpath + ) + review, _ = FileReview.objects.get_or_create( file=request_file, reviewer=user )