Skip to content

Commit

Permalink
Tracking pull request to merge release-1.51.0 to master (#1951)
Browse files Browse the repository at this point in the history
* update for release-1.51.0

* update pr number

* try string replace

* try string replace

* try string replace

* try string replace

* try replace string

* update create release workflow

* feat: zeva-1898 - small suppliers - assessment reduction (#1953)

* feat: zeva-1874 - myr starting balance styling (#1952)

* fix: zeva-1902 - report history (#1954)

* fix: zeva-1902 - supplementary report history fixes

* update unit test

* feat: zeva-1852 - Allow BCeID user to delete Draft MY Report (#1955)

* delete more MYR dependencies upon MYR delete (#1957)

* feat: zeva-1834 - remove outdated text (#1956)

* increase spilo resource allocation

* update backup cron schedule

* feat: zeva-1959 - slow loading credit applications (#1962)

* feat: zeva-1959 - slow loading credit applications

* fix code smells

* fix code smell

* more refinements/improvements

* fix: zeva-1959 - duplicate vins warning fix (#1965)

* fix: zeva-1959 - fix populate date warnings (#1966)

---------

Co-authored-by: tim738745 <[email protected]>
  • Loading branch information
kuanfandevops and tim738745 authored Sep 28, 2023
1 parent 93b8801 commit a8b80b2
Show file tree
Hide file tree
Showing 37 changed files with 1,180 additions and 567 deletions.
1 change: 0 additions & 1 deletion .github/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ The "Build PR on Dev" pipeline will be triggered when it identified pull request
* Update frontend/package.json version and create the new tracking pull request
* Update release-build.yaml
* name
* on -> push -> branches
* env -> PR_NUMBER
* env -> VERSION
* jobs -> call-unit-test -> with -> pr-numb
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ on:
jobs:
create-release:
runs-on: ubuntu-latest
env:
releasename: ${{ github.event.pull_request.head.ref }}
steps:
- uses: actions/checkout@v3
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.event.pull_request.head.ref/release-/v }}
tag_name: ${{ github.event.pull_request.head.ref/release-/v }}
name: ${releasename/release-/v}
tag_name: ${releasename/release-/v}
body: |
${{ github.event.pull_request.body }}
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/dev-build.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## For each release, please update the value of workflow name, branches and PR_NUMBER
## Also update frontend/package.json version

name: Dev Build 1.50.0
name: Dev Build 1.51.0

on:
push:
branches: [ release-1.50.0 ]
branches: [ release-1.51.0 ]
paths:
- frontend/**
- backend/**
Expand All @@ -14,8 +14,8 @@ on:

env:
## The pull request number of the Tracking pull request to merge the release branch to main
PR_NUMBER: 1931
VERSION: 1.50.0
PR_NUMBER: 1951
VERSION: 1.51.0
GIT_URL: https://github.com/bcgov/zeva.git
TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev
Expand All @@ -32,7 +32,7 @@ jobs:
call-unit-test:
uses: ./.github/workflows/unit-test-template.yaml
with:
pr-number: 1931
pr-number: 1951

build:

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-build.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## For each release, please update the value of workflow name, branches and PR_NUMBER
## Also update frontend/package.json version

name: Release Build 1.50.0
name: Release Build 1.51.0

on:
workflow_dispatch:
workflow_call:

env:
## The pull request number of the Tracking pull request to merge the release branch to main
PR_NUMBER: 1931
VERSION: 1.50.0
PR_NUMBER: 1951
VERSION: 1.51.0
GIT_URL: https://github.com/bcgov/zeva.git
TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev
Expand All @@ -27,7 +27,7 @@ jobs:
call-unit-test:
uses: ./.github/workflows/unit-test-template.yaml
with:
pr-number: 1931
pr-number: 1951

build:

Expand Down
93 changes: 32 additions & 61 deletions backend/api/serializers/model_year_report_noa.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from api.models.supplemental_report import SupplementalReport
from api.models.user_profile import UserProfile
from api.serializers.user import MemberSerializer, UserSerializer
from django.db.models import Q


class ModelYearReportNoaSerializer(ModelSerializer):
Expand Down Expand Up @@ -117,79 +118,49 @@ def get_is_supplementary(self, obj):
def get_status(self, obj):
request = self.context.get('request')

filter_statuses = [
ModelYearReportStatuses.ASSESSED,
ModelYearReportStatuses.REASSESSED
]

if request.user.is_government:
filter_statuses.append(ModelYearReportStatuses.RECOMMENDED)

reassessment_report = SupplementalReport.objects.filter(
supplemental_id=obj.id,
status__in=filter_statuses
).first()

if reassessment_report:
return reassessment_report.status.value
if not request.user.is_government and \
obj.status in [ModelYearReportStatuses.RECOMMENDED, ModelYearReportStatuses.RETURNED]:
return ModelYearReportStatuses.SUBMITTED.value

return obj.status.value

def get_history(self, obj):
request = self.context.get('request')

q_obj = Q(supplemental_report_id=obj.id)
if obj.supplemental_id:
previous_supplemental = SupplementalReport.objects.filter(id=obj.supplemental_id).first()
if previous_supplemental and previous_supplemental.status == ModelYearReportStatuses.SUBMITTED and not previous_supplemental.is_reassessment:
q_obj = q_obj | Q(supplemental_report_id=obj.supplemental_id)

history = SupplementalReportHistory.objects.filter(
supplemental_report_id=obj.id
q_obj
).order_by('-update_timestamp')

# is this a supplemental report? (created by bceid user)
create_user = UserProfile.objects.filter(username=obj.create_user).first()
if create_user and not create_user.is_government:
filter_statuses = [
ModelYearReportStatuses.ASSESSED,
ModelYearReportStatuses.REASSESSED
]

if request.user.is_government:
filter_statuses.append(ModelYearReportStatuses.RECOMMENDED)
history = history.filter(
validation_status__in=[
ModelYearReportStatuses.SUBMITTED
]
)

reassessment_report = SupplementalReport.objects.filter(
supplemental_id=obj.id,
status__in=filter_statuses
).first()

if reassessment_report:
reassessment_history = SupplementalReportHistory.objects.filter(
supplemental_report_id=reassessment_report.id,
validation_status__in=filter_statuses
).order_by('-update_timestamp')
history = reassessment_history | history
elif not request.user.is_government:
filter_statuses = [
ModelYearReportStatuses.ASSESSED,
ModelYearReportStatuses.REASSESSED
]

history = history.filter(
validation_status__in=filter_statuses
if request.user.is_government:
history = history.exclude(
validation_status__in=[
ModelYearReportStatuses.DELETED,
]
)
else:
history = history.exclude(
validation_status__in=[
ModelYearReportStatuses.RECOMMENDED,
ModelYearReportStatuses.DELETED,
ModelYearReportStatuses.RETURNED,
]
)
# Remove submitted by government user (only happens when the IDIR user saves first)
users = UserProfile.objects.filter(organization__is_government=True).values_list('username')
history = history.exclude(
validation_status__in=[
ModelYearReportStatuses.SUBMITTED,
],
create_user__in=users
)

# Remove submitted by government user (only happens when the IDIR user saves first)
users = UserProfile.objects.filter(organization__is_government=True).values_list('username')
history = history.exclude(
validation_status__in=[
ModelYearReportStatuses.SUBMITTED,
],
create_user__in=users
)

serializer = SupplementalReportHistorySerializer(history, many=True)

return serializer.data

class Meta:
Expand Down
4 changes: 4 additions & 0 deletions backend/api/serializers/sales_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ def get_evidence(self, instance):

def get_content(self, instance):
request = self.context.get('request')
skip_content = request.GET.get('skip_content', False)

if skip_content == 'true':
return []

content = []

Expand Down
109 changes: 85 additions & 24 deletions backend/api/serializers/sales_submission_content.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from rest_framework.serializers import ModelSerializer, \
SerializerMethodField

from rest_framework.serializers import ModelSerializer, SerializerMethodField
from api.models.sales_submission_content import SalesSubmissionContent
from api.models.sales_submission_statuses import SalesSubmissionStatuses
from api.serializers.vehicle import VehicleMinSerializer
from api.serializers.icbc_registration_data import \
IcbcRegistrationDataSerializer
from api.serializers.icbc_registration_data import IcbcRegistrationDataSerializer
from api.serializers.record_of_sale import RecordOfSaleSerializer


Expand All @@ -16,43 +13,38 @@ class SalesSubmissionContentSerializer(ModelSerializer):
warnings = SerializerMethodField()

def get_icbc_verification(self, instance):
request = self.context.get('request')
request = self.context.get("request")
icbc_data = instance.icbc_verification

if request.user.is_government and icbc_data:
serializer = IcbcRegistrationDataSerializer(
icbc_data,
context={
'submission_id': instance.submission.id
}
icbc_data, context={"submission_id": instance.submission.id}
)
return serializer.data

return None

def get_record_of_sale(self, instance):
request = self.context.get('request')
request = self.context.get("request")
record_of_sale = instance.record_of_sale

if record_of_sale and (
request.user.is_government or
instance.submission.validation_status ==
SalesSubmissionStatuses.VALIDATED
request.user.is_government
or instance.submission.validation_status
== SalesSubmissionStatuses.VALIDATED
):
serializer = RecordOfSaleSerializer(
instance.record_of_sale, read_only=True
)
serializer = RecordOfSaleSerializer(instance.record_of_sale, read_only=True)

return serializer.data

return None

def get_vehicle(self, instance):
request = self.context.get('request')
request = self.context.get("request")

if instance.vehicle is not None:
serializer = VehicleMinSerializer(
instance.vehicle, read_only=True, context={'request': request}
instance.vehicle, read_only=True, context={"request": request}
)

return serializer.data
Expand All @@ -65,10 +57,79 @@ def get_warnings(self, instance):
class Meta:
model = SalesSubmissionContent
fields = (
'id', 'sales_date', 'vehicle', 'xls_make', 'xls_model',
'xls_model_year', 'xls_vin', 'record_of_sale', 'sales_date',
'warnings', 'icbc_verification', 'reason', 'update_timestamp'
"id",
"sales_date",
"vehicle",
"xls_make",
"xls_model",
"xls_model_year",
"xls_vin",
"record_of_sale",
"sales_date",
"warnings",
"icbc_verification",
"reason",
"update_timestamp",
)
read_only_fields = (
'id',
read_only_fields = ("id",)


class SalesSubmissionContentBulkSerializer(ModelSerializer):
icbc_verification = SerializerMethodField()
vehicle = SerializerMethodField()
warnings = SerializerMethodField()

def get_icbc_verification(self, instance):
request = self.context.get("request")
map_of_vins_to_icbc_data = self.context.get("warnings_and_maps").get(
"map_of_vins_to_icbc_data"
)
icbc_data = map_of_vins_to_icbc_data.get(instance.xls_vin)

if request.user.is_government and icbc_data is not None:
serializer = IcbcRegistrationDataSerializer(
icbc_data, context={"submission_id": instance.submission.id}
)
return serializer.data

return None

def get_vehicle(self, instance):
request = self.context.get("request")
map_of_sales_submission_content_ids_to_vehicles = self.context.get(
"warnings_and_maps"
).get("map_of_sales_submission_content_ids_to_vehicles")
vehicle = map_of_sales_submission_content_ids_to_vehicles.get(instance.id)
if vehicle is not None:
serializer = VehicleMinSerializer(
vehicle, read_only=True, context={"request": request}
)

return serializer.data

return None

def get_warnings(self, instance):
warnings_map = self.context.get("warnings_and_maps").get("warnings")
warnings_list = warnings_map.get(instance.id)
if warnings_list is None:
return []
return warnings_list

class Meta:
model = SalesSubmissionContent
fields = (
"id",
"sales_date",
"vehicle",
"xls_make",
"xls_model",
"xls_model_year",
"xls_vin",
"sales_date",
"warnings",
"icbc_verification",
"reason",
"update_timestamp",
)
read_only_fields = ("id",)
Loading

0 comments on commit a8b80b2

Please sign in to comment.