Skip to content

Commit

Permalink
Tracking PR to merge release-1.1.0 to master (#165)
Browse files Browse the repository at this point in the history
* ZEVA-147: Split the Details Container into multiple containers (#168)

* ZEVA-143: Create New Organization (#167)

* ZEVA 145: Home page tidy up (#169)

* ZEVA 142: Fixed user group not being updated (#164)

* ZEVA-134 view organizations list (#153)

* ZEVA-132 Fixed Automapping for Keycloak (#152)

* ZEVA 108  - icbc data model (#130)

* zeva 110 - upload icbc spreadsheet (front end) (#135)

* ZEVA-115 UX Improvements (#132)

* ZEVA-80 UX Updates (#117)

* zeva-73 - credit transactions (#122)

* ZEVA-73: Credit transactions (#123)

* ZEVA-103: Government receives the request and issues credits (#121)

* ZEVA-117 Credit saving (#138)

* ZEVA-80 UX Updates (#117)

* zeva-73 - credit transactions (#122)

* ZEVA-73: Credit transactions (#123)

* ZEVA-103: Government receives the request and issues credits (#121)

* ZEVA DEV Fixes (#141)

* ZEVA 111 -  Back end component - parse uploaded file from ICBC (#148)

* ZEVA-137: Create Manage Organization Page (#161)

* ZEVA-135: Configurable modules (#160)

* ZEVA 155 - vehicle form validation (#179)

* ZEVA-149: Imported roles and permissions from TFRS (#172)
  • Loading branch information
kuanfandevops authored May 19, 2020
1 parent 2b7e6d4 commit eb82362
Show file tree
Hide file tree
Showing 81 changed files with 7,955 additions and 1,165 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ venv/
db.sqlite3
package-lock.json
.coverage
frontend/coverage/
frontend/coverage/lcov-report
3 changes: 2 additions & 1 deletion .pipeline/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ module.exports = settings => {
'IMAGE_REGISTRY': 'docker-registry.default.svc:5000',
'IMAGE_STREAM_NAMESPACE': phases[phase].namespace,
'IMAGE_STREAM_TAG': 'patroni:v10-stable',
'REPLICA': phases[phase].patroniReplica
'REPLICA': phases[phase].patroniReplica,
'PVC_SIZE': phases[phase].patroniPvcSize
}
}))

Expand Down
21 changes: 21 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
sonar.projectName=zeva

# Path to sources
sonar.sources=backend/api,backend/auditable,backend/db_comments,backend/zeva,frontend/src
sonar.exclusions=backend/api/tests
#sonar.inclusions=

# Path to tests
#sonar.tests=backend/api/tests
#sonar.test.exclusions=
#sonar.test.inclusions=

# Source encoding
sonar.sourceEncoding=UTF-8

# Exclusions for copy-paste detection
#sonar.cpd.exclusions=

# coverage reports
sonar.coverageReportPaths=frontend/coverage/clover.xml
sonar.javascript.lcov.reportPaths=frontend/coverage/lcov.info
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![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.

Expand Down
64 changes: 64 additions & 0 deletions backend/api/fixtures/operational/0006_add_roles_permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from django.db import transaction

from api.management.data_script import OperationalDataScript
from api.models.permission import Permission
from api.models.role import Role
from api.models.role_permission import RolePermission
from api.authorities import REQUIRED_AUTHORITIES


class AddRolesPermissions(OperationalDataScript):
"""
Adds the known suppliers
"""
is_revertable = False
comment = 'Adds the Roles and Permissions in the authorities file'

def check_run_preconditions(self):
return True

@transaction.atomic
def run(self):
display_order = 1
roles_added = 0
permissions_added = 0

for authority in REQUIRED_AUTHORITIES:
if authority.root is None:
continue

(role, role_created) = Role.objects.get_or_create(
role_code=authority.group,
defaults={
'description': authority.group,
'is_government_role':
True if authority.root == 'IDIR' else False,
'display_order': display_order
}
)

(permission, perm_created) = Permission.objects.get_or_create(
permission_code=authority.role.replace(' ', '_').upper(),
defaults={
'name': authority.role,
'description': authority.description
}
)

RolePermission.objects.get_or_create(
permission=permission,
role=role
)

if role_created:
roles_added += 1
display_order += 1

if perm_created:
permissions_added += 1

print("Added {} roles.".format(roles_added))
print("Added {} permissions.".format(permissions_added))


script_class = AddRolesPermissions
9 changes: 2 additions & 7 deletions backend/api/fixtures/test/0001_add_plugin_hybrid_vehicles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from api.management.data_script import OperationalDataScript
from api.models.model_year import ModelYear
from api.models.vehicle import Vehicle
from api.models.vehicle_class import VehicleClass
from api.models.vehicle_zev_type import ZevType
from api.models.vehicle_make import Make


class AddPluginHybridVehicles(OperationalDataScript):
Expand Down Expand Up @@ -163,7 +161,7 @@ class AddPluginHybridVehicles(OperationalDataScript):

def check_run_preconditions(self):
for veh in self.list_of_vehicles:
if Vehicle.objects.filter(make__name=veh['make'], model_year__name='2019', model_name=veh['model']).exists():
if Vehicle.objects.filter(model_year__name='2019', model_name=veh['model']).exists():
return False

return True
Expand All @@ -176,14 +174,11 @@ def run(self):

for vehicle in self.list_of_vehicles:
Vehicle.objects.create(
make=Make.objects.get(name=vehicle.get("make")),
make=vehicle.get("make"),
model_name=vehicle.get("model"),
model_year=model_year,
range=vehicle.get("range"),
validation_status="VALIDATED",
vehicle_class_code=VehicleClass.objects.get(
vehicle_class_code=vehicle.get("class_code")
),
vehicle_zev_type=ZevType.objects.get(
vehicle_zev_code=vehicle.get("zev_type")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from api.management.data_script import OperationalDataScript
from api.models.model_year import ModelYear
from api.models.vehicle import Vehicle
from api.models.vehicle_class import VehicleClass
from api.models.vehicle_zev_type import ZevType
from api.models.vehicle_make import Make


class AddBatteryElectricVehicles(OperationalDataScript):
Expand Down Expand Up @@ -189,7 +187,7 @@ class AddBatteryElectricVehicles(OperationalDataScript):

def check_run_preconditions(self):
for veh in self.list_of_vehicles:
if Vehicle.objects.filter(make__name=veh['make'], model_year__name='2019', model_name=veh['model']).exists():
if Vehicle.objects.filter(model_year__name='2019', model_name=veh['model']).exists():
return False

return True
Expand All @@ -203,14 +201,11 @@ def run(self):

for vehicle in self.list_of_vehicles:
Vehicle.objects.create(
make=Make.objects.get(name=vehicle.get("make")),
make=vehicle.get("make"),
model_name=vehicle.get("model"),
model_year=model_year,
range=vehicle.get("range"),
validation_status="VALIDATED",
vehicle_class_code=VehicleClass.objects.get(
vehicle_class_code=vehicle.get("class_code")
),
vehicle_zev_type=vehicle_zev_type
)

Expand Down
10 changes: 3 additions & 7 deletions backend/api/keycloak_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,14 @@ def authenticate(self, request):
)
except UserProfile.DoesNotExist:
raise exceptions.AuthenticationFailed(
'user_id "{}" does not exist'.format(username))
'user_id "{}" does not exist'.format(
user_token.get('user_id')
))

if not user.is_active:
raise exceptions.PermissionDenied(
'Your account is currently inactive. Please contact your '
'administrator to re-activate your account.'
)

if 'realm_access' in user_token:
if 'roles' in user_token['realm_access']:
for role in user_token['realm_access']['roles']:
if role not in FILTERED_ROLES:
user.roles.append(role)

return user, None
6 changes: 6 additions & 0 deletions backend/api/managers/permission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.db import models


class PermissionManager(models.Manager):
def get_by_natural_key(self, code):
return self.get(code=code)
6 changes: 6 additions & 0 deletions backend/api/managers/role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.db import models


class RoleManager(models.Manager):
def get_by_natural_key(self, name):
return self.get(name=name)
21 changes: 21 additions & 0 deletions backend/api/migrations/0037_auto_20200508_1451.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.0.3 on 2020-05-08 21:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0036_auto_20200429_1327'),
]

operations = [
migrations.AlterUniqueTogether(
name='vehicle',
unique_together={('make', 'model_name', 'vehicle_zev_type', 'model_year')},
),
migrations.RemoveField(
model_name='vehicle',
name='vehicle_class_code',
),
]
60 changes: 60 additions & 0 deletions backend/api/migrations/0038_auto_20200513_1500.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Generated by Django 3.0.3 on 2020-05-13 22:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0037_auto_20200508_1451'),
]

operations = [
migrations.RemoveField(
model_name='vehicleclass',
name='create_user',
),
migrations.RemoveField(
model_name='vehicleclass',
name='update_user',
),
migrations.RemoveField(
model_name='vehiclemakeorganization',
name='create_user',
),
migrations.RemoveField(
model_name='vehiclemakeorganization',
name='organization',
),
migrations.RemoveField(
model_name='vehiclemakeorganization',
name='update_user',
),
migrations.RemoveField(
model_name='vehiclemakeorganization',
name='vehicle_make',
),
migrations.RemoveField(
model_name='vehiclechangehistory',
name='make_id',
),
migrations.AlterField(
model_name='icbcvehicle',
name='make',
field=models.CharField(max_length=250, unique=True),
),
migrations.AlterField(
model_name='vehicle',
name='make',
field=models.CharField(max_length=250, unique=True),
),
migrations.DeleteModel(
name='Make',
),
migrations.DeleteModel(
name='VehicleClass',
),
migrations.DeleteModel(
name='VehicleMakeOrganization',
),
]
22 changes: 22 additions & 0 deletions backend/api/migrations/0039_auto_20200514_0900.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.0.3 on 2020-05-14 16:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0038_auto_20200513_1500'),
]

operations = [
migrations.RemoveField(
model_name='vehiclechangehistory',
name='vehicle_class_code_id',
),
migrations.AddField(
model_name='vehiclechangehistory',
name='make',
field=models.CharField(blank=True, max_length=250, null=True),
),
]
23 changes: 23 additions & 0 deletions backend/api/migrations/0040_auto_20200515_1411.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.0.3 on 2020-05-15 21:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0039_auto_20200514_0900'),
]

operations = [
migrations.AlterField(
model_name='icbcvehicle',
name='make',
field=models.CharField(max_length=250),
),
migrations.AlterField(
model_name='vehicle',
name='make',
field=models.CharField(max_length=250),
),
]
Loading

0 comments on commit eb82362

Please sign in to comment.