Skip to content

Commit

Permalink
Merge pull request #193 from icefoganalytics/test
Browse files Browse the repository at this point in the history
Portal updates and publishing letters
  • Loading branch information
datajohnson authored Oct 29, 2023
2 parents 5dd1203 + 7a0ab81 commit ac14e2a
Show file tree
Hide file tree
Showing 14 changed files with 453 additions and 306 deletions.
3 changes: 2 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ app.use(

CreateMigrationRoutes(app);

app.use("/api/portal", portalRouter);

configureAuthentication(app);

app.get("/_status", (req: Request, res: Response) => {
Expand All @@ -58,7 +60,6 @@ app.get("/_status", (req: Request, res: Response) => {

app.use("/api/v2/reference", RequireActive, referenceRouter);
app.use("/api/v2/admin", RequireActive, adminRouter);
app.use("/api/portal", portalRouter);

// serves the static files generated by the front-end
app.use(express.static(path.join(__dirname, "web")));
Expand Down
225 changes: 112 additions & 113 deletions src/api/models/student.ts
Original file line number Diff line number Diff line change
@@ -1,139 +1,138 @@
import Dependent from "@/models/dependent"
import Person from "@/models/person"
import Relationship from "@/models/relationship"
import Residence from "@/models/residence"
import StudentConsent from "@/models/student-consent"
import StudentPerson from "@/models/student-person"
import Dependent from "@/models/dependent";
import Person from "@/models/person";
import Relationship from "@/models/relationship";
import Residence from "@/models/residence";
import StudentConsent from "@/models/student-consent";
import StudentPerson from "@/models/student-person";

interface StudentRecord {
id: number
personId: number
highSchoolId?: number
educationLevelId?: number
indigenousLearnerId?: number
vendorId?: string
yukonId?: string
checkedForYukonId: boolean
nationalId?: string
locatorNumber?: string
isCrownWard: boolean
highSchoolFinalGrade?: string
highSchoolLeftYear?: number
highSchoolLeftMonth?: number
preFundedYear?: number
preFundingYearsUsed?: number
cslLetterDate?: Date
cslWarnCode?: string
preOverAwardAmount?: number
preYeaAwardsUsedAmount?: number
userName?: string
userPassword?: string
isActive: boolean
isFirstLogonFlg?: string
lastLogonDate?: Date
lastPwChangeDate?: Date
yeaExpiryDate?: Date
adjYgFundingWeeks?: number
adjStaUpgradingWeeks?: number
adjOutsideTravelCnt?: number
yukonResidentFromMonth?: number
yukonResidentFromYear?: number
canadianResidentFromMonth?: number
canadianResidentFromYear?: number
oldYtid?: string
residenceComment?: string
kinFirstName?: string
kinLastName?: string
kinAddress1?: string
kinAddress2?: string
kinCityId?: number
kinProvinceId?: number
kinCountryId?: number
kinPostalCode?: string
id: number;
personId: number;
highSchoolId?: number;
educationLevelId?: number;
indigenousLearnerId?: number;
vendorId?: string;
yukonId?: string;
checkedForYukonId: boolean;
nationalId?: string;
locatorNumber?: string;
isCrownWard: boolean;
highSchoolFinalGrade?: string;
highSchoolLeftYear?: number;
highSchoolLeftMonth?: number;
preFundedYear?: number;
preFundingYearsUsed?: number;
cslLetterDate?: Date;
cslWarnCode?: string;
preOverAwardAmount?: number;
preYeaAwardsUsedAmount?: number;
userName?: string;
userPassword?: string;
isActive: boolean;
isFirstLogonFlg?: string;
lastLogonDate?: Date;
lastPwChangeDate?: Date;
yeaExpiryDate?: Date;
adjYgFundingWeeks?: number;
adjStaUpgradingWeeks?: number;
adjOutsideTravelCnt?: number;
yukonResidentFromMonth?: number;
yukonResidentFromYear?: number;
canadianResidentFromMonth?: number;
canadianResidentFromYear?: number;
oldYtid?: string;
residenceComment?: string;
kinFirstName?: string;
kinLastName?: string;
kinAddress1?: string;
kinAddress2?: string;
kinCityId?: number;
kinProvinceId?: number;
kinCountryId?: number;
kinPostalCode?: string;

// Relations
dependents?: Dependent[]
person?: Person
residences?: Residence[]
studentConsents?: StudentConsent[]
studentPersons?: StudentPerson[]
dependents?: Dependent[];
person?: Person;
residences?: Residence[];
studentConsents?: StudentConsent[];
studentPersons?: StudentPerson[];
highSchool?: { name: string };
}

interface Student extends StudentRecord {}

class Student {
constructor(params: StudentRecord) {
this.id = params.id
this.personId = params.personId
this.highSchoolId = params.highSchoolId
this.educationLevelId = params.educationLevelId
this.indigenousLearnerId = params.indigenousLearnerId
this.vendorId = params.vendorId
this.yukonId = params.yukonId
this.checkedForYukonId = params.checkedForYukonId
this.nationalId = params.nationalId
this.locatorNumber = params.locatorNumber
this.isCrownWard = params.isCrownWard
this.highSchoolFinalGrade = params.highSchoolFinalGrade
this.highSchoolLeftYear = params.highSchoolLeftYear
this.highSchoolLeftMonth = params.highSchoolLeftMonth
this.preFundedYear = params.preFundedYear
this.preFundingYearsUsed = params.preFundingYearsUsed
this.cslLetterDate = params.cslLetterDate
this.cslWarnCode = params.cslWarnCode
this.preOverAwardAmount = params.preOverAwardAmount
this.preYeaAwardsUsedAmount = params.preYeaAwardsUsedAmount
this.userName = params.userName
this.userPassword = params.userPassword
this.isActive = params.isActive
this.isFirstLogonFlg = params.isFirstLogonFlg
this.lastLogonDate = params.lastLogonDate
this.lastPwChangeDate = params.lastPwChangeDate
this.yeaExpiryDate = params.yeaExpiryDate
this.adjYgFundingWeeks = params.adjYgFundingWeeks
this.adjStaUpgradingWeeks = params.adjStaUpgradingWeeks
this.adjOutsideTravelCnt = params.adjOutsideTravelCnt
this.yukonResidentFromMonth = params.yukonResidentFromMonth
this.yukonResidentFromYear = params.yukonResidentFromYear
this.canadianResidentFromMonth = params.canadianResidentFromMonth
this.canadianResidentFromYear = params.canadianResidentFromYear
this.oldYtid = params.oldYtid
this.residenceComment = params.residenceComment
this.kinFirstName = params.kinFirstName
this.kinLastName = params.kinLastName
this.kinAddress1 = params.kinAddress1
this.kinAddress2 = params.kinAddress2
this.kinCityId = params.kinCityId
this.kinProvinceId = params.kinProvinceId
this.kinCountryId = params.kinCountryId
this.kinPostalCode = params.kinPostalCode
this.dependents = params.dependents
this.person = params.person
this.residences = params.residences
this.studentConsents = params.studentConsents
this.studentPersons = params.studentPersons
this.id = params.id;
this.personId = params.personId;
this.highSchoolId = params.highSchoolId;
this.educationLevelId = params.educationLevelId;
this.indigenousLearnerId = params.indigenousLearnerId;
this.vendorId = params.vendorId;
this.yukonId = params.yukonId;
this.checkedForYukonId = params.checkedForYukonId;
this.nationalId = params.nationalId;
this.locatorNumber = params.locatorNumber;
this.isCrownWard = params.isCrownWard;
this.highSchoolFinalGrade = params.highSchoolFinalGrade;
this.highSchoolLeftYear = params.highSchoolLeftYear;
this.highSchoolLeftMonth = params.highSchoolLeftMonth;
this.preFundedYear = params.preFundedYear;
this.preFundingYearsUsed = params.preFundingYearsUsed;
this.cslLetterDate = params.cslLetterDate;
this.cslWarnCode = params.cslWarnCode;
this.preOverAwardAmount = params.preOverAwardAmount;
this.preYeaAwardsUsedAmount = params.preYeaAwardsUsedAmount;
this.userName = params.userName;
this.userPassword = params.userPassword;
this.isActive = params.isActive;
this.isFirstLogonFlg = params.isFirstLogonFlg;
this.lastLogonDate = params.lastLogonDate;
this.lastPwChangeDate = params.lastPwChangeDate;
this.yeaExpiryDate = params.yeaExpiryDate;
this.adjYgFundingWeeks = params.adjYgFundingWeeks;
this.adjStaUpgradingWeeks = params.adjStaUpgradingWeeks;
this.adjOutsideTravelCnt = params.adjOutsideTravelCnt;
this.yukonResidentFromMonth = params.yukonResidentFromMonth;
this.yukonResidentFromYear = params.yukonResidentFromYear;
this.canadianResidentFromMonth = params.canadianResidentFromMonth;
this.canadianResidentFromYear = params.canadianResidentFromYear;
this.oldYtid = params.oldYtid;
this.residenceComment = params.residenceComment;
this.kinFirstName = params.kinFirstName;
this.kinLastName = params.kinLastName;
this.kinAddress1 = params.kinAddress1;
this.kinAddress2 = params.kinAddress2;
this.kinCityId = params.kinCityId;
this.kinProvinceId = params.kinProvinceId;
this.kinCountryId = params.kinCountryId;
this.kinPostalCode = params.kinPostalCode;
this.dependents = params.dependents;
this.person = params.person;
this.residences = params.residences;
this.studentConsents = params.studentConsents;
this.studentPersons = params.studentPersons;
this.highSchool = params.highSchool;
}

get parents(): Person[] | undefined {
if (this.studentPersons === undefined) {
return undefined
return undefined;
}

const studentPersonsWithParentRelationship = this.studentPersons
.filter(
(studentPerson) =>
studentPerson.isActive &&
studentPerson.relationship?.description === Relationship.Types.PARENT
studentPerson.isActive && studentPerson.relationship?.description === Relationship.Types.PARENT
)
// I don't know why .filter(studentPerson => studentPerson.person !== undefined) doesn't work on its own
.filter(StudentPerson.hasValidPerson)
.filter(StudentPerson.hasValidPerson);

const parents = studentPersonsWithParentRelationship.map(
(studentPerson) => studentPerson.person
)
const parents = studentPersonsWithParentRelationship.map((studentPerson) => studentPerson.person);

return parents
return parents;
}
}

export default Student
export default Student;
19 changes: 19 additions & 0 deletions src/api/routes/admin/application-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,25 @@ applicationRouter.get(
}
);

applicationRouter.put(
"/:applicationId/funding-request/:fundingRequestId/letters/:object_key",
[param("applicationId").isInt().notEmpty(), param("fundingRequestId").isInt().notEmpty()],
ReturnValidationErrors,
async (req: Request, res: Response) => {
const { fundingRequestId, object_key } = req.params;
let letters = await documentService.getDocumentsForFundingRequest(parseInt(fundingRequestId));
let letter = letters.filter((l) => l.object_key == object_key);

if (letter.length > 0) {
await documentService.updateDocument(object_key, req.body);
res.json({data: "Success"})

}

res.status(404).send;
}
);

applicationRouter.delete(
"/:applicationId/funding-request/:fundingRequestId/letters/:object_key",
[param("applicationId").isInt().notEmpty(), param("fundingRequestId").isInt().notEmpty()],
Expand Down
Loading

0 comments on commit ac14e2a

Please sign in to comment.