-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tracking pull request to pull release-1.26.0 to master (#686)
- Loading branch information
1 parent
d25511f
commit 2a9b961
Showing
94 changed files
with
4,335 additions
and
1,141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,58 @@ | ||
'use strict'; | ||
const {OpenShiftClientX} = require('@bcgov/pipeline-cli') | ||
const path = require('path'); | ||
"use strict"; | ||
const { OpenShiftClientX } = require("@bcgov/pipeline-cli"); | ||
const path = require("path"); | ||
|
||
module.exports = (settings)=>{ | ||
const phases=settings.phases | ||
const options = settings.options | ||
const oc=new OpenShiftClientX(Object.assign({'namespace':phases.build.namespace}, options)); | ||
const phase='build' | ||
var objects = [] | ||
module.exports = (settings) => { | ||
const phases = settings.phases; | ||
const options = settings.options; | ||
const oc = new OpenShiftClientX( | ||
Object.assign({ namespace: phases.build.namespace }, options) | ||
); | ||
const phase = "build"; | ||
var objects = []; | ||
|
||
const templatesLocalBaseUrl =oc.toFileUrl(path.resolve(__dirname, '../../openshift')) | ||
const templatesLocalBaseUrl = oc.toFileUrl( | ||
path.resolve(__dirname, "../../openshift") | ||
); | ||
|
||
objects.push(...oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/build-master.yaml`, { | ||
'param':{ | ||
'NAME': phases[phase].name, | ||
'SUFFIX': phases[phase].suffix, | ||
'VERSION': phases[phase].tag, | ||
'SOURCE_REPOSITORY_URL': oc.git.http_url, | ||
'SOURCE_REPOSITORY_REF': oc.git.ref, | ||
'SOURCE_IMAGE_STREAM_NAMESPACE': phases[phase].namespace, | ||
'SOURCE_IMAGE_STREAM_TAG': 'bcgov-jenkins-basic:v2-20210308' | ||
} | ||
})); | ||
objects.push( | ||
...oc.processDeploymentTemplate( | ||
`${templatesLocalBaseUrl}/build-master.yaml`, | ||
{ | ||
param: { | ||
NAME: phases[phase].name, | ||
SUFFIX: phases[phase].suffix, | ||
VERSION: phases[phase].tag, | ||
SOURCE_REPOSITORY_URL: oc.git.http_url, | ||
SOURCE_REPOSITORY_REF: oc.git.ref, | ||
SOURCE_IMAGE_STREAM_NAMESPACE: phases[phase].namespace, | ||
SOURCE_IMAGE_STREAM_TAG: "bcgov-jenkins-basic:v2-20210520", | ||
}, | ||
} | ||
) | ||
); | ||
|
||
objects.push(...oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/build-slave.yaml`, { | ||
'param':{ | ||
'NAME': phases[phase].name, | ||
'SUFFIX': phases[phase].suffix, | ||
'VERSION': phases[phase].tag, | ||
'SOURCE_IMAGE_STREAM_TAG': `${phases[phase].name}:${phases[phase].tag}`, | ||
'SLAVE_NAME':'main' | ||
} | ||
})); | ||
objects.push( | ||
...oc.processDeploymentTemplate( | ||
`${templatesLocalBaseUrl}/build-slave.yaml`, | ||
{ | ||
param: { | ||
NAME: phases[phase].name, | ||
SUFFIX: phases[phase].suffix, | ||
VERSION: phases[phase].tag, | ||
SOURCE_IMAGE_STREAM_TAG: `${phases[phase].name}:${phases[phase].tag}`, | ||
SLAVE_NAME: "main", | ||
}, | ||
} | ||
) | ||
); | ||
|
||
oc.applyRecommendedLabels(objects, phases[phase].name, phase, phases[phase].changeId, phases[phase].instance) | ||
oc.applyAndBuild(objects) | ||
} | ||
oc.applyRecommendedLabels( | ||
objects, | ||
phases[phase].name, | ||
phase, | ||
phases[phase].changeId, | ||
phases[phase].instance | ||
); | ||
oc.applyAndBuild(objects); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=bcgov_zeva&metric=alert_status)](https://sonarcloud.io/dashboard?id=bcgov_zeva) | ||
|
||
# Zero-Emission Vehicles | ||
Facilitates online Zero-Emission Vehicle (ZEV) sales reporting by regulated parties (automakers), plus issuance and transfer of ZEV credits. This is to support compliance with the ZEV Act regulations that require increasing sales of ZEVs to reduce GHG emissions from vehicles in the province. | ||
|
||
## License | ||
# Project Architecture | ||
The project is a typical we application, it has frontend, backend and database. | ||
* Frontend: Nodejs and React | ||
* Backend: Python and Django | ||
* Database: Postgresql 10 and Patroni | ||
* Object Storage: Minio | ||
* Application Monitoring: Nagios | ||
* Database Backup: [BackupContainer](https://github.com/BCDevOps/backup-container) | ||
* Cloud Platform: [Openshift](https://docs.openshift.com/container-platform/4.6/welcome/index.html) | ||
* Database Documentation: [SchemaSpy](http://schemaspy.org/) | ||
|
||
# Project Pipeline | ||
The project uses pull request based pipeline is supported by [BCDK](https://github.com/BCDevOps/bcdk) and follow the instructions at [here](https://github.com/bcgov/zeva/tree/release-1.26.0/openshift/README.md) to setup the pipeline. | ||
|
||
# Build and deploy | ||
## Application Setup on Openshift platforms | ||
* All templates are located under openshift/templates folder. | ||
* Follow the instructions [here](https://github.com/bcgov/zeva/tree/release-1.26.0/openshift/templates/README.md) to setup The application on Openshift. | ||
|
||
## CI/CD | ||
### Build and deploy in Jenkins | ||
Once Jenkins is up and running, it automatically builds pull requests and promote to dev, test and prod with confirmation. The Jenkins url can be found in Openshift under project's Networking->Routers. | ||
|
||
### Build and deploy in command line | ||
* Cd to .pipeline folder and run the following command line to build pull requests and deploy to environment. | ||
* $ npm run build -- --pr=pull-request-number --env=build | ||
* $ npm run deploy -- --pr=pull-request-number --env=dev/test/prod | ||
* When a pull request is closed or merged, all resources created for the pull request is removed by Jenkins automatically. They also can be remove the the following command. | ||
* $ npm run clean -- --pr=pull-request-number --env=build/dev/test/prod | ||
|
||
# License | ||
Code released under the [Apache License, Version 2.0](./LICENSE). |
29 changes: 29 additions & 0 deletions
29
backend/api/fixtures/operational/0030_update_signing_authority_assertions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.db import transaction | ||
|
||
from api.management.data_script import OperationalDataScript | ||
from api.models.signing_authority_assertion import SigningAuthorityAssertion | ||
|
||
|
||
class UpdateSigningAuthorityAssertions(OperationalDataScript): | ||
""" | ||
Update the assertions for the compliance report | ||
""" | ||
is_revertable = False | ||
comment = 'Update the assertions for the compliance report' | ||
|
||
def check_run_preconditions(self): | ||
return True | ||
|
||
def update_assertions(self): | ||
text = "I confirm this consumer ZEV sales information is complete and correct." | ||
assertion = SigningAuthorityAssertion.objects.get( | ||
module="consumer_sales") | ||
assertion.description = text | ||
assertion.save() | ||
|
||
@transaction.atomic | ||
def run(self): | ||
self.update_assertions() | ||
|
||
|
||
script_class = UpdateSigningAuthorityAssertions |
35 changes: 35 additions & 0 deletions
35
backend/api/fixtures/operational/0031_add_assessment_descriptions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from django.db import transaction | ||
|
||
from api.management.data_script import OperationalDataScript | ||
from api.models.model_year_report_assessment_descriptions import ModelYearReportAssessmentDescriptions | ||
|
||
|
||
class AddAssessmentDescriptions(OperationalDataScript): | ||
""" | ||
Adds the descriptions that will show up as radio options on the assessment | ||
page for idir users to select before recommending assessment | ||
""" | ||
is_revertable = False | ||
comment = 'Adds the vehicle makes found in the NRCAN document' | ||
|
||
def check_run_preconditions(self): | ||
return True | ||
|
||
@transaction.atomic | ||
def run(self): | ||
ModelYearReportAssessmentDescriptions.objects.create( | ||
description="{user.organization.name} has complied with section 10 (2) of the Zero-Emission Vehicles Act for the {modelYear} adjustment period.", | ||
display_order=0 | ||
) | ||
ModelYearReportAssessmentDescriptions.objects.create( | ||
description="Section 10 (3) does not apply as {user.organization.name} did not have a balance at the end of the compliance date for the previous model year that contained less than zero ZEV units of the same vehicle class and any ZEV class.", | ||
display_order=1 | ||
) | ||
ModelYearReportAssessmentDescriptions.objects.create( | ||
description="Section 10 (3) applies and {user.organization.name} is subject to an automatic administrative penalty As per section 26 of the Act the amount of the administrative penalty is:", | ||
display_order=2 | ||
|
||
) | ||
|
||
|
||
script_class = AddAssessmentDescriptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.0.7 on 2021-05-10 18:16 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0098_modelyearreportcomplianceobligation'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='modelyearreport', | ||
name='ldv_sales', | ||
field=models.IntegerField(null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='modelyearreportprevioussales', | ||
name='previous_sales', | ||
field=models.IntegerField(), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Generated by Django 3.0.14 on 2021-05-14 22:18 | ||
|
||
import db_comments.model_mixins | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0099_auto_20210510_1116'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='modelyearreportmake', | ||
name='from_gov', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name='modelyearreportprevioussales', | ||
name='from_gov', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.CreateModel( | ||
name='ModelYearReportAdjustment', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('create_timestamp', models.DateTimeField(auto_now_add=True, null=True)), | ||
('create_user', models.CharField(default='SYSTEM', max_length=130)), | ||
('update_timestamp', models.DateTimeField(auto_now=True, null=True)), | ||
('update_user', models.CharField(max_length=130, null=True)), | ||
('number_of_credits', models.IntegerField()), | ||
('is_reduction', models.BooleanField(default=False)), | ||
('credit_class', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='model_year_report_adjustments', to='api.CreditClass')), | ||
('model_year', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='model_year_report_adjustments', to='api.ModelYear')), | ||
('model_year_report', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='model_year_report_adjustments', to='api.ModelYearReport')), | ||
], | ||
options={ | ||
'db_table': 'model_year_report_adjustment', | ||
}, | ||
bases=(models.Model, db_comments.model_mixins.DBComments), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 3.0.14 on 2021-05-19 16:52 | ||
|
||
import db_comments.model_mixins | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0100_auto_20210514_1518'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ModelYearReportLDVSales', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('create_timestamp', models.DateTimeField(auto_now_add=True, null=True)), | ||
('create_user', models.CharField(default='SYSTEM', max_length=130)), | ||
('update_timestamp', models.DateTimeField(auto_now=True, null=True)), | ||
('update_user', models.CharField(max_length=130, null=True)), | ||
('ldv_sales', models.IntegerField()), | ||
('from_gov', models.BooleanField(default=False)), | ||
('model_year', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='api.ModelYear')), | ||
('model_year_report', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='api.ModelYearReport')), | ||
], | ||
options={ | ||
'db_table': 'model_year_report_ldv_sales', | ||
}, | ||
bases=(models.Model, db_comments.model_mixins.DBComments), | ||
), | ||
migrations.DeleteModel( | ||
name='ModelYearReportPreviousSales', | ||
), | ||
] |
67 changes: 67 additions & 0 deletions
67
...eportassessment_modelyearreportassessmentcomment_modelyearreportassessmentdescriptions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Generated by Django 3.0.3 on 2021-05-21 15:50 | ||
|
||
import db_comments.model_mixins | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0101_auto_20210519_0952'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ModelYearReportAssessmentDescriptions', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('create_timestamp', models.DateTimeField(auto_now_add=True, null=True)), | ||
('create_user', models.CharField(default='SYSTEM', max_length=130)), | ||
('update_timestamp', models.DateTimeField(auto_now=True, null=True)), | ||
('update_user', models.CharField(max_length=130, null=True)), | ||
('description', models.CharField(blank=True, db_column='assessment_description', max_length=4000, null=True)), | ||
], | ||
options={ | ||
'db_table': 'model_year_report_assessment_descriptions', | ||
'ordering': ['create_timestamp'], | ||
}, | ||
bases=(models.Model, db_comments.model_mixins.DBComments), | ||
), | ||
migrations.CreateModel( | ||
name='ModelYearReportAssessmentComment', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('create_timestamp', models.DateTimeField(auto_now_add=True, null=True)), | ||
('create_user', models.CharField(default='SYSTEM', max_length=130)), | ||
('update_timestamp', models.DateTimeField(auto_now=True, null=True)), | ||
('update_user', models.CharField(max_length=130, null=True)), | ||
('to_director', models.BooleanField(default=False)), | ||
('comment', models.CharField(blank=True, db_column='assessment_comment', max_length=4000, null=True)), | ||
('model_year_report', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='model_year_report_assessment_comments', to='api.ModelYearReport')), | ||
], | ||
options={ | ||
'db_table': 'model_year_report_assessment_comment', | ||
'ordering': ['create_timestamp'], | ||
}, | ||
bases=(models.Model, db_comments.model_mixins.DBComments), | ||
), | ||
migrations.CreateModel( | ||
name='ModelYearReportAssessment', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('create_timestamp', models.DateTimeField(auto_now_add=True, null=True)), | ||
('create_user', models.CharField(default='SYSTEM', max_length=130)), | ||
('update_timestamp', models.DateTimeField(auto_now=True, null=True)), | ||
('update_user', models.CharField(max_length=130, null=True)), | ||
('penalty', models.DecimalField(decimal_places=2, max_digits=20, null=True)), | ||
('model_year_report', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='model_year_report_assessment', to='api.ModelYearReport')), | ||
('model_year_report_assessment_description', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='api.ModelYearReportAssessmentDescriptions')), | ||
], | ||
options={ | ||
'db_table': 'model_year_report_assessment', | ||
'ordering': ['create_timestamp'], | ||
}, | ||
bases=(models.Model, db_comments.model_mixins.DBComments), | ||
), | ||
] |
17 changes: 17 additions & 0 deletions
17
backend/api/migrations/0103_remove_modelyearreport_ldv_sales.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 3.0.14 on 2021-05-19 17:22 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0102_modelyearreportassessment_modelyearreportassessmentcomment_modelyearreportassessmentdescriptions'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='modelyearreport', | ||
name='ldv_sales', | ||
), | ||
] |
Oops, something went wrong.