Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRPT-653 Add ENV-COS role and fix flavourId bug #804

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const DEFAULT_CSV_TYPES = {

const ROLE_DATA_SOURCES = {
[Constants.ApplicationRoles.ADMIN_FLNRO]: ['coors-csv'],
[Constants.ApplicationRoles.ADMIN_ENV_COS]: ['coors-csv'],
[Constants.ApplicationRoles.ADMIN_FLNR_NRO]: ['era-csv', 'nris-flnr-csv'],
[Constants.ApplicationRoles.ADMIN_AGRI]: ['agri-cmdb-csv', 'agri-mis-csv'],
[Constants.ApplicationRoles.ADMIN_ALC]: ['alc-csv']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export class ImportComponent implements OnInit, OnDestroy {
this.factoryService.userOnlyInLimitedRole(Constants.ApplicationRoles.ADMIN_FLNRO) ||
this.factoryService.userOnlyInLimitedRole(Constants.ApplicationRoles.ADMIN_FLNR_NRO) ||
this.factoryService.userOnlyInLimitedRole(Constants.ApplicationRoles.ADMIN_AGRI) ||
this.factoryService.userOnlyInLimitedRole(Constants.ApplicationRoles.ADMIN_ALC)
this.factoryService.userOnlyInLimitedRole(Constants.ApplicationRoles.ADMIN_ALC) ||
this.factoryService.userOnlyInLimitedRole(Constants.ApplicationRoles.ADMIN_ENV_COS)
) {
this.showSourceSystem = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_BCMI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_FLNRO) ||
roles.includes(Constants.ApplicationRoles.ADMIN_FLNR_NRO) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);

Expand Down Expand Up @@ -179,6 +180,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_WF) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);

this.menus[recordTypes.ADMINISTRATIVE_SANCTION] =
Expand All @@ -187,6 +189,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_FLNR_NRO) ||
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);

this.menus[recordTypes.AGREEMENT] = inBaseAdminRole(roles);
Expand All @@ -205,6 +208,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_FLNR_NRO) ||
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);

this.menus[recordTypes.CORRESPONDENCE] = inBaseAdminRole(roles);
Expand All @@ -217,6 +221,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_FLNR_NRO) ||
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);

this.menus[recordTypes.MANAGEMENT_PLAN] = inBaseAdminRole(roles);
Expand All @@ -228,6 +233,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_WF) ||
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);

this.menus[recordTypes.PERMIT] = inBaseAdminRole(roles) || roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD);
Expand All @@ -238,6 +244,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_FLNR_NRO) ||
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);

this.menus[recordTypes.REPORT] = inBaseAdminRole(roles);
Expand All @@ -250,6 +257,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_FLNR_NRO) ||
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);

this.menus[recordTypes.WARNING] =
Expand All @@ -258,6 +266,7 @@ export class KeycloakService {
roles.includes(Constants.ApplicationRoles.ADMIN_FLNR_NRO) ||
roles.includes(Constants.ApplicationRoles.ADMIN_AGRI) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_EPD) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ENV_COS) ||
roles.includes(Constants.ApplicationRoles.ADMIN_ALC);
}

Expand Down
23 changes: 20 additions & 3 deletions angular/projects/admin-nrpti/src/app/utils/constants/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class Constants {
ADMIN_FLNR_NRO: 'admin:flnr-nro',
ADMIN_AGRI: 'admin:agri',
ADMIN_ENV_EPD: 'admin:env-epd',
ADMIN_ENV_COS: 'admin:env-cos',
ADMIN_ALC: 'admin:alc'
};

Expand All @@ -20,6 +21,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
];

Expand Down Expand Up @@ -68,6 +70,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
],
LNG: [
Expand All @@ -77,6 +80,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
]
},
Expand All @@ -87,6 +91,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
],
LNG: [
Expand All @@ -95,6 +100,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
]
},
Expand Down Expand Up @@ -125,6 +131,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
],
LNG: [
Expand All @@ -133,6 +140,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
]
},
Expand All @@ -151,6 +159,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
],
LNG: [
Expand All @@ -159,6 +168,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
]
},
Expand All @@ -174,6 +184,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
],
LNG: [
Expand All @@ -183,6 +194,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
]
},
Expand All @@ -197,6 +209,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
],
LNG: [
Expand All @@ -205,6 +218,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
]
},
Expand All @@ -223,6 +237,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
],
LNG: [
Expand All @@ -231,6 +246,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
]
},
Expand All @@ -241,6 +257,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
],
LNG: [
Expand All @@ -249,6 +266,7 @@ export class Constants {
Constants.ApplicationRoles.ADMIN_FLNR_NRO,
Constants.ApplicationRoles.ADMIN_AGRI,
Constants.ApplicationRoles.ADMIN_ENV_EPD,
Constants.ApplicationRoles.ADMIN_ENV_COS,
Constants.ApplicationRoles.ADMIN_ALC
]
}
Expand All @@ -262,9 +280,8 @@ export class Constants {
[Constants.ApplicationRoles.ADMIN_FLNR_NRO]: ['Natural Resource Officers'],
[Constants.ApplicationRoles.ADMIN_AGRI]: ['Ministry of Agriculture'],
[Constants.ApplicationRoles.ADMIN_ENV_EPD]: ['Environmental Protection Division'],
[Constants.ApplicationRoles.ADMIN_ALC]: [
'Agriculture Land Commission'
]
[Constants.ApplicationRoles.ADMIN_ENV_COS]: ['Conservation Officer Service (COS)'],
[Constants.ApplicationRoles.ADMIN_ALC]: ['Agriculture Land Commission']
};

public static readonly LngSectionPickList: string[] = [
Expand Down
42 changes: 42 additions & 0 deletions api/migrations/20210311223603-renameConservationOfficerService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {};

exports.up = async function(db) {
console.log('**** Renaming Conservation Officer Service issuing agency ****');

const mClient = await db.connection.connect(db.connectionString, {
native_parser: true
});

try {
const nrpti = await mClient.collection('nrpti');

await nrpti.updateMany(
{
issuingAgency: 'Conservation Officer Service'
},
{ $set: { issuingAgency: 'Conservation Officer Service (COS)' } }
);

console.log(`Finished renaming Conservation Officer Service issuing agency`);
} catch (err) {
console.log(`Error renaming Conservation Officer Service issuing agency: ${err}`);
} finally {
mClient.close();
}

return null;
};

exports.down = function(db) {
return null;
};

exports._meta = {
version: 1
};
57 changes: 57 additions & 0 deletions api/migrations/20210311230347-addEnvCosRoleToCoorsCsv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict';

const { ApplicationRoles } = require('./../src/utils/constants/misc');

const CSV_SOURCE_DEFAULT_ROLES = [
{ source: 'coors-csv', role: ApplicationRoles.ADMIN_ENV_COS }
];

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {};

exports.up = async function(db) {
console.log('**** Updating CSV Import records permissions ****');

const mClient = await db.connection.connect(db.connectionString, {
native_parser: true
});

try {
const nrpti = await mClient.collection('nrpti');

for (const csvRole of CSV_SOURCE_DEFAULT_ROLES) {
await nrpti.updateMany(
{
sourceSystemRef: csvRole.source
},
{
$addToSet: {
read: csvRole.role,
write: csvRole.role,
['issuedTo.read']: csvRole.role,
['issuedTo.write']: csvRole.role
}
}
);
}

console.log(`Finished updating CSV Import records permissions`);
} catch (err) {
console.log(`Error updating CSV Import records permissions: ${err}`);
} finally {
mClient.close();
}

return null;
};

exports.down = function(db) {
return null;
};

exports._meta = {
version: 1
};
1 change: 1 addition & 0 deletions api/src/controllers/post/administrative-penalty.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ADDITIONAL_ROLES = [
utils.ApplicationRoles.ADMIN_FLNR_NRO,
utils.ApplicationRoles.ADMIN_AGRI,
utils.ApplicationRoles.ADMIN_ENV_EPD,
utils.ApplicationRoles.ADMIN_ENV_COS,
utils.ApplicationRoles.ADMIN_ALC
];
exports.ADDITIONAL_ROLES = ADDITIONAL_ROLES;
Expand Down
1 change: 1 addition & 0 deletions api/src/controllers/post/administrative-sanction.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ADDITIONAL_ROLES = [
utils.ApplicationRoles.ADMIN_FLNR_NRO,
utils.ApplicationRoles.ADMIN_AGRI,
utils.ApplicationRoles.ADMIN_ENV_EPD,
utils.ApplicationRoles.ADMIN_ENV_COS,
utils.ApplicationRoles.ADMIN_ALC
];
exports.ADDITIONAL_ROLES = ADDITIONAL_ROLES;
Expand Down
1 change: 1 addition & 0 deletions api/src/controllers/post/court-conviction.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ADDITIONAL_ROLES = [
utils.ApplicationRoles.ADMIN_FLNR_NRO,
utils.ApplicationRoles.ADMIN_AGRI,
utils.ApplicationRoles.ADMIN_ENV_EPD,
utils.ApplicationRoles.ADMIN_ENV_COS,
utils.ApplicationRoles.ADMIN_ALC
];
exports.ADDITIONAL_ROLES = ADDITIONAL_ROLES;
Expand Down
1 change: 1 addition & 0 deletions api/src/controllers/post/inspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ADDITIONAL_ROLES = [
utils.ApplicationRoles.ADMIN_FLNR_NRO,
utils.ApplicationRoles.ADMIN_AGRI,
utils.ApplicationRoles.ADMIN_ENV_EPD,
utils.ApplicationRoles.ADMIN_ENV_COS,
utils.ApplicationRoles.ADMIN_ALC
];
exports.ADDITIONAL_ROLES = ADDITIONAL_ROLES;
Expand Down
1 change: 1 addition & 0 deletions api/src/controllers/post/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ADDITIONAL_ROLES = [
utils.ApplicationRoles.ADMIN_FLNR_NRO,
utils.ApplicationRoles.ADMIN_AGRI,
utils.ApplicationRoles.ADMIN_ENV_EPD,
utils.ApplicationRoles.ADMIN_ENV_COS,
utils.ApplicationRoles.ADMIN_ALC
];
exports.ADDITIONAL_ROLES = ADDITIONAL_ROLES;
Expand Down
1 change: 1 addition & 0 deletions api/src/controllers/post/restorative-justice.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ADDITIONAL_ROLES = [
utils.ApplicationRoles.ADMIN_FLNR_NRO,
utils.ApplicationRoles.ADMIN_AGRI,
utils.ApplicationRoles.ADMIN_ENV_EPD,
utils.ApplicationRoles.ADMIN_ENV_COS,
utils.ApplicationRoles.ADMIN_ALC
];
exports.ADDITIONAL_ROLES = ADDITIONAL_ROLES;
Expand Down
Loading