Skip to content

Commit

Permalink
Tracking pull request to merge release-1.10.0 to main (#270)
Browse files Browse the repository at this point in the history
* update to 1.10.0

* itvr-404-417-405 (#274)

* feat: new text on rebate form (#273)

* First github action (#278)

* itvr-419--approval-email-changes (#276)

* itvr-419--approval-email-changes

* itvr-419--add-constants-file

* remove superuser and permissions for BA (#275)

* remove superuser and permissions for BA

* remove comments

* Add dispatch (#279)

* sync BCDK version with app version (#281)

* add timeout (#282)

* add inputs (#283)

* Gha try inputs 1.10.0 (#284)

* itvr-425-409-email-flags-and-approval-email-change (#280)

* itvr-425-409-email-flags-and-approval-email-change

* fix typo

* add env to branch

* update release branch name

* itvr-422--dob-inputs-change (#277)

* change-version-number-and-remove-run-once-code (#287)

* update-readme (#288)

* Add manual approval step (#285)

* split test and prod deployment

* update timeout and open deployment

* add Tim

* itvr-438--fix-cra-upload-error (#299)

Co-authored-by: tim738745 <[email protected]>
Co-authored-by: Alex Zorkin <[email protected]>
Co-authored-by: vibhiquartech <[email protected]>
  • Loading branch information
4 people authored Sep 13, 2022
1 parent 8ae77b7 commit e97d996
Show file tree
Hide file tree
Showing 25 changed files with 583 additions and 141 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
## For each release, the value of workflow name, branches and PR_NUMBER need to be adjusted accordingly

name: CI/CD ITVR release-1.10.0

on:
push:
branches: [ release-1.10.0 ]
workflow_dispatch:
workflow_call:

env:
## The pull request number of the Tracking pull request to merge the release branch to main
PR_NUMBER: 270
RELEASE_NAME: release-1.10.0

jobs:

## This is the CI job
build:

name: Build ITVR on Openshift
runs-on: ubuntu-latest
timeout-minutes: 60

steps:

## it will checkout to /home/runner/work/itvr/itvr
- name: Check out repository
uses: actions/checkout@v2

## Log in to Openshift with a token of service account
- name: Log in to Openshift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
insecure_skip_tls_verify: true
namespace: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools

## Run build on Openshift
- name: Run build
run: |
cd .pipeline
npm install
npm run build -- --pr=${{ env.PR_NUMBER }} --env=build
deploy-on-test:

name: Deploy ITVR on Test Environment
runs-on: ubuntu-latest
timeout-minutes: 240
needs: build

steps:

## it will checkout to /home/runner/work/itvr/itvr
- name: Check out repository
uses: actions/checkout@v2

- name: Log in to Openshift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
insecure_skip_tls_verify: true
namespace: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools

- name: Ask for approval for ITVR Test deployment
uses: trstringer/[email protected]
with:
secret: ${{ github.TOKEN }}
approvers: AlexZorkin,emi-hi,tim738745,vibhiquartech,kuanfandevops
minimum-approvals: 1
issue-title: "ITVR ${{ env.RELEASE_NAME }} Test Deployment"
timeout-minutes: 240

- name: Run BCDK deployment on ITVR Test environment
run: |
cd .pipeline
echo "Deploying ITVR ${{ env.RELEASE_NAME }} on Test"
npm install
npm run deploy -- --pr=${{ env.PR_NUMBER }} --env=test
deploy-on-prod:

name: Deploy ITVR on Prod Environment
runs-on: ubuntu-latest
timeout-minutes: 2880
needs: deploy-on-test

steps:

## it will checkout to /home/runner/work/itvr/itvr
- name: Check out repository
uses: actions/checkout@v2

- name: Log in to Openshift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
insecure_skip_tls_verify: true
namespace: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools

- name: Ask for approval for ITVR Prod deployment
uses: trstringer/[email protected]
with:
secret: ${{ github.TOKEN }}
approvers: AlexZorkin,kuanfandevops,tim738745
minimum-approvals: 2
issue-title: "ITVR ${{ env.RELEASE_NAME }} Prod Deployment"
timeout-minutes: 2880

- name: Run BCDK deployment on ITVR Test environment
run: |
cd .pipeline
echo "Deploying ITVR ${{ env.RELEASE_NAME }} on Prod"
npm install
npm run deploy -- --pr=${{ env.PR_NUMBER }} --env=prod
5 changes: 4 additions & 1 deletion .pipeline/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const options= require('@bcgov/pipeline-cli').Util.parseArguments()
const changeId = options.pr //aka pull-request
const version = '1.0.0'
const version = '1.10.0'
const name = 'itvr'
const ocpName = 'apps.silver.devops'

Expand All @@ -27,6 +27,9 @@ Set the limit as two times of request
electric-vehicle-rebates.gov.bc.ca
*/
options.git.owner='bcgov'
//Have to set options.git.repository to be itvr otherwise an error will be thrown as the label github-repo
//will contain https://github.com/bcgov/itvr which is not allowed as a valid label
options.git.repository='itvr'

const phases = {

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,7 @@ python manage.py test

or to run specific test files, point to the folder or file
python manage.py test api.services.tests.test_calculate_rebate

### Scheduled Jobs

Currently, when the task-queue application starts, it creates scheduled jobs only if those jobs don't already exist in the database. This means that if some aspects of a job are changed (e.g. its arguments concerning timeout time, etc), one has to delete the job first in the admin console before deploying, or update the job manually in the admin console after deploying. This is an open issue, see: https://apps.nrs.gov.bc.ca/int/jira/browse/ZELDA-436
50 changes: 50 additions & 0 deletions django/api/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin
from .models.go_electric_rebate_application import (
GoElectricRebateApplication,
GoElectricRebateApplicationWithFailedEmail,
SearchableGoElectricRebateApplication,
SubmittedGoElectricRebateApplication,
CancellableGoElectricRebateApplication,
Expand Down Expand Up @@ -84,6 +85,8 @@ class SubmittedGoElectricRebateApplicationAdmin(admin.ModelAdmin):
"consent_personal",
"consent_tax",
"is_legacy",
"confirmation_email_success",
"spouse_email_success",
)

def get_queryset(self, request):
Expand Down Expand Up @@ -159,6 +162,8 @@ class CancellableGoElectricRebateApplicationAdmin(admin.ModelAdmin):
"date_of_birth",
"tax_year",
"is_legacy",
"confirmation_email_success",
"spouse_email_success",
)

def get_queryset(self, request):
Expand Down Expand Up @@ -223,6 +228,8 @@ class SearchableGoElectricRebateApplicationAdmin(admin.ModelAdmin):
"consent_personal",
"consent_tax",
"is_legacy",
"confirmation_email_success",
"spouse_email_success",
)

def get_queryset(self, request):
Expand All @@ -233,3 +240,46 @@ def has_delete_permission(self, request, obj=None):

def get_inlines(self, request, obj=None):
return get_inlines(obj)


@admin.register(GoElectricRebateApplicationWithFailedEmail)
class GoElectricRebateApplicationWithFailedEmailAdmin(admin.ModelAdmin):
actions = None
search_fields = ["drivers_licence", "id", "status"]
exclude = (
"sin",
"doc1",
"doc2",
"user",
"tax_year",
"consent_personal",
"consent_tax",
"is_legacy",
)
readonly_fields = (
"id",
"last_name",
"first_name",
"middle_names",
"status",
"email",
"user_is_bcsc",
"address",
"city",
"postal_code",
"drivers_licence",
"date_of_birth",
"application_type",
"doc1_tag",
"doc2_tag",
"confirmation_email_success",
"spouse_email_success",
)

def get_queryset(self, request):
return GoElectricRebateApplication.objects.filter(
Q(confirmation_email_success=False) | Q(spouse_email_success=False)
)

def has_delete_permission(self, request, obj=None):
return False
2 changes: 0 additions & 2 deletions django/api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ def ready(self):
schedule_get_ncda_redeemed_rebates,
schedule_cancel_untouched_household_applications,
schedule_expire_expired_applications,
schedule_send_mass_approval_email_once,
)

if settings.RUN_JOBS and "qcluster" in sys.argv:
schedule_send_rebates_to_ncda()
schedule_get_ncda_redeemed_rebates()
schedule_cancel_untouched_household_applications()
schedule_expire_expired_applications()
schedule_send_mass_approval_email_once()


class ITVRAdminConfig(AdminConfig):
Expand Down
28 changes: 28 additions & 0 deletions django/api/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from enum import Enum

# for each income tested maximum rebate ($4000, $2000, $1000), there are different rebate levels for certain ZEV types and lease terms
class FOUR_THOUSAND_REBATE(Enum):
ZEV_MAX = 4000
ZEV_MID = 2688
ZEV_MIN = 1332
PHEV_MAX = 2000
PHEV_MID = 1334
PHEV_MIN = 666


class TWO_THOUSAND_REBATE(Enum):
ZEV_MAX = 2000
ZEV_MID = 1334
ZEV_MIN = 666
PHEV_MAX = 1000
PHEV_MID = 667
PHEV_MIN = 333


class ONE_THOUSAND_REBATE(Enum):
ZEV_MAX = 1000
ZEV_MID = 667
ZEV_MIN = 333
PHEV_MAX = 500
PHEV_MID = 334
PHEV_MIN = 167
18 changes: 18 additions & 0 deletions django/api/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# django_q hooks


from api.models.go_electric_rebate_application import GoElectricRebateApplication


def set_email_status(task):
func = task.func
application_id = task.args[1]
email_successful = task.success
if func == "api.tasks.send_individual_confirm":
GoElectricRebateApplication.objects.filter(pk=application_id).update(
confirmation_email_success=email_successful
)
elif task.func == "api.tasks.send_spouse_initial_message":
GoElectricRebateApplication.objects.filter(pk=application_id).update(
spouse_email_success=email_successful
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.1 on 2022-08-25 17:44

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0010_alter_cancellablegoelectricrebateapplication_options_and_more'),
]

operations = [
migrations.AddField(
model_name='goelectricrebateapplication',
name='approval_email_sent',
field=models.BooleanField(null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 4.0.1 on 2022-09-06 17:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0011_goelectricrebateapplication_approval_email_sent'),
]

operations = [
migrations.CreateModel(
name='GoElectricRebateApplicationWithFailedEmail',
fields=[
],
options={
'ordering': ['-created'],
'proxy': True,
'indexes': [],
'constraints': [],
},
bases=('api.goelectricrebateapplication',),
),
migrations.RemoveField(
model_name='goelectricrebateapplication',
name='approval_email_sent',
),
migrations.AddField(
model_name='goelectricrebateapplication',
name='confirmation_email_success',
field=models.BooleanField(null=True),
),
migrations.AddField(
model_name='goelectricrebateapplication',
name='spouse_email_success',
field=models.BooleanField(null=True),
),
]
16 changes: 16 additions & 0 deletions django/api/models/go_electric_rebate_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class Status(TextChoices):
)
date_of_birth = DateField(validators=[validate_driving_age], null=True)
tax_year = IntegerField(null=True)
confirmation_email_success = BooleanField(null=True)
spouse_email_success = BooleanField(null=True)
doc1 = ImageField(
upload_to="docs",
blank=True,
Expand Down Expand Up @@ -249,3 +251,17 @@ def admin_label(cls):
@classproperty
def admin_hide_view_change_buttons(cls):
return True


class GoElectricRebateApplicationWithFailedEmail(GoElectricRebateApplication):
class Meta:
proxy = True
ordering = ["-created"]

@classproperty
def admin_label(cls):
return "Applications with failed emails"

@classproperty
def admin_hide_view_change_buttons(cls):
return True
Loading

0 comments on commit e97d996

Please sign in to comment.