Skip to content

Commit

Permalink
fix(university-gateway): Include attachmentKey when sending attachmen…
Browse files Browse the repository at this point in the history
…ts (#16631)

* Rename externalId -> externalKey for extraApplicationField
Add otherDocuments when creating application (extraApplicationField)
Fix when setting chosenProgram
Remove unecessary mapping for file types

* include attachmentKey when sending otherDocuments attachments

* Cleanup

* Cleanup

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
johannaagma and kodiakhq[bot] authored Oct 30, 2024
1 parent a40250f commit 1d3e7e4
Show file tree
Hide file tree
Showing 19 changed files with 260 additions and 198 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict'

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.query(`
BEGIN;
-- Add new column
ALTER TABLE program_extra_application_field
ADD COLUMN external_key VARCHAR(255) NOT NULL DEFAULT '';
-- Set value in new column
UPDATE program_extra_application_field
SET external_key = external_id;
-- Drop the old column
ALTER TABLE program_extra_application_field
DROP COLUMN external_id;
COMMIT;
`)
},

down(queryInterface, Sequelize) {
return queryInterface.sequelize.query(`
BEGIN;
-- Add back the old column
ALTER TABLE program_extra_application_field
ADD COLUMN external_id VARCHAR(255) NOT NULL DEFAULT '';
-- Set value in old column
UPDATE program_extra_application_field
SET external_id = external_key;
-- Drop the new column
ALTER TABLE program_extra_application_field
DROP COLUMN external_key;
COMMIT;
`)
},
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ModeOfDelivery, ApplicationTypes } from '@island.is/university-gateway'
import {
ModeOfDelivery,
ApplicationTypes,
FieldType,
} from '@island.is/university-gateway'
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
import {
IsArray,
Expand Down Expand Up @@ -104,19 +108,12 @@ class CreateApplicationFileDto {
})
fileName!: string

@IsString()
@ApiProperty({
description: 'File type',
example: 'profskirteini',
})
fileType!: string

@IsString()
@ApiProperty({
description: 'A public download link to a s3 file',
example: '',
})
url!: string
fileUrl!: string
}

class CreateApplicationEducationDto {
Expand Down Expand Up @@ -210,12 +207,21 @@ class CreateApplicationWorkExperienceDto {
}

class CreateApplicationExtraFieldsDto {
@IsEnum(FieldType)
@ApiProperty({
description:
'What type of field should be displayed in the application form',
example: FieldType.UPLOAD,
enum: FieldType,
})
fieldType!: FieldType

@IsString()
@ApiProperty({
description: 'Field key',
description: 'External key for field',
example: 'cv_field',
})
key!: string
externalKey!: string

@IsObject()
@ApiProperty({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class InternalApplicationService {
)

if (affectedCount > 0) {
//TODOx update in application system DB
//TODO update in application system DB
}
} catch (e) {
logger.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { UniversityOfIcelandApplicationClient } from '@island.is/clients/univers
import {
ApplicationStatus,
IApplication,
IApplicationAttachment,
UniversityNationalIds,
} from '@island.is/university-gateway'
import { University } from '../university/model/university'
Expand Down Expand Up @@ -89,10 +90,10 @@ export class UniversityApplicationService {
)
}

const allAttachments = applicationDto.educationList
.map((x) => x.degreeAttachments)
.filter((y) => !!y)
.flat()
const allAttachments: IApplicationAttachment[] =
applicationDto.educationList
.flatMap((education) => education.degreeAttachments || [])
.filter(Boolean)

// Wrap answers in obj that can be sent to libs/clients for universities
const applicationObj: IApplication = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class InternalProgramService {
for (let k = 0; k < extraApplicationFieldList.length; k++) {
await this.programExtraApplicationFieldModel.create({
programId: programId,
externalId: extraApplicationFieldList[k].externalId,
externalKey: extraApplicationFieldList[k].externalKey,
nameIs: extraApplicationFieldList[k].nameIs,
nameEn: extraApplicationFieldList[k].nameEn,
descriptionIs: extraApplicationFieldList[k].descriptionIs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export class ProgramExtraApplicationField extends Model<
program?: Program

@ApiProperty({
description: 'External id for field',
description: 'External key for field',
example: 'cv_field',
})
@Column({
type: DataType.STRING,
allowNull: false,
})
externalId!: string
externalKey!: string

@ApiProperty({
description: 'Field name (Icelandic)',
Expand Down
2 changes: 1 addition & 1 deletion apps/web/screens/queries/UniversityGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const GET_UNIVERSITY_GATEWAY_PROGRAM = gql`
extraApplicationFields {
descriptionEn
descriptionIs
externalId
externalKey
fieldType
nameEn
nameIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class UniversityGatewayProgramDetails extends UniversityGatewayProgram {
@ObjectType('UniversityGatewayProgramExtraApplicationField')
class UniversityGatewayProgramExtraApplicationField {
@Field()
externalId!: string
externalKey!: string

@Field()
nameIs!: string
Expand Down
Loading

0 comments on commit 1d3e7e4

Please sign in to comment.