diff --git a/backend/api/services/supplemental_report.py b/backend/api/services/supplemental_report.py index 3466d5160..587bcad74 100644 --- a/backend/api/services/supplemental_report.py +++ b/backend/api/services/supplemental_report.py @@ -22,6 +22,7 @@ def get_map_of_model_year_report_ids_to_latest_supplemental_ids( def get_ordered_list_of_supplemental_reports(model_year_report, *fields): reports = list( SupplementalReport.objects.filter(model_year_report=model_year_report) + .exclude(status=ModelYearReportStatuses.DELETED) .only("id", "supplemental_id", *fields) .order_by("create_timestamp") ) diff --git a/backend/api/viewsets/model_year_report.py b/backend/api/viewsets/model_year_report.py index c06640de0..3966e287d 100644 --- a/backend/api/viewsets/model_year_report.py +++ b/backend/api/viewsets/model_year_report.py @@ -69,6 +69,7 @@ SupplementalModelYearReportSerializer, ) from api.models.organization import Organization +from api.services.supplemental_report import get_ordered_list_of_supplemental_reports class ModelYearReportViewset( @@ -1176,3 +1177,12 @@ def assessed_supplementals(self, request, pk): data, context={"request": request}, many=True ) return Response(serializer.data) + + @action(detail=True, methods=["get"]) + def latest_supplemental_status(self, request, pk): + result = None + supplementals = get_ordered_list_of_supplemental_reports(pk, "status") + if supplementals: + result = supplementals[-1].status.value + return Response(result) + diff --git a/frontend/src/app/routes/Compliance.js b/frontend/src/app/routes/Compliance.js index e8e1ab82a..08c7b5f91 100644 --- a/frontend/src/app/routes/Compliance.js +++ b/frontend/src/app/routes/Compliance.js @@ -28,7 +28,8 @@ const COMPLIANCE = { MAKES: `${API_BASE_PATH}/reports/:id/makes`, SUPPLEMENTAL_CREATE: `${API_BASE_PATH}/reports/:id/supplemental_save`, NOA_HISTORY: `${API_BASE_PATH}/reports/:id/noa_history`, - SUPPLEMENTAL_HISTORY: `${API_BASE_PATH}/reports/:id/supplemental_history` + SUPPLEMENTAL_HISTORY: `${API_BASE_PATH}/reports/:id/supplemental_history`, + LATEST_SUPPLEMENTAL_STATUS: `${API_BASE_PATH}/reports/:id/latest_supplemental_status` } export default COMPLIANCE diff --git a/frontend/src/compliance/components/AssessmentDetailsPage.js b/frontend/src/compliance/components/AssessmentDetailsPage.js index 182660498..833e559b2 100644 --- a/frontend/src/compliance/components/AssessmentDetailsPage.js +++ b/frontend/src/compliance/components/AssessmentDetailsPage.js @@ -322,56 +322,6 @@ const AssessmentDetailsPage = (props) => {
- {CONFIG.FEATURES.SUPPLEMENTAL_REPORT.ENABLED && - !user.isGovernment && - statuses.assessment.status === 'ASSESSED' && - ((!supplementaryId && supplementaryStatus === 'DRAFT') || - (supplementaryStatus === 'DRAFT' && createdByGov) || - supplementaryStatus === 'DELETED' || - supplementaryStatus === 'ASSESSED') && ( - - - )} - {analystAction && ['RETURNED', 'SUBMITTED', 'UNSAVED'].indexOf( statuses.assessment.status @@ -388,14 +338,6 @@ const AssessmentDetailsPage = (props) => { Edit )} - } + +
+
{supplementalReportHistory && supplementalReportHistory.map((item, index) => (