Skip to content

Commit

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

* udpate pr number

* fix - adds is_government to basic user serializer (#2276)

* Oct 1 2024 stuff  -- build-on-dev (#2226)

* feat: 2207 - sales forecast (#2211)

* initial commit

* small change

* sales forecast backend

* feat: 2204 and 2209 - sales forecast (#2218)

* feat: 2204 and 2209 = sales forecast

* some changes

* wording changes

* some changes

* oct 1 stuff - spreadsheet column name changes (#2225)

* address codeQL-raised issue

* Task: Frontend Spreadsheet Record Validation #2220 (#2228)

* Frontend validation for SalesForecastRecord records.

* Fixing casing

* Cleanup

* feat: 2219 - forecast report column mapping + automatic summation of ZEVs supplied (#2231)

* feat: 2219 - forecast report colum mapping + automatic summation of ZEVs supplied

* small change

* fix totals display upon discard of records

* feat: 2221 - some styling (#2236)

* Task: Sales Forecast Report Checkbox Assertion #2222 (#2232)

* Adding new signing authority assertion for Sales Forecast

* Cleaning up

* wording changes

* formatting

* fix: amend download() function to take into account case where content-disposition is not an exposed header

* update template

* spreadsheet validation updates

* spreadsheet validation cleanup

* Added message for a successful or unsuccessful upload (#2278)

Co-authored-by: julianforeman <[email protected]>

* cleanup

---------

Co-authored-by: JulianForeman <[email protected]>
Co-authored-by: julianforeman <[email protected]>

* fix: comment edit (#2277)

* fix: adds context to update comment

* chore: removes extra spaces

---------

Co-authored-by: Emily <[email protected]>
Co-authored-by: tim738745 <[email protected]>
Co-authored-by: JulianForeman <[email protected]>
Co-authored-by: julianforeman <[email protected]>
  • Loading branch information
5 people authored Oct 1, 2024
1 parent c46d85a commit 73c61fa
Show file tree
Hide file tree
Showing 37 changed files with 1,075 additions and 78 deletions.
28 changes: 11 additions & 17 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.60.0
name: Dev Build 1.61.0

on:
push:
branches: [ release-1.60.0 ]
branches: [release-1.61.0]
paths:
- frontend/**
- backend/**
Expand All @@ -14,35 +14,31 @@ on:

env:
## The pull request number of the Tracking pull request to merge the release branch to main
PR_NUMBER: 2190
VERSION: 1.60.0
GIT_URL: https://github.com/bcgov/zeva.git
PR_NUMBER: 2270
VERSION: 1.61.0
GIT_URL: https://github.com/bcgov/zeva.git
TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev
TEST_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-test
PROD_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-prod


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

jobs:
call-unit-test:
uses: ./.github/workflows/unit-test-template.yaml
with:
pr-number: 2190
pr-number: 2270

build:

name: Build ZEVA on Openshift
runs-on: ubuntu-latest
timeout-minutes: 60
needs: call-unit-test

steps:

- name: Check out repository
uses: actions/checkout@v3

Expand All @@ -67,14 +63,12 @@ jobs:
oc start-build --wait=true zeva-frontend-build-${{ env.PR_NUMBER }}
deploy-on-dev:

name: Deploy ZEVA on Dev
runs-on: ubuntu-latest
timeout-minutes: 60
needs: build

steps:

steps:
- name: Check out repository
uses: actions/checkout@v3
with:
Expand All @@ -86,8 +80,8 @@ jobs:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
insecure_skip_tls_verify: true
namespace: ${{ env.TOOLS_NAMESPACE }}
namespace: ${{ env.TOOLS_NAMESPACE }}

- name: Tag Frontend Image from tools to dev
run: |
oc tag ${{ env.TOOLS_NAMESPACE }}/zeva-frontend:build-${{ env.VERSION }}-${{ env.PR_NUMBER }} ${{ env.DEV_NAMESPACE }}/zeva-frontend:dev-${{ env.VERSION }}
Expand All @@ -106,7 +100,7 @@ jobs:
echo "zeva-frontend-dev release does not exist"
helm install --set frontendImageTagname=dev-${{ env.VERSION }},openshiftLicensePlate=${{ secrets.OPENSHIFT_NAMESPACE_PLATE }} -n ${{ env.DEV_NAMESPACE }} -f ./values-dev.yaml zeva-frontend-dev .
fi
# helm status will show an error if the helm release doesn't exist. The error will be ignored.
- name: Deply zeva-backend on Dev
shell: bash {0}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dev-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
## For each release, the value of workflow name, branches and VERSION need to be adjusted accordingly

name: Zeva new-pipeline-1.60.0 Dev CI
name: Zeva new-pipeline-1.61.0 Dev CI

on:
# push:
# branches: [ new-pipeline-1.60.0 ]
# branches: [ new-pipeline-1.61.0 ]
# paths:
# - frontend/**
# - backend/**
workflow_dispatch:

env:
VERSION: 1.60.0
VERSION: 1.61.0
GIT_URL: https://github.com/bcgov/zeva.git
TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev
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.60.0
name: Release Build 1.61.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: 2190
VERSION: 1.60.0
PR_NUMBER: 2270
VERSION: 1.61.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 @@ -25,7 +25,7 @@ jobs:
call-unit-test:
uses: ./.github/workflows/unit-test-template.yaml
with:
pr-number: 2190
pr-number: 2270

build:
name: Build ZEVA on Openshift
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## For each release, the value of workflow name, branches and VERSION need to be adjusted accordingly

name: ZEVA new-pipeline-1.60.0 Test CI
name: ZEVA new-pipeline-1.61.0 Test CI

on:
workflow_dispatch:

env:
VERSION: 1.60.0
VERSION: 1.61.0
GIT_URL: https://github.com/bcgov/zeva.git
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev
TEST_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-test
Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions backend/api/constants/zev_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from enum import Enum, unique


@unique
class ZEV_TYPE(Enum):
BEV = "BEV"
PHEV = "PHEV"
FCEV = "FCEV"
EREV = "EREV"
65 changes: 65 additions & 0 deletions backend/api/migrations/0007_auto_20240821_1401.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Generated by Django 3.2.25 on 2024-08-21 21:01

import api.constants.zev_type
import db_comments.model_mixins
from django.db import migrations, models
import django.db.models.deletion
import enumfields.fields


class Migration(migrations.Migration):

dependencies = [
('api', '0006_auto_20240508_1553'),
]

operations = [
migrations.CreateModel(
name='SalesForecast',
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)),
('ice_vehicles_one', models.IntegerField(blank=True, null=True)),
('ice_vehicles_two', models.IntegerField(blank=True, null=True)),
('ice_vehicles_three', models.IntegerField(blank=True, null=True)),
('zev_vehicles_one', models.IntegerField(blank=True, null=True)),
('zev_vehicles_two', models.IntegerField(blank=True, null=True)),
('zev_vehicles_three', models.IntegerField(blank=True, null=True)),
],
options={
'db_table': 'sales_forecast',
},
bases=(models.Model, db_comments.model_mixins.DBComments),
),
migrations.CreateModel(
name='SalesForecastRecord',
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)),
('model_year', models.CharField(max_length=4)),
('make', models.CharField(max_length=250)),
('model_name', models.CharField(max_length=250)),
('type', enumfields.fields.EnumField(enum=api.constants.zev_type.ZEV_TYPE, max_length=10)),
('range', models.DecimalField(decimal_places=2, max_digits=20)),
('zev_class', models.CharField(max_length=1)),
('vehicle_class_interior_volume', models.CharField(max_length=250)),
('total_supplied', models.IntegerField()),
('sales_forecast', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.salesforecast')),
],
options={
'db_table': 'sales_forecast_record',
},
bases=(models.Model, db_comments.model_mixins.DBComments),
),
migrations.AddField(
model_name='salesforecast',
name='model_year_report',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.modelyearreport', unique=True),
),
]
21 changes: 21 additions & 0 deletions backend/api/migrations/0008_auto_20240828_1034.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.db import migrations, models

def add_sales_forecast_authority_assertion(apps, schema_editor):
SigningAuthorityAssertion = apps.get_model('api', 'SigningAuthorityAssertion')

SigningAuthorityAssertion.objects.get_or_create(
description="I confirm that the Forecast Report is complete.",
display_order=8,
effective_date="2020-01-01",
module="consumer_sales"
)

class Migration(migrations.Migration):

dependencies = [
('api', '0007_auto_20240821_1401'), # Replace with the name of the previous migration file
]

operations = [
migrations.RunPython(add_sales_forecast_authority_assertion),
]
2 changes: 2 additions & 0 deletions backend/api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@
from . import supplemental_report_history
from . import supplemental_report_statuses
from . import icbc_snapshot_data
from . import sales_forecast
from . import sales_forecast_record
26 changes: 26 additions & 0 deletions backend/api/models/sales_forecast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.db import models
from api.models.model_year_report import ModelYearReport
from auditable.models import Auditable


class SalesForecast(Auditable):
model_year_report = models.ForeignKey(
to=ModelYearReport, unique=True, on_delete=models.CASCADE
)

ice_vehicles_one = models.IntegerField(blank=True, null=True)

ice_vehicles_two = models.IntegerField(blank=True, null=True)

ice_vehicles_three = models.IntegerField(blank=True, null=True)

zev_vehicles_one = models.IntegerField(blank=True, null=True)

zev_vehicles_two = models.IntegerField(blank=True, null=True)

zev_vehicles_three = models.IntegerField(blank=True, null=True)

class Meta:
db_table = "sales_forecast"

db_table_comment = "Stores sales forecast information"
32 changes: 32 additions & 0 deletions backend/api/models/sales_forecast_record.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.db import models
from enumfields import EnumField
from api.models.sales_forecast import SalesForecast
from api.models.model_year import ModelYear
from api.models.credit_class import CreditClass
from api.constants.zev_type import ZEV_TYPE
from auditable.models import Auditable


class SalesForecastRecord(Auditable):
sales_forecast = models.ForeignKey(to=SalesForecast, on_delete=models.CASCADE)

model_year = models.CharField(max_length=4)

make = models.CharField(max_length=250)

model_name = models.CharField(max_length=250)

type = EnumField(ZEV_TYPE)

range = models.DecimalField(max_digits=20, decimal_places=2)

zev_class = models.CharField(max_length=1)

vehicle_class_interior_volume = models.CharField(max_length=250)

total_supplied = models.IntegerField()

class Meta:
db_table = "sales_forecast_record"

db_table_comment = "Stores sales forecast records"
36 changes: 36 additions & 0 deletions backend/api/permissions/sales_forecast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from rest_framework import permissions
from api.services.model_year_report import get_model_year_report
from api.models.model_year_report_statuses import ModelYearReportStatuses


class SalesForecastPermissions(permissions.BasePermission):

def has_permission(self, request, view):
model_year_report_id = view.kwargs.get("pk")
model_year_report = None
user = request.user
is_government = user.is_government
organization_matches = False
if model_year_report_id is not None:
model_year_report = get_model_year_report(model_year_report_id)
if (
model_year_report is not None
and model_year_report.organization == user.organization
):
organization_matches = True

if view.action == "save" and not is_government and organization_matches:
return True
elif view.action == "records" or view.action == "totals":
if model_year_report is not None:
if is_government and model_year_report.validation_status not in [
ModelYearReportStatuses.DRAFT,
ModelYearReportStatuses.DELETED,
]:
return True
elif not is_government and organization_matches is True:
return True
elif view.action == "template_url":
return True

return False
35 changes: 35 additions & 0 deletions backend/api/serializers/sales_forecast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from rest_framework.serializers import ModelSerializer, SlugRelatedField
from enumfields.drf import EnumField
from api.models.sales_forecast import SalesForecast
from api.models.sales_forecast_record import SalesForecastRecord
from api.constants.zev_type import ZEV_TYPE


class SalesForecastSerializer(ModelSerializer):
class Meta:
model = SalesForecast
fields = [
"ice_vehicles_one",
"ice_vehicles_two",
"ice_vehicles_three",
"zev_vehicles_one",
"zev_vehicles_two",
"zev_vehicles_three",
]


class SalesForecastRecordSerializer(ModelSerializer):
type = EnumField(ZEV_TYPE)

class Meta:
model = SalesForecastRecord
fields = [
"model_year",
"make",
"model_name",
"type",
"range",
"zev_class",
"vehicle_class_interior_volume",
"total_supplied",
]
Loading

0 comments on commit 73c61fa

Please sign in to comment.