Skip to content

Commit

Permalink
Tracking pull request to merge release-2.11.0 to master (#2634)
Browse files Browse the repository at this point in the history
* new input field for organization details - IDIR only

* TFRS - new input field for organization details - IDIR only#2579

* removing supplier type migration

* reverting back the change

* Fix: Discrepency in latest_report id 2667

* fix: renamed migration and order to fix merge error

* adding edrms in detail and compliance report page. making part3supplier default selected.

* removing comment

* fix to disappear edrms from bceid side

* removing edrms value from bceid side

---------

Co-authored-by: jig-patel <[email protected]>
Co-authored-by: Prashanth <[email protected]>
Co-authored-by: Alex Zorkin <[email protected]>
Co-authored-by: Your Name <[email protected]>
  • Loading branch information
5 people committed Oct 27, 2023
1 parent 06f401c commit 5a2dcc2
Show file tree
Hide file tree
Showing 16 changed files with 515 additions and 311 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ on:
jobs:
create-release:
runs-on: ubuntu-latest
env:
releasename: ${{ github.event.pull_request.head.ref }}
steps:
- uses: actions/checkout@v3
- name: Replace release name
uses: mad9000/actions-find-and-replace-string@4
id: newereleasename
with:
source: ${{ github.event.pull_request.head.ref }}
find: 'release-'
replace: 'v'
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.event.pull_request.head.ref }}
tag_name: ${{ github.event.pull_request.head.ref }}
name: ${{ steps.newereleasename.outputs.value }}
tag_name: ${{ steps.newereleasename.outputs.value }}
body: |
${{ github.event.pull_request.body }}
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dev-release.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## For each release, the value of name, branches, RELEASE_NAME and PR_NUMBER need to be adjusted accordingly
## For each release, update lib/config.js: version and releaseBranch

name: TFRS Dev release-2.10.0
name: TFRS Dev release-2.11.0

on:
push:
branches: [ release-2.10.0 ]
branches: [ release-2.11.0 ]
paths:
- frontend/**
- backend/**
Expand All @@ -15,8 +15,8 @@ on:
env:
## The pull request number of the Tracking pull request to merge the release branch to main
## Also remember to update the version in .pipeline/lib/config.js
PR_NUMBER: 2574
RELEASE_NAME: release-2.10.0
PR_NUMBER: 2634
RELEASE_NAME: release-2.11.0

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tfrs-release.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## For each release, the value of name, branches, RELEASE_NAME and PR_NUMBER need to be adjusted accordingly
## For each release, update lib/config.js: version and releaseBranch

name: TFRS release-2.10.0
name: TFRS release-2.11.0

on:
workflow_dispatch:
Expand All @@ -10,8 +10,8 @@ on:
env:
## The pull request number of the Tracking pull request to merge the release branch to main
## Also remember to update the version in .pipeline/lib/config.js
PR_NUMBER: 2574
RELEASE_NAME: release-2.10.0
PR_NUMBER: 2634
RELEASE_NAME: release-2.11.0

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
4 changes: 2 additions & 2 deletions .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 = '2.10.0'
const version = '2.11.0'
const name = 'tfrs'
const ocpName = 'apps.silver.devops'

Expand All @@ -13,7 +13,7 @@ options.git.repository='tfrs'
const phases = {
build: { namespace:'0ab226-tools' , name: `${name}`, phase: 'build' , changeId:changeId, suffix: `-build-${changeId}` ,
instance: `${name}-build-${changeId}` , version:`${version}-${changeId}`, tag:`build-${version}-${changeId}`,
releaseBranch: 'release-2.10.0'
releaseBranch: 'release-2.11.0'
},
dev: {namespace:'0ab226-dev' , name: `${name}`, phase: 'dev' , changeId:changeId, suffix: `-dev` ,
instance: `${name}-dev` , version:`${version}`, tag:`dev-${version}`, dbServiceName: 'tfrs-spilo',
Expand Down
17 changes: 17 additions & 0 deletions backend/api/migrations/0009_organization_edrms_record.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2023-10-10 22:21

from django.db import migrations, models

class Migration(migrations.Migration):

dependencies = [
('api', '0008_auto_20230718_0104'),
]

operations = [
migrations.AddField(
model_name='organization',
name='edrms_record',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
58 changes: 58 additions & 0 deletions backend/api/migrations/0010_migrate_compliance_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import collections

from django.db import migrations, transaction


def update_report_fields(apps, schema_editor):
ComplianceReport = apps.get_model('api', 'compliancereport')
for report in ComplianceReport.objects.filter(supplements__isnull=False):
with transaction.atomic():
ancestor = report
root = None
latest = None
while ancestor.supplements is not None:
ancestor = ancestor.supplements

visited = []
id_traversal = {}
to_visit = collections.deque([ancestor.id])
i = 1

while len(to_visit) > 0:
current_id = to_visit.popleft()

# break loops
if current_id in visited:
continue
visited.append(current_id)

current = ComplianceReport.objects.get(id=current_id)

if current.supplements is None:
root = current
latest = current
# don't count non-supplement reports (really should just be the root)
if current.supplements is not None and \
not current.status.fuel_supplier_status_id == "Deleted":
latest = current
i += 1
id_traversal[current_id] = i
for descendant in current.supplemental_reports.order_by('create_timestamp').all():
to_visit.append(descendant.id)

for compliance_id, traversal in id_traversal.items():
ComplianceReport.objects.filter(id=int(compliance_id)) \
.update(latest_report=latest, root_report=root, traversal=traversal)
for report in ComplianceReport.objects.filter(supplements__isnull=True, latest_report__isnull=True):
ComplianceReport.objects.filter(id=report.id) \
.update(latest_report=report, root_report=report)


class Migration(migrations.Migration):
dependencies = [
('api', '0009_organization_edrms_record'),
]

operations = [
migrations.RunPython(update_report_fields, reverse_code=migrations.RunPython.noop),
]
6 changes: 6 additions & 0 deletions backend/api/models/Organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class Organization(Auditable):
max_length=500,
db_comment="Organization's legal name"
)
edrms_record = models.CharField(
max_length=100,
blank=True,
null=True,
db_comment="EDRMS Record Number",
)
status = models.ForeignKey(
'OrganizationStatus',
related_name='organizations',
Expand Down
12 changes: 8 additions & 4 deletions backend/api/serializers/ComplianceReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,12 +1242,12 @@ def create(self, validated_data):
record.save()

root_report = previous_report.root_report or previous_report
new_compliance_report.latest_report = new_compliance_report.supplements
new_compliance_report.latest_report = new_compliance_report
new_compliance_report.root_report = root_report
if previous_report.latest_report_id != new_compliance_report.supplements_id:
if previous_report.latest_report_id != new_compliance_report.latest_report_id:
if not previous_report.status.fuel_supplier_status_id == 'Deleted':
new_compliance_report.traversal = previous_report.traversal + 1
ComplianceReport.objects.filter(root_report_id=root_report.id).update(latest_report=new_compliance_report.supplements)
ComplianceReport.objects.filter(root_report=root_report).update(latest_report=new_compliance_report)
else:
new_compliance_report.traversal = previous_report.traversal
else:
Expand Down Expand Up @@ -1710,7 +1710,11 @@ def destroy(self):
'readOnly': "Cannot delete a compliance report that's not a "
"draft."
})

if compliance_report.is_supplemental:
# Revert back the previous report as the latest report
ComplianceReport.objects.filter(root_report=compliance_report.root_report) \
.update(latest_report=compliance_report.supplements)

compliance_report.status.fuel_supplier_status = \
ComplianceReportStatus.objects.get(status="Deleted")
compliance_report.status.save()
Expand Down
19 changes: 14 additions & 5 deletions backend/api/serializers/Organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ class OrganizationSerializer(serializers.ModelSerializer):
"""
organization_address = serializers.SerializerMethodField()
organization_balance = serializers.SerializerMethodField()
edrms_record = serializers.SerializerMethodField()

class Meta:
model = Organization
fields = ('id', 'name', 'status', 'status_display', 'actions_type',
'actions_type_display', 'create_timestamp', 'type',
'organization_balance', 'organization_address')
'organization_balance', 'organization_address', 'edrms_record')

def get_organization_address(self, obj):
"""
Expand All @@ -78,7 +79,14 @@ def get_organization_balance(self, obj):

return obj.organization_balance

def get_edrms_record(self, obj):
request = self.context.get('request')

if not request.user.has_perm('VIEW_FUEL_SUPPLIERS') and \
request.user.organization.id != obj.id:
return None

return obj.edrms_record
class OrganizationCreateSerializer(serializers.ModelSerializer):
"""
Serializer for creating organizations
Expand All @@ -99,6 +107,7 @@ def validate(self, attrs):
def create(self, validated_data):
CachedPages.objects.filter(cache_key__icontains='organizations').delete()
obj = Organization.objects.create(
edrms_record = validated_data['edrms_record'],
name=validated_data['name'],
type=validated_data['type'],
actions_type=validated_data['actions_type'],
Expand All @@ -118,7 +127,7 @@ def create(self, validated_data):
class Meta:
model = Organization
fields = ('id', 'name', 'type', 'status', 'actions_type',
'organization_address')
'organization_address', 'edrms_record')
read_only_fields = ('id',)


Expand Down Expand Up @@ -156,9 +165,9 @@ def update(self, obj, validated_data):
actions_type = OrganizationActionsType.objects.get(
the_type="Sell Only"
)

Organization.objects.filter(id=obj.id).update(
name=validated_data['name'],
edrms_record=validated_data['edrms_record'],
actions_type=actions_type,
status=status,
update_timestamp=timezone.now()
Expand Down Expand Up @@ -212,7 +221,7 @@ def update(self, obj, validated_data):
class Meta:
model = Organization
fields = ('id', 'name', 'type', 'status', 'actions_type',
'organization_address', 'update_timestamp')
'organization_address', 'update_timestamp', 'edrms_record')
read_only_fields = ('id', 'type')


Expand Down Expand Up @@ -250,4 +259,4 @@ def get_organization_address(self, obj):

class Meta:
model = Organization
fields = ('id', 'name', 'organization_address', 'type', 'status')
fields = ('id', 'name', 'organization_address', 'type', 'status', 'edrms_record')
5 changes: 4 additions & 1 deletion charts/tfrs-rabbitmq/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ resources:
memory: 400Mi
limits:
cpu: 320m
memory: 800Mi
memory: 800Mi

clustering:
forceBoot: true
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tfrs",
"version": "2.10.0",
"version": "2.11.0",
"dependencies": {
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,13 @@ class ComplianceReportingEditContainer extends Component {
]
: null
}
</p>,
<p className="schedule-organization-address" key="organization-attorney-address">
{organizationAddress && atLeastOneAttorneyAddressFieldExists(organizationAddress) && this.props.loggedInUser.isGovernmentUser ? (
<>
Company Profile, EDRMS Record #: {item.organization.edrmsRecord || ''}
</>
) : null}
</p>,
<ScheduleTabs
active={tab}
Expand Down
Loading

0 comments on commit 5a2dcc2

Please sign in to comment.