Skip to content

Commit

Permalink
Add barebones feature allowing users to send submissions back to in p…
Browse files Browse the repository at this point in the history
…rogress from ready for certification.
  • Loading branch information
tadhg-ohiggins committed Oct 20, 2023
1 parent 92dec12 commit 48aa466
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 153 deletions.
4 changes: 4 additions & 0 deletions backend/audit/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,7 @@ def clean_booleans(self):
)
tribal_authorization_certifying_official_name = forms.CharField()
tribal_authorization_certifying_official_title = forms.CharField()


class UnlockAfterCertificationForm(forms.Form):
unlock_after_certification = forms.BooleanField()
8 changes: 8 additions & 0 deletions backend/audit/modellib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .submission_event import ( # noqa
SubmissionEvent,
)

# In case we want to iterate through all the models for some reason:
models = [
SubmissionEvent,
]
79 changes: 79 additions & 0 deletions backend/audit/modellib/submission_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import logging
from django.contrib.auth import get_user_model
from django.db import models
from django.utils.translation import gettext_lazy as _

User = get_user_model()

logger = logging.getLogger(__name__)


class SubmissionEvent(models.Model):
class EventType:
ACCESS_GRANTED = "access-granted"
ADDITIONAL_EINS_UPDATED = "additional-eins-updated"
ADDITIONAL_UEIS_UPDATED = "additional-ueis-updated"
AUDIT_INFORMATION_UPDATED = "audit-information-updated"
AUDIT_REPORT_PDF_UPDATED = "audit-report-pdf-updated"
AUDITEE_CERTIFICATION_COMPLETED = "auditee-certification-completed"
AUDITOR_CERTIFICATION_COMPLETED = "auditor-certification-completed"
CORRECTIVE_ACTION_PLAN_UPDATED = "corrective-action-plan-updated"
CREATED = "created"
FEDERAL_AWARDS_UPDATED = "federal-awards-updated"
FEDERAL_AWARDS_AUDIT_FINDINGS_UPDATED = "federal-awards-audit-findings-updated"
FEDERAL_AWARDS_AUDIT_FINDINGS_TEXT_UPDATED = (
"federal-awards-audit-findings-text-updated"
)
FINDINGS_UNIFORM_GUIDANCE_UPDATED = "findings-uniform-guidance-updated"
GENERAL_INFORMATION_UPDATED = "general-information-updated"
LOCKED_FOR_CERTIFICATION = "locked-for-certification"
UNLOCKED_AFTER_CERTIFICATION = "unlocked-after-certification"
NOTES_TO_SEFA_UPDATED = "notes-to-sefa-updated"
SECONDARY_AUDITORS_UPDATED = "secondary-auditors-updated"
SUBMITTED = "submitted"
DISSEMINATED = "disseminated"
TRIBAL_CONSENT_UPDATED = "tribal-consent-updated"

EVENT_TYPES = (
(EventType.ACCESS_GRANTED, _("Access granted")),
(EventType.ADDITIONAL_EINS_UPDATED, _("Additional EINs updated")),
(EventType.ADDITIONAL_UEIS_UPDATED, _("Additional UEIs updated")),
(EventType.AUDIT_INFORMATION_UPDATED, _("Audit information updated")),
(EventType.AUDIT_REPORT_PDF_UPDATED, _("Audit report PDF updated")),
(
EventType.AUDITEE_CERTIFICATION_COMPLETED,
_("Auditee certification completed"),
),
(
EventType.AUDITOR_CERTIFICATION_COMPLETED,
_("Auditor certification completed"),
),
(EventType.CORRECTIVE_ACTION_PLAN_UPDATED, _("Corrective action plan updated")),
(EventType.CREATED, _("Created")),
(EventType.FEDERAL_AWARDS_UPDATED, _("Federal awards updated")),
(
EventType.FEDERAL_AWARDS_AUDIT_FINDINGS_UPDATED,
_("Federal awards audit findings updated"),
),
(
EventType.FEDERAL_AWARDS_AUDIT_FINDINGS_TEXT_UPDATED,
_("Federal awards audit findings text updated"),
),
(
EventType.FINDINGS_UNIFORM_GUIDANCE_UPDATED,
_("Findings uniform guidance updated"),
),
(EventType.GENERAL_INFORMATION_UPDATED, _("General information updated")),
(EventType.LOCKED_FOR_CERTIFICATION, _("Locked for certification")),
(EventType.UNLOCKED_AFTER_CERTIFICATION, _("Unlocked after certification")),
(EventType.NOTES_TO_SEFA_UPDATED, _("Notes to SEFA updated")),
(EventType.SECONDARY_AUDITORS_UPDATED, _("Secondary auditors updated")),
(EventType.SUBMITTED, _("Submitted to the FAC for processing")),
(EventType.DISSEMINATED, _("Copied to dissemination tables")),
(EventType.TRIBAL_CONSENT_UPDATED, _("Tribal audit consent updated")),
)

sac = models.ForeignKey("audit.SingleAuditChecklist", on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.PROTECT)
timestamp = models.DateTimeField(auto_now_add=True)
event = models.CharField(choices=EVENT_TYPES)
83 changes: 14 additions & 69 deletions backend/audit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import audit.cross_validation
from audit.intake_to_dissemination import IntakeToDissemination
from audit.modellib import SubmissionEvent
from audit.validators import (
validate_additional_ueis_json,
validate_additional_eins_json,
Expand Down Expand Up @@ -467,6 +468,19 @@ def transition_to_ready_for_certification(self):
return SingleAuditChecklist.STATUS.READY_FOR_CERTIFICATION
return SingleAuditChecklist.STATUS.IN_PROGRESS

@transition(
field="submission_status",
source=STATUS.READY_FOR_CERTIFICATION,
target=STATUS.IN_PROGRESS,
)
def transition_to_in_progress_again(self):
"""
The permission checks verifying that the user attempting to do this has
the appropriate privileges will done at the view level.
"""
self.transition_name.append(SingleAuditChecklist.STATUS.IN_PROGRESS)
self.transition_date.append(datetime.now(timezone.utc))

@transition(
field="submission_status",
source=STATUS.READY_FOR_CERTIFICATION,
Expand Down Expand Up @@ -735,72 +749,3 @@ def save(self, *args, **kwargs):
)

super().save(*args, **kwargs)


class SubmissionEvent(models.Model):
class EventType:
ACCESS_GRANTED = "access-granted"
ADDITIONAL_EINS_UPDATED = "additional-eins-updated"
ADDITIONAL_UEIS_UPDATED = "additional-ueis-updated"
AUDIT_INFORMATION_UPDATED = "audit-information-updated"
AUDIT_REPORT_PDF_UPDATED = "audit-report-pdf-updated"
AUDITEE_CERTIFICATION_COMPLETED = "auditee-certification-completed"
AUDITOR_CERTIFICATION_COMPLETED = "auditor-certification-completed"
CORRECTIVE_ACTION_PLAN_UPDATED = "corrective-action-plan-updated"
CREATED = "created"
FEDERAL_AWARDS_UPDATED = "federal-awards-updated"
FEDERAL_AWARDS_AUDIT_FINDINGS_UPDATED = "federal-awards-audit-findings-updated"
FEDERAL_AWARDS_AUDIT_FINDINGS_TEXT_UPDATED = (
"federal-awards-audit-findings-text-updated"
)
FINDINGS_UNIFORM_GUIDANCE_UPDATED = "findings-uniform-guidance-updated"
GENERAL_INFORMATION_UPDATED = "general-information-updated"
LOCKED_FOR_CERTIFICATION = "locked-for-certification"
NOTES_TO_SEFA_UPDATED = "notes-to-sefa-updated"
SECONDARY_AUDITORS_UPDATED = "secondary-auditors-updated"
SUBMITTED = "submitted"
DISSEMINATED = "disseminated"
TRIBAL_CONSENT_UPDATED = "tribal-consent-updated"

EVENT_TYPES = (
(EventType.ACCESS_GRANTED, _("Access granted")),
(EventType.ADDITIONAL_EINS_UPDATED, _("Additional EINs updated")),
(EventType.ADDITIONAL_UEIS_UPDATED, _("Additional UEIs updated")),
(EventType.AUDIT_INFORMATION_UPDATED, _("Audit information updated")),
(EventType.AUDIT_REPORT_PDF_UPDATED, _("Audit report PDF updated")),
(
EventType.AUDITEE_CERTIFICATION_COMPLETED,
_("Auditee certification completed"),
),
(
EventType.AUDITOR_CERTIFICATION_COMPLETED,
_("Auditor certification completed"),
),
(EventType.CORRECTIVE_ACTION_PLAN_UPDATED, _("Corrective action plan updated")),
(EventType.CREATED, _("Created")),
(EventType.FEDERAL_AWARDS_UPDATED, _("Federal awards updated")),
(
EventType.FEDERAL_AWARDS_AUDIT_FINDINGS_UPDATED,
_("Federal awards audit findings updated"),
),
(
EventType.FEDERAL_AWARDS_AUDIT_FINDINGS_TEXT_UPDATED,
_("Federal awards audit findings text updated"),
),
(
EventType.FINDINGS_UNIFORM_GUIDANCE_UPDATED,
_("Findings uniform guidance updated"),
),
(EventType.GENERAL_INFORMATION_UPDATED, _("General information updated")),
(EventType.LOCKED_FOR_CERTIFICATION, _("Locked for certification")),
(EventType.NOTES_TO_SEFA_UPDATED, _("Notes to SEFA updated")),
(EventType.SECONDARY_AUDITORS_UPDATED, _("Secondary auditors updated")),
(EventType.SUBMITTED, _("Submitted to the FAC for processing")),
(EventType.DISSEMINATED, _("Copied to dissemination tables")),
(EventType.TRIBAL_CONSENT_UPDATED, _("Tribal audit consent updated")),
)

sac = models.ForeignKey(SingleAuditChecklist, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.PROTECT)
timestamp = models.DateTimeField(auto_now_add=True)
event = models.CharField(choices=EVENT_TYPES)
1 change: 1 addition & 0 deletions backend/audit/templates/audit/my_submissions.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ <h1 class="font-sans-xl">Audits in progress</h1>
<tr>
<td>
<a class="usa-link" href="{% url 'audit:SubmissionProgress' item.report_id %}">{{ item.submission_status }}</a>
{% if item.submission_status == "Ready For Certification" %}<a class="usa-link" href="{% url 'audit:UnlockAfterCertification' item.report_id %}">🔓</a>{% endif%}
</td>
<td>{{ item.auditee_name }}</td>
<td>{{ item.report_id }}</td>
Expand Down
49 changes: 49 additions & 0 deletions backend/audit/templates/audit/unlock-after-certification.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
<div class="grid-container margin-top-6 margin-bottom-10">
<div class="grid-row">
<h1 class="font-sans-2xl" id="title">Unlock after certification</h1>
{% if submission_status == target_status %}
<form class="padding-x-6"
id="unlock-after-certification"
method="post">
{% csrf_token %}
<fieldset class="usa-fieldset">

{% comment %} This div is the grey box, and should handle its own margins and padding. {% endcomment %}
<div class="bg-base-lightest padding-5">
<fieldset class="usa-fieldset radio margin-bottom-6" id="question-opt-in-out">
<legend class="margin-bottom-3 font-sans-lg text-bold text-underline">
I understand that this will move the submission back to an in-progress, editable state and that it will need to be marked as ready for certification again in future.
</legend>

<div class="usa-checkbox">
<input id="unlock_after_certification"
name="unlock_after_certification"
class="usa-checkbox__input"
type="checkbox"
value="True"
checked
<label class="usa-checkbox__label" for="unlock-for-certification-checkbox"></label>
</div>

<fieldset class="usa-fieldset margin-top-2 tablet:grid-col-12" id="agree-or-cancel">
<button class="usa-button" id="continue">Agree to unlock for certification</button>
<a class="usa-button usa-button--unstyled margin-left-2 margin-top-2 tablet:margin-top-0"
id="unlock-after-certification-button"
href="{% url 'audit:SubmissionProgress' report_id %}"
aria-controls="form-cancel">Cancel</a>
</fieldset>
</fieldset>
</div>
</fieldset>
</form>
{% else %}
<p>This form is only accessible for submissions with a ready for certification status.</p>

{% endif%}
</div>
</div>
{% include "audit-metadata.html" %}
{% endblock content %}
7 changes: 7 additions & 0 deletions backend/audit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def test_submission_status_transitions(self):
SingleAuditChecklist.STATUS.SUBMITTED,
"transition_to_submitted",
),
(
[
SingleAuditChecklist.STATUS.READY_FOR_CERTIFICATION,
],
SingleAuditChecklist.STATUS.IN_PROGRESS,
"transition_to_in_progress_again",
),
)

now = datetime.now(timezone.utc)
Expand Down
Loading

0 comments on commit 48aa466

Please sign in to comment.