From 5581b7bc3d8a83453502420f8fb170e99be049ec Mon Sep 17 00:00:00 2001 From: Phil Dominguez <142051477+phildominguez-gsa@users.noreply.github.com> Date: Thu, 29 Aug 2024 09:12:53 -0400 Subject: [PATCH] Removing redundant validation (#4212) * Removing redundant validation * Lint * Adding explicit else * Lint --- backend/audit/models/models.py | 20 ++++++-------------- backend/audit/views/views.py | 12 +++++++----- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/backend/audit/models/models.py b/backend/audit/models/models.py index 371fd0d2b..e74829893 100644 --- a/backend/audit/models/models.py +++ b/backend/audit/models/models.py @@ -13,7 +13,7 @@ from django.utils.translation import gettext_lazy as _ from django.utils import timezone as django_timezone -from django_fsm import FSMField, RETURN_VALUE, transition +from django_fsm import FSMField, transition import audit.cross_validation from audit.cross_validation.naming import SECTION_NAMES @@ -505,23 +505,15 @@ def validate_individually(self): @transition( field="submission_status", source=STATUS.IN_PROGRESS, - target=RETURN_VALUE(STATUS.IN_PROGRESS, STATUS.READY_FOR_CERTIFICATION), + target=STATUS.READY_FOR_CERTIFICATION, ) def transition_to_ready_for_certification(self): """ - Pretend we're doing multi-sheet validation here. - This probably won't be the first time this validation is done; - there's likely to be a step in one of the views that does cross-sheet - validation and reports back to the user. + The permission checks verifying that the user attempting to do this has + the appropriate privileges will be done at the view level. """ - errors = self.validate_full() - if not errors: - self.transition_name.append( - SingleAuditChecklist.STATUS.READY_FOR_CERTIFICATION - ) - self.transition_date.append(datetime.now(timezone.utc)) - return SingleAuditChecklist.STATUS.READY_FOR_CERTIFICATION - return SingleAuditChecklist.STATUS.IN_PROGRESS + self.transition_name.append(SingleAuditChecklist.STATUS.READY_FOR_CERTIFICATION) + self.transition_date.append(datetime.now(timezone.utc)) @transition( field="submission_status", diff --git a/backend/audit/views/views.py b/backend/audit/views/views.py index 3ac9ed51f..7820c8b52 100644 --- a/backend/audit/views/views.py +++ b/backend/audit/views/views.py @@ -332,11 +332,13 @@ def post(self, request, *args, **kwargs): event_type=SubmissionEvent.EventType.LOCKED_FOR_CERTIFICATION, ) return redirect(reverse("audit:SubmissionProgress", args=[report_id])) - - context = {"report_id": report_id, "errors": errors} - return render( - request, "audit/cross-validation/cross-validation-results.html", context - ) + else: + context = {"report_id": report_id, "errors": errors} + return render( + request, + "audit/cross-validation/cross-validation-results.html", + context, + ) except SingleAuditChecklist.DoesNotExist: raise PermissionDenied("You do not have access to this audit.")