Skip to content

Commit

Permalink
Removing redundant validation (#4212)
Browse files Browse the repository at this point in the history
* Removing redundant validation

* Lint

* Adding explicit else

* Lint
  • Loading branch information
phildominguez-gsa committed Aug 29, 2024
1 parent 377d210 commit 5581b7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
20 changes: 6 additions & 14 deletions backend/audit/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 7 additions & 5 deletions backend/audit/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit 5581b7b

Please sign in to comment.