diff --git a/.github/workflows/dev-cicd.yaml b/.github/workflows/dev-cicd.yaml index b9ed91ad..0cc2021b 100644 --- a/.github/workflows/dev-cicd.yaml +++ b/.github/workflows/dev-cicd.yaml @@ -1,6 +1,6 @@ ## For each release, the value of workflow name, branches and PR_NUMBER need to be adjusted accordingly -name: ITVR Dev release-1.20.0 +name: ITVR Dev release-1.21.0 on: pull_request: diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index 45d5788a..595e22fa 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -1,4 +1,4 @@ -name: ITVR release-1.20.0 +name: ITVR release-1.21.0 on: workflow_dispatch: @@ -6,11 +6,11 @@ on: pull_request: description: 'Tracking pull request number' required: true - default: 583 + default: 590 release_branch: description: 'The name of the release branch' required: true - default: release-1.20.0 + default: release-1.21.0 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/chart/itvr-apps/charts/itvr-frontend/values-dev.yaml b/chart/itvr-apps/charts/itvr-frontend/values-dev.yaml index c1897a50..3f0cd109 100644 --- a/chart/itvr-apps/charts/itvr-frontend/values-dev.yaml +++ b/chart/itvr-apps/charts/itvr-frontend/values-dev.yaml @@ -31,7 +31,7 @@ frontend: reactAppBCeIDKeycloakClientId: itvr-on-gold-cluster-3972 reactAppBCeIDKeycloakRealm: standard reactAppBCeIDKeycloakUrl: https://dev.loginproxy.gov.bc.ca/auth/ - snowplowCollector: spm.apps.gov.bc.ca + snowplowCollector: createFrontendRoute: true diff --git a/chart/itvr-apps/charts/itvr-frontend/values-test.yaml b/chart/itvr-apps/charts/itvr-frontend/values-test.yaml index b388b226..d234a0f7 100644 --- a/chart/itvr-apps/charts/itvr-frontend/values-test.yaml +++ b/chart/itvr-apps/charts/itvr-frontend/values-test.yaml @@ -31,7 +31,7 @@ frontend: reactAppBCeIDKeycloakClientId: itvr-on-gold-cluster-3972 reactAppBCeIDKeycloakRealm: standard reactAppBCeIDKeycloakUrl: https://test.loginproxy.gov.bc.ca/auth/ - snowplowCollector: spm.apps.gov.bc.ca + snowplowCollector: createFrontendRoute: true diff --git a/django/api/admin.py b/django/api/admin.py index 1ff17f59..7f74f813 100644 --- a/django/api/admin.py +++ b/django/api/admin.py @@ -16,6 +16,7 @@ from django.db import transaction from api.services.ncda import delete_rebate, update_rebate from django_q.tasks import async_task +from api.services.go_electric_rebate_application import equivalent_drivers_licence_number_found class ITVRModelAdmin(admin.ModelAdmin): @@ -410,14 +411,17 @@ def change_view(self, request, object_id, form_url="", extra_context=None): def response_change(self, request, obj): ret = super().response_change(request, obj) if "edit_drivers_licence" in request.POST: + new_dl = obj.drivers_licence + if equivalent_drivers_licence_number_found(new_dl, obj.id): + raise Exception rebates = list(GoElectricRebate.objects.filter(application__id=obj.id)) if len(rebates) == 1: rebate = rebates[0] ncda_id = rebate.ncda_id - rebate.drivers_licence = obj.drivers_licence + rebate.drivers_licence = new_dl rebate.save() if ncda_id is not None: - update_rebate(ncda_id, {"Title": obj.drivers_licence}) + update_rebate(ncda_id, {"Title": new_dl}) elif len(rebates) > 1: raise Exception return ret diff --git a/django/api/serializers/application_form.py b/django/api/serializers/application_form.py index 8fdc1d27..4c794837 100644 --- a/django/api/serializers/application_form.py +++ b/django/api/serializers/application_form.py @@ -4,6 +4,8 @@ from datetime import date from rest_framework.response import Response from rest_framework import status +from api.services.go_electric_rebate_application import equivalent_drivers_licence_number_found +from rest_framework.serializers import ValidationError class ApplicationFormCreateSerializer(ModelSerializer): @@ -23,6 +25,11 @@ def _get_tax_year(self): if month < 7: return year - 2 return year - 1 + + def validate_drivers_licence(self, value): + if equivalent_drivers_licence_number_found(value): + raise ValidationError("Equivalent DL# exists.") + return value class ApplicationFormCreateSerializerDefault(ApplicationFormCreateSerializer): diff --git a/django/api/services/go_electric_rebate_application.py b/django/api/services/go_electric_rebate_application.py new file mode 100644 index 00000000..76bb9f72 --- /dev/null +++ b/django/api/services/go_electric_rebate_application.py @@ -0,0 +1,32 @@ +from api.models.go_electric_rebate_application import GoElectricRebateApplication +from django.db.models import Q + + +def equivalent_drivers_licence_number_found( + drivers_licence_number, application_id=None +): + equivalent_dl = drivers_licence_number + if len(drivers_licence_number) == 7: + equivalent_dl = "0" + drivers_licence_number + elif len(drivers_licence_number) == 8 and drivers_licence_number.startswith("0"): + equivalent_dl = drivers_licence_number[1:] + exclude_lookup = {} + if application_id is not None: + exclude_lookup["id"] = application_id + return ( + GoElectricRebateApplication.objects.filter( + Q(drivers_licence__exact=drivers_licence_number) + | Q(drivers_licence__exact=equivalent_dl) + ) + .filter( + status__in=[ + GoElectricRebateApplication.Status.SUBMITTED, + GoElectricRebateApplication.Status.HOUSEHOLD_INITIATED, + GoElectricRebateApplication.Status.VERIFIED, + GoElectricRebateApplication.Status.APPROVED, + GoElectricRebateApplication.Status.REDEEMED, + ] + ) + .exclude(**exclude_lookup) + .exists() + ) diff --git a/django/api/viewsets/application_form.py b/django/api/viewsets/application_form.py index 8c312848..2ae19c19 100644 --- a/django/api/viewsets/application_form.py +++ b/django/api/viewsets/application_form.py @@ -11,6 +11,7 @@ ApplicationFormSpouseSerializer, ) from api.models.go_electric_rebate_application import GoElectricRebateApplication +from api.services.go_electric_rebate_application import equivalent_drivers_licence_number_found class ApplicationFormViewset( @@ -65,21 +66,7 @@ def household(self, request, pk=None): @action(detail=False, methods=["GET"], url_path="check_status") def check_status(self, request, pk=None): drivers_licence = request.query_params.get("drivers_license", None) - dl_not_valid = ( - GoElectricRebateApplication.objects.filter( - drivers_licence__exact=drivers_licence - ) - .filter( - status__in=[ - GoElectricRebateApplication.Status.SUBMITTED, - GoElectricRebateApplication.Status.HOUSEHOLD_INITIATED, - GoElectricRebateApplication.Status.VERIFIED, - GoElectricRebateApplication.Status.APPROVED, - GoElectricRebateApplication.Status.REDEEMED, - ] - ) - .exists() - ) + dl_not_valid = equivalent_drivers_licence_number_found(drivers_licence) if dl_not_valid: return Response({"drivers_license_valid": "false"}) diff --git a/frontend/package.json b/frontend/package.json index 0fda4b29..29b518a7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "1.20.0", + "version": "1.21.0", "private": true, "dependencies": { "@date-io/date-fns": "^2.14.0", diff --git a/openshift/templates/knp-for-helm-deployment/knp-env-metabase-dev.yaml b/openshift/templates/knp-for-helm-deployment/knp-env-metabase-dev.yaml new file mode 100644 index 00000000..f4b467f9 --- /dev/null +++ b/openshift/templates/knp-for-helm-deployment/knp-env-metabase-dev.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: allow-spilo-accepts-metabase +spec: + ## Allow spilo to accept communication from metabase + podSelector: + matchLabels: + app.kubernetes.io/instance: itvr-spilo-dev + app.kubernetes.io/name: spilo + ingress: + - ports: + - protocol: TCP + port: 5432 + from: + - namespaceSelector: + matchLabels: + environment: dev + name: 30b186 + - podSelector: + matchLabels: + app: metabase + policyTypes: + - Ingress + \ No newline at end of file diff --git a/openshift/templates/knp-for-helm-deployment/knp-env-metabase-prod.yaml b/openshift/templates/knp-for-helm-deployment/knp-env-metabase-prod.yaml new file mode 100644 index 00000000..7dd1257a --- /dev/null +++ b/openshift/templates/knp-for-helm-deployment/knp-env-metabase-prod.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: allow-spilo-accepts-metabase +spec: + ## Allow spilo to accept communication from metabase + podSelector: + matchLabels: + app.kubernetes.io/instance: itvr-spilo + app.kubernetes.io/name: spilo + ingress: + - ports: + - protocol: TCP + port: 5432 + from: + - namespaceSelector: + matchLabels: + environment: prod + name: 30b186 + - podSelector: + matchLabels: + app: metabase + policyTypes: + - Ingress + \ No newline at end of file diff --git a/openshift/templates/knp-for-helm-deployment/knp-env-metabase-test.yaml b/openshift/templates/knp-for-helm-deployment/knp-env-metabase-test.yaml new file mode 100644 index 00000000..2994d147 --- /dev/null +++ b/openshift/templates/knp-for-helm-deployment/knp-env-metabase-test.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: allow-spilo-accepts-metabase +spec: + ## Allow spilo to accept communication from metabase + podSelector: + matchLabels: + app.kubernetes.io/instance: itvr-spilo + app.kubernetes.io/name: spilo + ingress: + - ports: + - protocol: TCP + port: 5432 + from: + - namespaceSelector: + matchLabels: + environment: test + name: 30b186 + - podSelector: + matchLabels: + app: metabase + policyTypes: + - Ingress + \ No newline at end of file diff --git a/openshift/templates/knp-for-helm-deployment/knp-env-pr.yaml b/openshift/templates/knp-for-helm-deployment/knp-env-pr.yaml index c17e87bc..b02cf5cf 100644 --- a/openshift/templates/knp-for-helm-deployment/knp-env-pr.yaml +++ b/openshift/templates/knp-for-helm-deployment/knp-env-pr.yaml @@ -89,28 +89,3 @@ objects: ports: - protocol: TCP port: 3310 - - apiVersion: networking.k8s.io/v1 - kind: NetworkPolicy - metadata: - name: allow-spilo-accepts-metabase - spec: - ## Allow spilo to accept communication from metabase - podSelector: - matchLabels: - app.kubernetes.io/instance: itvr-spilo - app.kubernetes.io/name: spilo - ingress: - - ports: - - protocol: TCP - port: 5432 - from: - - namespaceSelector: - matchLabels: - environment: ${ENVIRONMENT} - name: 30b186 - - podSelector: - matchLabels: - app: metabase - policyTypes: - - Ingress - \ No newline at end of file