Skip to content

Commit

Permalink
SIMSBIOHUB-275: Remove Project Coordinator from SIMS (#1104)
Browse files Browse the repository at this point in the history
* Removes any Project Coordinator UI for creating, editing or viewing projects

* Removes any reference to Project Coordinator in the frontend and backend codebase

* Adds a migration that makes project coordinator fields optional, retaining any existing project coordinator data.
  • Loading branch information
curtisupshall authored and KjartanE committed Oct 5, 2023
1 parent dfa7a99 commit 3dafd6c
Show file tree
Hide file tree
Showing 57 changed files with 317 additions and 1,373 deletions.
136 changes: 0 additions & 136 deletions api/src/models/project-create.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';
import { describe } from 'mocha';
import {
PostCoordinatorData,
PostIUCNData,
PostLocationData,
PostObjectivesData,
Expand All @@ -17,10 +16,6 @@ describe('PostProjectObject', () => {
projectPostObject = new PostProjectObject(null);
});

it('sets coordinator', function () {
expect(projectPostObject.coordinator).to.equal(null);
});

it('sets project', function () {
expect(projectPostObject.project).to.equal(null);
});
Expand All @@ -37,71 +32,6 @@ describe('PostProjectObject', () => {
expect(projectPostObject.iucn).to.equal(null);
});
});

describe('All values provided', () => {
let projectPostObject: PostProjectObject;

const obj = {
coordinator: {
first_name: 'first',
last_name: 'last',
email_address: '[email protected]',
coordinator_agency: 'agency',
share_contact_details: 'true'
},
project: {
project_name: 'name_test_data',
project_programs: [1],
start_date: 'start_date_test_data',
end_date: 'end_date_test_data',
comments: 'comments_test_data'
},
objectives: {
objectives: 'these are the project objectives'
},
location: {
location_description: 'a location description',
geometry: [
{
type: 'Polygon',
coordinates: [
[
[-128, 55],
[-128, 55.5],
[-128, 56],
[-126, 58],
[-128, 55]
]
],
properties: {
name: 'Biohub Islands'
}
}
]
},
iucn: {
classificationDetails: [
{
classification: 1,
subClassification1: 2,
subClassification2: 3
}
]
},
partnerships: {
indigenous_partnerships: [1, 2],
stakeholder_partnerships: ['partner1, partner2']
}
};

before(() => {
projectPostObject = new PostProjectObject(obj);
});

it('sets coordinator', function () {
expect(projectPostObject.coordinator.first_name).to.equal(obj.coordinator.first_name);
});
});
});

describe('PostProjectData', () => {
Expand Down Expand Up @@ -200,72 +130,6 @@ describe('PostObjectivesData', () => {
});
});

describe('PostCoordinatorData', () => {
describe('No values provided', () => {
let projectCoordinatorData: PostCoordinatorData;

before(() => {
projectCoordinatorData = new PostCoordinatorData(null);
});

it('sets first_name', function () {
expect(projectCoordinatorData.first_name).to.eql(null);
});

it('sets last_name', function () {
expect(projectCoordinatorData.last_name).to.eql(null);
});

it('sets email_address', function () {
expect(projectCoordinatorData.email_address).to.eql(null);
});

it('sets coordinator_agency', function () {
expect(projectCoordinatorData.coordinator_agency).to.eql(null);
});

it('sets share_contact_details', function () {
expect(projectCoordinatorData.share_contact_details).to.eql(false);
});
});

describe('All values provided', () => {
let projectCoordinatorData: PostCoordinatorData;

const obj = {
first_name: 'first',
last_name: 'last',
email_address: '[email protected]',
coordinator_agency: 'agency',
share_contact_details: 'true'
};

before(() => {
projectCoordinatorData = new PostCoordinatorData(obj);
});

it('sets first_name', function () {
expect(projectCoordinatorData.first_name).to.eql(obj.first_name);
});

it('sets last_name', function () {
expect(projectCoordinatorData.last_name).to.eql(obj.last_name);
});

it('sets email_address', function () {
expect(projectCoordinatorData.email_address).to.eql(obj.email_address);
});

it('sets coordinator_agency', function () {
expect(projectCoordinatorData.coordinator_agency).to.eql(obj.coordinator_agency);
});

it('sets share_contact_details', function () {
expect(projectCoordinatorData.share_contact_details).to.eql(true);
});
});
});

describe('PostIUCNData', () => {
describe('No values provided', () => {
let projectIUCNData: PostIUCNData;
Expand Down
26 changes: 0 additions & 26 deletions api/src/models/project-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const defaultLog = getLogger('models/project-create');
* @class PostProjectObject
*/
export class PostProjectObject {
coordinator: PostCoordinatorData;
project: PostProjectData;
objectives: PostObjectivesData;
location: PostLocationData;
Expand All @@ -22,7 +21,6 @@ export class PostProjectObject {
constructor(obj?: any) {
defaultLog.debug({ label: 'PostProjectObject', message: 'params', obj });

this.coordinator = (obj?.coordinator && new PostCoordinatorData(obj.coordinator)) || null;
this.project = (obj?.project && new PostProjectData(obj.project)) || null;
this.objectives = (obj?.project && new PostObjectivesData(obj.objectives)) || null;
this.location = (obj?.location && new PostLocationData(obj.location)) || null;
Expand All @@ -31,30 +29,6 @@ export class PostProjectObject {
}
}

/**
* Processes POST /project contact data
*
* @export
* @class PostCoordinatorData
*/
export class PostCoordinatorData {
first_name: string;
last_name: string;
email_address: string;
coordinator_agency: string;
share_contact_details: boolean;

constructor(obj?: any) {
defaultLog.debug({ label: 'PostCoordinatorData', message: 'params', obj });

this.first_name = obj?.first_name || null;
this.last_name = obj?.last_name || null;
this.email_address = obj?.email_address || null;
this.coordinator_agency = obj?.coordinator_agency || null;
this.share_contact_details = (obj?.share_contact_details === 'true' && true) || false;
}
}

/**
* Processes POST /project project data.
*
Expand Down
77 changes: 1 addition & 76 deletions api/src/models/project-update.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { describe } from 'mocha';
import { PutCoordinatorData, PutIUCNData, PutLocationData, PutObjectivesData, PutProjectData } from './project-update';
import { PutIUCNData, PutLocationData, PutObjectivesData, PutProjectData } from './project-update';

describe('PutProjectData', () => {
describe('No values provided', () => {
Expand Down Expand Up @@ -107,81 +107,6 @@ describe('PutObjectivesData', () => {
});
});

describe('PutCoordinatorData', () => {
describe('No values provided', () => {
let data: PutCoordinatorData;

before(() => {
data = new PutCoordinatorData(null);
});

it('sets first_name', () => {
expect(data.first_name).to.equal(null);
});

it('sets last_name', () => {
expect(data.last_name).to.equal(null);
});

it('sets email_address', () => {
expect(data.email_address).to.equal(null);
});

it('sets coordinator_agency', () => {
expect(data.coordinator_agency).to.equal(null);
});

it('sets share_contact_details', () => {
expect(data.share_contact_details).to.equal(false);
});

it('sets revision_count', () => {
expect(data.revision_count).to.equal(null);
});
});

describe('all values provided', () => {
const obj = {
first_name: 'coordinator_first_name',
last_name: 'coordinator_last_name',
email_address: 'coordinator_email_address',
coordinator_agency: 'coordinator_agency_name',
share_contact_details: 'true',
revision_count: 1
};

let data: PutCoordinatorData;

before(() => {
data = new PutCoordinatorData(obj);
});

it('sets first_name', () => {
expect(data.first_name).to.equal('coordinator_first_name');
});

it('sets last_name', () => {
expect(data.last_name).to.equal('coordinator_last_name');
});

it('sets email_address', () => {
expect(data.email_address).to.equal('coordinator_email_address');
});

it('sets coordinator_agency', () => {
expect(data.coordinator_agency).to.equal('coordinator_agency_name');
});

it('sets share_contact_details', () => {
expect(data.share_contact_details).to.equal(true);
});

it('sets revision_count', () => {
expect(data.revision_count).to.equal(1);
});
});
});

describe('PutLocationData', () => {
describe('No values provided', () => {
let data: PutLocationData;
Expand Down
20 changes: 0 additions & 20 deletions api/src/models/project-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,6 @@ export class PutObjectivesData {
}
}

export class PutCoordinatorData {
first_name: string;
last_name: string;
email_address: string;
coordinator_agency: string;
share_contact_details: boolean;
revision_count: number;

constructor(obj?: any) {
defaultLog.debug({ label: 'PutCoordinatorData', message: 'params', obj });

this.first_name = obj?.first_name || null;
this.last_name = obj?.last_name || null;
this.email_address = obj?.email_address || null;
this.coordinator_agency = obj?.coordinator_agency || null;
this.share_contact_details = (obj?.share_contact_details === 'true' && true) || false;
this.revision_count = obj?.revision_count ?? null;
}
}

export class PutLocationData {
location_description: string;
geometry: Feature[];
Expand Down
Loading

0 comments on commit 3dafd6c

Please sign in to comment.