Skip to content

Commit

Permalink
fix: script runner for new reserved community type (#4380)
Browse files Browse the repository at this point in the history
* fix: script runner for new reserved community type

* fix: update comment
  • Loading branch information
ludtkemorgan authored Oct 15, 2024
1 parent 763e03a commit a6be180
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/src/controllers/script-runner.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { AdminOrJurisdictionalAdminGuard } from '../guards/admin-or-jurisdiction
import { DataTransferDTO } from '../dtos/script-runner/data-transfer.dto';
import { BulkApplicationResendDTO } from '../dtos/script-runner/bulk-application-resend.dto';
import { AmiChartImportDTO } from '../dtos/script-runner/ami-chart-import.dto';
import { CommunityTypeDTO } from '../dtos/script-runner/community-type.dto';

@Controller('scriptRunner')
@ApiTags('scriptRunner')
Expand Down Expand Up @@ -120,4 +121,22 @@ export class ScirptRunnerController {
): Promise<SuccessDTO> {
return await this.scriptRunnerService.optOutExistingLotteries(req);
}

@Put('createNewReservedCommunityType')
@ApiOperation({
summary: 'A script that creates a new reserved community type',
operationId: 'createNewReservedCommunityType',
})
@ApiOkResponse({ type: SuccessDTO })
async createNewReservedCommunityType(
@Body() body: CommunityTypeDTO,
@Request() req: ExpressRequest,
): Promise<SuccessDTO> {
return await this.scriptRunnerService.createNewReservedCommunityType(
req,
body.id,
body.name,
body.description,
);
}
}
23 changes: 23 additions & 0 deletions api/src/dtos/script-runner/community-type.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { IsDefined, IsString, IsUUID } from 'class-validator';
import { Expose } from 'class-transformer';
import { ValidationsGroupsEnum } from '../../enums/shared/validation-groups-enum';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CommunityTypeDTO {
@Expose()
@IsString({ groups: [ValidationsGroupsEnum.default] })
@IsUUID(4, { groups: [ValidationsGroupsEnum.default] })
@IsDefined({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty()
id: string;

@Expose()
@IsString({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty()
name: string;

@Expose()
@IsString({ groups: [ValidationsGroupsEnum.default] })
@ApiPropertyOptional()
description?: string;
}
38 changes: 38 additions & 0 deletions api/src/services/script-runner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Application } from '../dtos/applications/application.dto';
import { AmiChartImportDTO } from '../dtos/script-runner/ami-chart-import.dto';
import { AmiChartCreate } from '../dtos/ami-charts/ami-chart-create.dto';
import { AmiChartService } from './ami-chart.service';
import { IdDTO } from '../dtos/shared/id.dto';

/**
this is the service for running scripts
Expand Down Expand Up @@ -416,6 +417,43 @@ export class ScriptRunnerService {
return { success: true };
}

/**
*
* @param req incoming request object
* @param jurisdictionIdDTO id containing the jurisdiction id we are creating the new community type for
* @param name name of the community type
* @param name description of the community type
* @returns successDTO
* @description creates a new reserved community type. Reserved community types also need translations added
*/
async createNewReservedCommunityType(
req: ExpressRequest,
jurisdictionId: string,
name: string,
description?: string,
): Promise<SuccessDTO> {
// script runner standard start up
const requestingUser = mapTo(User, req['user']);
await this.markScriptAsRunStart(`${name} Type`, requestingUser);

// create new reserved community type using the passed in params
await this.prisma.reservedCommunityTypes.create({
data: {
name: name,
description: description,
jurisdictions: {
connect: {
id: jurisdictionId,
},
},
},
});

// script runner standard spin down
await this.markScriptAsComplete(`${name} Type`, requestingUser);
return { success: true };
}

/**
this is simply an example
*/
Expand Down
2 changes: 2 additions & 0 deletions shared-helpers/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,15 @@
"listings.reservedCommunityTypeDescriptions.senior62": "Personas mayores de 62 años",
"listings.reservedCommunityTypeDescriptions.specialNeeds": "Necesidades especiales",
"listings.reservedCommunityTypeDescriptions.veteran": "Veterano",
"listings.reservedCommunityTypeDescriptions.schoolEmployee": "Empleado de la escuela",
"listings.reservedCommunityTypes.developmentalDisability": "La discapacidad del desarrollo",
"listings.reservedCommunityTypes.housingVoucher": "Vale HCV/Sección 8",
"listings.reservedCommunityTypes.senior": "Personas mayores",
"listings.reservedCommunityTypes.senior55": "Personas mayores de 55 años",
"listings.reservedCommunityTypes.senior62": "Personas mayores de 62 años",
"listings.reservedCommunityTypes.specialNeeds": "Necesidades especiales",
"listings.reservedCommunityTypes.veteran": "Veterano",
"listings.reservedCommunityTypes.schoolEmployee": "Empleado de la escuela",
"listings.reservedFor": "Reservada para %{type}",
"listings.reservedTypePlural.developmentalDisability": "Discapacidades del desarrollo",
"listings.reservedTypePlural.family": "familias",
Expand Down
2 changes: 2 additions & 0 deletions shared-helpers/src/locales/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -659,13 +659,15 @@
"listings.reservedCommunityTypeDescriptions.senior62": "Seniors 62+",
"listings.reservedCommunityTypeDescriptions.specialNeeds": "Special Needs",
"listings.reservedCommunityTypeDescriptions.veteran": "Veteran",
"listings.reservedCommunityTypeDescriptions.schoolEmployee": "School Employee",
"listings.reservedCommunityTypes.developmentalDisability": "Developmental Disability",
"listings.reservedCommunityTypes.housingVoucher": "HCV/Section 8 Voucher",
"listings.reservedCommunityTypes.senior": "Seniors",
"listings.reservedCommunityTypes.senior55": "Seniors 55+",
"listings.reservedCommunityTypes.senior62": "Seniors 62+",
"listings.reservedCommunityTypes.specialNeeds": "Special Needs",
"listings.reservedCommunityTypes.veteran": "Veteran",
"listings.reservedCommunityTypes.schoolEmployee": "School Employee",
"listings.reservedFor": "Reserved for %{type}",
"listings.reservedTypePlural.developmentalDisability": "Developmental Disabilities",
"listings.reservedTypePlural.family": "families",
Expand Down
2 changes: 2 additions & 0 deletions shared-helpers/src/locales/tl.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,15 @@
"listings.reservedCommunityTypeDescriptions.senior62": "Mga nakatatanda 62+",
"listings.reservedCommunityTypeDescriptions.specialNeeds": "Espesyal na pangangailangan",
"listings.reservedCommunityTypeDescriptions.veteran": "Beterano",
"listings.reservedCommunityTypeDescriptions.schoolEmployee": "Empleyado ng Paaralan",
"listings.reservedCommunityTypes.developmentalDisability": "Kapansanan sa Pag-unlad",
"listings.reservedCommunityTypes.housingVoucher": "Voucher ng HCV/Seksyon 8",
"listings.reservedCommunityTypes.senior": "Mga nakatatanda",
"listings.reservedCommunityTypes.senior55": "Mga nakatatanda 55+",
"listings.reservedCommunityTypes.senior62": "Mga nakatatanda 62+",
"listings.reservedCommunityTypes.specialNeeds": "Espesyal na pangangailangan",
"listings.reservedCommunityTypes.veteran": "Beterano",
"listings.reservedCommunityTypes.schoolEmployee": "Empleyado ng Paaralan",
"listings.reservedFor": "Nakalaan para sa %{type}",
"listings.reservedTypePlural.developmentalDisability": "Mga Kapansanan sa Pag-unlad",
"listings.reservedTypePlural.family": "mga pamilya",
Expand Down
2 changes: 2 additions & 0 deletions shared-helpers/src/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,15 @@
"listings.reservedCommunityTypeDescriptions.senior62": "Người cao tuổi 62+",
"listings.reservedCommunityTypeDescriptions.specialNeeds": "Nhu cầu đặc biệt",
"listings.reservedCommunityTypeDescriptions.veteran": "Cựu chiến binh",
"listings.reservedCommunityTypeDescriptions.schoolEmployee": "Nhân viên trường học",
"listings.reservedCommunityTypes.developmentalDisability": "Khuyết tật phát triển",
"listings.reservedCommunityTypes.housingVoucher": "Phiếu HCV/Phần 8",
"listings.reservedCommunityTypes.senior": "Người lớn tuổi",
"listings.reservedCommunityTypes.senior55": "Người cao tuổi 55+",
"listings.reservedCommunityTypes.senior62": "Người cao tuổi 62+",
"listings.reservedCommunityTypes.specialNeeds": "Nhu cầu đặc biệt",
"listings.reservedCommunityTypes.veteran": "Cựu chiến binh",
"listings.reservedCommunityTypes.schoolEmployee": "Nhân viên trường học",
"listings.reservedFor": "Được dành riêng cho %{type}",
"listings.reservedTypePlural.developmentalDisability": "Chậm phát triển",
"listings.reservedTypePlural.family": "các gia đình",
Expand Down
2 changes: 2 additions & 0 deletions shared-helpers/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,15 @@
"listings.reservedCommunityTypeDescriptions.senior62": "62 岁以上的老年人",
"listings.reservedCommunityTypeDescriptions.specialNeeds": "特殊需求",
"listings.reservedCommunityTypeDescriptions.veteran": "老将",
"listings.reservedCommunityTypeDescriptions.schoolEmployee": "学校员工",
"listings.reservedCommunityTypes.developmentalDisability": "发育障碍",
"listings.reservedCommunityTypes.housingVoucher": "HCV/第 8 节优惠券",
"listings.reservedCommunityTypes.senior": "老年人",
"listings.reservedCommunityTypes.senior55": "55 岁以上的老年人",
"listings.reservedCommunityTypes.senior62": "62 岁以上的老年人",
"listings.reservedCommunityTypes.specialNeeds": "特殊需求",
"listings.reservedCommunityTypes.veteran": "老将",
"listings.reservedCommunityTypes.schoolEmployee": "学校员工",
"listings.reservedFor": "保留給 %{type}",
"listings.reservedTypePlural.developmentalDisability": "发育障碍",
"listings.reservedTypePlural.family": "家庭",
Expand Down

0 comments on commit a6be180

Please sign in to comment.