Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking pull request to merge release-1.21.0 to main #590

Merged
merged 5 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dev-cicd.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-build.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: ITVR release-1.20.0
name: ITVR release-1.21.0

on:
workflow_dispatch:
inputs:
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 }}
Expand Down
2 changes: 1 addition & 1 deletion chart/itvr-apps/charts/itvr-frontend/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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


2 changes: 1 addition & 1 deletion chart/itvr-apps/charts/itvr-frontend/values-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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


8 changes: 6 additions & 2 deletions django/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions django/api/serializers/application_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
32 changes: 32 additions & 0 deletions django/api/services/go_electric_rebate_application.py
Original file line number Diff line number Diff line change
@@ -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()
)
17 changes: 2 additions & 15 deletions django/api/viewsets/application_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"})
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.20.0",
"version": "1.21.0",
"private": true,
"dependencies": {
"@date-io/date-fns": "^2.14.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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

25 changes: 0 additions & 25 deletions openshift/templates/knp-for-helm-deployment/knp-env-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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