diff --git a/backend/api/serializers/model_year_report.py b/backend/api/serializers/model_year_report.py
index 66064f2c1..9ccebf2a4 100644
--- a/backend/api/serializers/model_year_report.py
+++ b/backend/api/serializers/model_year_report.py
@@ -198,6 +198,7 @@ class Meta:
'update_timestamp',
)
+
class ModelYearReportsSerializer(ModelSerializer):
validation_status = EnumField(ModelYearReportStatuses)
model_year = SlugRelatedField(
@@ -211,6 +212,7 @@ class Meta:
'organization_name', 'model_year', 'validation_status', 'id', 'organization_id'
)
+
class ModelYearReportListSerializer(
ModelSerializer, EnumSupportSerializerMixin
):
@@ -222,8 +224,6 @@ class ModelYearReportListSerializer(
ldv_sales = SerializerMethodField()
supplemental_status = SerializerMethodField()
-
-
def get_ldv_sales(self, obj):
request = self.context.get('request')
@@ -300,17 +300,15 @@ def get_supplemental_status(self, obj):
return ('REASSESSMENT {}').format(sup_status)
if not request.user.is_government and sup_status in ['SUBMITTED', 'DRAFT', 'RECOMMENDED']:
# if it is being viewed by bceid, they shouldnt see it
- # unless it is reassessed or returned
+ # show the last assessed report
if supplemental_records.count() > 1:
for each in supplemental_records:
# find the newest record that is either created by bceid or one that they are allowed to see
item_create_user = UserProfile.objects.get(username=each.create_user)
# bceid are allowed to see any created by them or
- # if the status is REASSESSED or RETURNED?
- if not item_create_user.is_government or each.status.value == 'RETURNED':
+ # if the status is REASSESSED
+ if item_create_user.is_government and each.status.value == 'ASSESSED':
return ('SUPPLEMENTARY {}').format(each.status.value)
- if each.status.value == 'REASSESSED':
- return each.status.value
else:
# if created by bceid its a supplemental report
if sup_status == 'SUBMITTED':
diff --git a/backend/api/serializers/model_year_report_noa.py b/backend/api/serializers/model_year_report_noa.py
index c44d7947b..2a632e19b 100644
--- a/backend/api/serializers/model_year_report_noa.py
+++ b/backend/api/serializers/model_year_report_noa.py
@@ -57,7 +57,6 @@ def get_display_superseded_text(self, obj):
return True
return False
-
def get_is_reassessment(self, obj):
user = UserProfile.objects.filter(username=obj.create_user).first()
if user is None:
diff --git a/backend/api/serializers/model_year_report_supplemental.py b/backend/api/serializers/model_year_report_supplemental.py
index 2fb46b4c3..2d3089619 100644
--- a/backend/api/serializers/model_year_report_supplemental.py
+++ b/backend/api/serializers/model_year_report_supplemental.py
@@ -239,18 +239,26 @@ def get_reassessment(self, obj):
supplementary_report_id = None
supplementary_report_status = supplementary_report.status.value
+ supplementary_report_is_reassessment = False
if supplemental_user:
supplementary_report_id = obj.supplemental_id
supplemental_report = SupplementalReport.objects.filter(
model_year_report_id=obj.model_year_report_id,
id=obj.supplemental_id
).first()
+
supplementary_report_status = supplemental_report.status.value
+ supplemental_user = UserProfile.objects.filter(username=supplemental_report.create_user).first()
+
+ if supplemental_user.is_government:
+ supplementary_report_is_reassessment = True
+
return {
'is_reassessment': True,
'supplementary_report_id': supplementary_report_id,
'status': supplementary_report_status,
+ 'supplementary_report_is_reassessment': supplementary_report_is_reassessment
}
reassessment_report = SupplementalReport.objects.filter(
diff --git a/backend/api/viewsets/model_year_report.py b/backend/api/viewsets/model_year_report.py
index b0dea9730..ebf844466 100644
--- a/backend/api/viewsets/model_year_report.py
+++ b/backend/api/viewsets/model_year_report.py
@@ -624,6 +624,34 @@ def supplemental_assessment(self, request, pk):
if not supplemental_id:
supplemental_id = report.supplemental.id
+ # check if we have permission for this
+ supplemental_report = SupplementalReport.objects.filter(
+ id=supplemental_id
+ ).first()
+
+ create_user = UserProfile.objects.filter(
+ username=supplemental_report.create_user
+ ).first()
+
+ if supplemental_report and request.user.is_government:
+ if supplemental_report.status.value == 'DRAFT' and not create_user.is_government:
+ supplemental_id = 0
+
+ if supplemental_report.status.value in [
+ 'RETURNED',
+ 'DELETED'
+ ]:
+ supplemental_id = 0
+ elif supplemental_report and not request.user.is_government:
+ if supplemental_report.status.value == 'DRAFT' and create_user.is_government:
+ supplemental_id = 0
+
+ if supplemental_report.status.value in [
+ 'RECOMMENDED',
+ 'DELETED'
+ ]:
+ supplemental_id = 0
+
serializer = SupplementalReportAssessmentSerializer(
supplemental_id, context={'request': request}
)
diff --git a/frontend/src/app/css/Supplementary.scss b/frontend/src/app/css/Supplementary.scss
index dbac1129c..e579007e4 100644
--- a/frontend/src/app/css/Supplementary.scss
+++ b/frontend/src/app/css/Supplementary.scss
@@ -97,7 +97,7 @@
.nav-item {
padding: 1rem 0;
- &.DRAFT, &.SUBMITTED, &.UNSAVED, &.SAVED {
+ &.DRAFT, &.UNSAVED, &.SAVED {
a {
border-bottom-color: $background-warning;
}
@@ -107,7 +107,7 @@
}
}
- &.CONFIRMED, &.RECOMMENDED, &.RETURNED {
+ &.CONFIRMED, &.SUBMITTED, &.RECOMMENDED, &.RETURNED {
a {
border-bottom-color: $background-light-blue;
}
diff --git a/frontend/src/compliance/components/AssessmentDetailsPage.js b/frontend/src/compliance/components/AssessmentDetailsPage.js
index 59798f265..6b79461c5 100644
--- a/frontend/src/compliance/components/AssessmentDetailsPage.js
+++ b/frontend/src/compliance/components/AssessmentDetailsPage.js
@@ -207,14 +207,14 @@ const AssessmentDetailsPage = (props) => {