Skip to content

Commit

Permalink
Tracking pull request to merge release-2.3.0 to master (#2097)
Browse files Browse the repository at this point in the history
* new release 2.3.0

* update pr number

* cancel teh previous workflow run

* fix: adding input fields for user username and email

* feat: added logic to limit editing a mapped user for bceid users

---------

Co-authored-by: AlexZorkin <[email protected]>
Co-authored-by: Alex Zorkin <[email protected]>
  • Loading branch information
3 people committed Feb 16, 2023
1 parent f33289f commit fe82570
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 28 deletions.
21 changes: 21 additions & 0 deletions .github/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# TFRS Post Release Work
After the release is deployed on Prod
* Merge the tracking pull request to master
* Create the release from master amd make it as the lasted release
* Create the new release branch from master
* Update the following fields in various files
* Create the tracking pull request to merge the new release branch to master

## Update .github/workflows/tfrs-release.yaml
* name
* branches
* PR_NUMBER
* RELEASE_NAME

## Update .pipeline/lib/config.js
* const version
* releaseBranch

## Update frontend/package.json
* version
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
## 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.2.0
name: TFRS release-2.3.0

on:
push:
branches: [ release-2.2.0 ]
branches: [ release-2.3.0 ]
workflow_dispatch:
workflow_call:

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: 2047
RELEASE_NAME: release-2.2.0
PR_NUMBER: 2097
RELEASE_NAME: release-2.3.0

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

jobs:

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.2.0'
const version = '2.3.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.2.0'
releaseBranch: 'release-2.3.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
12 changes: 12 additions & 0 deletions backend/api/models/User.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from api.managers.UserManager import UserManager

from .ComplianceReportHistory import ComplianceReportHistory
from .UserCreationRequest import UserCreationRequest
from .CreditTradeHistory import CreditTradeHistory
from .Permission import Permission
from .Role import Role
Expand Down Expand Up @@ -165,6 +166,17 @@ def is_government_user(self):
return True

return False

@property
def is_mapped(self):
"""
Has a user logged in and claimed this user account?
"""
user = UserCreationRequest.objects.filter(user_id=self.id).first()
if user:
return user.is_mapped
else:
return False

@property
def display_name(self):
Expand Down
13 changes: 8 additions & 5 deletions backend/api/serializers/User.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Meta:
'id', 'first_name', 'last_name', 'email',
'username', 'display_name', 'is_active',
'organization', 'roles', 'is_government_user', 'permissions',
'phone', 'cell_phone', 'title')
'phone', 'cell_phone', 'title', 'is_mapped')


class UserBasicSerializer(serializers.ModelSerializer):
Expand Down Expand Up @@ -184,9 +184,12 @@ def update(self, instance, validated_data):
'phone', instance.phone)
instance.title = validated_data.get(
'title', instance.title)

UserCreationRequest.objects.filter(user_id=instance.id).update(external_username=request.data["external_username"], keycloak_email=request.data["keycloak_email"] )

# if a user is mapped, then we limit the supplier's ability to edit external user account info
if request.user.is_government_user or not instance.is_mapped:
UserCreationRequest.objects.filter(user_id=instance.id) \
.update(external_username=request.data["external_username"], keycloak_email=request.data["keycloak_email"])

instance.save()

return instance
Expand All @@ -195,7 +198,7 @@ class Meta:
model = User
fields = (
'id', 'first_name', 'last_name', 'display_name', 'email', 'phone',
'roles', 'is_active', 'organization', 'cell_phone', 'title'
'roles', 'is_active', 'organization', 'cell_phone', 'title', 'is_mapped'
)
read_only_fields = (
'organization', 'id', 'is_government_user'
Expand Down Expand Up @@ -246,4 +249,4 @@ class Meta:
fields = (
'cell_phone', 'display_name', 'email', 'first_name', 'id',
'is_active', 'last_name', 'organization', 'phone', 'roles',
'user_creation_request', 'title')
'user_creation_request', 'title', 'is_mapped')
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.2.0",
"version": "2.3.0",
"dependencies": {
"@babel/eslint-parser": "^7.19.1",
"@babel/polyfill": "^7.12.1",
Expand Down
20 changes: 8 additions & 12 deletions frontend/src/admin/users/UserEditContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class UserEditContainer extends Component {
status: 'active',
title: '',
workPhone: '',
roles: []
roles: [],
isMapped: false
}
}

Expand Down Expand Up @@ -90,7 +91,8 @@ class UserEditContainer extends Component {
roles: props.user.details.roles.map(role => ({
id: role.id,
value: true
}))
})),
isMapped: props.user.details.isMapped
}

this.setState({
Expand Down Expand Up @@ -133,18 +135,12 @@ class UserEditContainer extends Component {

this.submitted = true

let email = this.state.fields.userCreationRequest.keycloakEmail

if (this.state.fields.email) {
({ email } = this.state.fields)
}

// API data structure
const data = {
const data = {
cellPhone: this.state.fields.mobilePhone,
email:this.state.fields.email,
keycloak_email: this.state.fields.userCreationRequest.keycloakEmail,
external_username:this.state.fields.userCreationRequest.externalUsername,
email: this.state.fields.email,
keycloak_email: this.state.fields.userCreationRequest.keycloakEmail,
external_username: this.state.fields.userCreationRequest.externalUsername,
firstName: this.state.fields.firstName,
lastName: this.state.fields.lastName,
organization: this.state.fields.organization ? this.state.fields.organization.id : null,
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/admin/users/components/UserFormDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const UserFormDetails = props => (
'Email address associated with the BCeID user account:'}
{document.location.pathname.indexOf('/admin/users/') >= 0 &&
'IDIR Email Address:'}
{!props.isAdding &&
<input
className="form-control"
id="keycloak-email"
Expand All @@ -64,8 +63,8 @@ const UserFormDetails = props => (
required="required"
type="email"
value={props.fields.userCreationRequest.keycloakEmail}
disabled={!props.loggedInUser.isGovernmentUser && props.fields.isMapped}
/>
}
</label>
</div>
</div>
Expand All @@ -77,7 +76,6 @@ const UserFormDetails = props => (
'BCeID:'}
{document.location.pathname.indexOf('/admin/users/') >= 0 &&
'IDIR Username:'}
{!props.isAdding &&
<input
className="form-control"
id="external-username"
Expand All @@ -87,8 +85,8 @@ const UserFormDetails = props => (
required="required"
type="text"
value={props.fields.userCreationRequest.externalUsername}
disabled={!props.loggedInUser.isGovernmentUser && props.fields.isMapped}
/>
}
</label>
</div>
</div>
Expand Down

0 comments on commit fe82570

Please sign in to comment.