Skip to content

Commit

Permalink
Release/2023 11 27 (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan authored Nov 27, 2023
2 parents e27c74a + 81ba8bc commit 5586408
Show file tree
Hide file tree
Showing 102 changed files with 4,490 additions and 4,020 deletions.
6 changes: 3 additions & 3 deletions backend/core/src/email/email.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ describe("EmailService", () => {
const service = await module.resolve(EmailService)
await service.requestApproval(
user,
{ id: listing.id, name: listing.name },
{ id: listing.id, name: listing.name, juris: listing.jurisdiction?.id },
emailArr,
"http://localhost:3001"
)
Expand Down Expand Up @@ -419,7 +419,7 @@ describe("EmailService", () => {
const service = await module.resolve(EmailService)
await service.changesRequested(
user,
{ id: listing.id, name: listing.name },
{ id: listing.id, name: listing.name, juris: listing.jurisdiction?.id },
emailArr,
"http://localhost:3001"
)
Expand Down Expand Up @@ -466,7 +466,7 @@ describe("EmailService", () => {
const service = await module.resolve(EmailService)
await service.listingApproved(
user,
{ id: listing.id, name: listing.name },
{ id: listing.id, name: listing.name, juris: listing.jurisdiction?.id },
emailArr,
"http://localhost:3000"
)
Expand Down
48 changes: 41 additions & 7 deletions backend/core/src/email/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Jurisdiction } from "../jurisdictions/entities/jurisdiction.entity"
import { Language } from "../shared/types/language-enum"
import { JurisdictionsService } from "../jurisdictions/services/jurisdictions.service"
import { Translation } from "../translations/entities/translation.entity"
import { IdName, ListingEventType, Unit } from "../../types"
import { ListingEventType, Unit } from "../../types"
import { formatLocalDate } from "../shared/utils/format-local-date"
import { formatCommunityType } from "../listings/helpers"

Expand Down Expand Up @@ -62,6 +62,12 @@ const formatUnitDetails = (
return ""
}

type listingInfo = {
id: string
name: string
juris: string
}

@Injectable({ scope: Scope.REQUEST })
export class EmailService {
polyglot: Polyglot
Expand Down Expand Up @@ -552,9 +558,20 @@ export class EmailService {
)
}

public async requestApproval(user: User, listingInfo: IdName, emails: string[], appUrl: string) {
public async requestApproval(
user: User,
listingInfo: listingInfo,
emails: string[],
appUrl: string
) {
try {
const jurisdiction = await this.getUserJurisdiction(user)
const jurisdiction = listingInfo.juris
? await this.jurisdictionService.findOne({
where: {
id: listingInfo.juris,
},
})
: await this.getUserJurisdiction(user)
void (await this.loadTranslations(jurisdiction, Language.en))
await this.send(
emails,
Expand All @@ -572,9 +589,20 @@ export class EmailService {
}
}

public async changesRequested(user: User, listingInfo: IdName, emails: string[], appUrl: string) {
public async changesRequested(
user: User,
listingInfo: listingInfo,
emails: string[],
appUrl: string
) {
try {
const jurisdiction = await this.getUserJurisdiction(user)
const jurisdiction = listingInfo.juris
? await this.jurisdictionService.findOne({
where: {
id: listingInfo.juris,
},
})
: await this.getUserJurisdiction(user)
void (await this.loadTranslations(jurisdiction, Language.en))
await this.send(
emails,
Expand All @@ -594,12 +622,18 @@ export class EmailService {

public async listingApproved(
user: User,
listingInfo: IdName,
listingInfo: listingInfo,
emails: string[],
publicUrl: string
) {
try {
const jurisdiction = await this.getUserJurisdiction(user)
const jurisdiction = listingInfo.juris
? await this.jurisdictionService.findOne({
where: {
id: listingInfo.juris,
},
})
: await this.getUserJurisdiction(user)
void (await this.loadTranslations(jurisdiction, Language.en))
await this.send(
emails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ export class Jurisdiction extends AbstractEntity {
@Expose()
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
enableListingOpportunity: boolean | null

@Column({ type: "boolean", nullable: false, default: false })
@Expose()
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
enableGeocodingPreferences: boolean | null
}
16 changes: 11 additions & 5 deletions backend/core/src/listings/listings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,29 +415,35 @@ export class ListingsService {
const nonApprovingRoles = [UserRoleEnum.partner]
if (!params.approvingRoles.includes(UserRoleEnum.jurisdictionAdmin))
nonApprovingRoles.push(UserRoleEnum.jurisdictionAdmin)
if (params.status === ListingStatus.pendingReview) {
if (
params.status === ListingStatus.pendingReview &&
params.previousStatus !== ListingStatus.pendingReview
) {
const userInfo = await this.getUserEmailInfo(
params.approvingRoles,
params.listingInfo.id,
params.jurisId
)
await this.emailService.requestApproval(
params.user,
{ id: params.listingInfo.id, name: params.listingInfo.name },
{ id: params.listingInfo.id, name: params.listingInfo.name, juris: params.jurisId },
userInfo.emails,
this.configService.get("PARTNERS_PORTAL_URL")
)
}
// admin updates status to changes requested when approval requires partner changes
else if (params.status === ListingStatus.changesRequested) {
else if (
params.status === ListingStatus.changesRequested &&
params.previousStatus !== ListingStatus.changesRequested
) {
const userInfo = await this.getUserEmailInfo(
nonApprovingRoles,
params.listingInfo.id,
params.jurisId
)
await this.emailService.changesRequested(
params.user,
{ id: params.listingInfo.id, name: params.listingInfo.name },
{ id: params.listingInfo.id, name: params.listingInfo.name, juris: params.jurisId },
userInfo.emails,
this.configService.get("PARTNERS_PORTAL_URL")
)
Expand All @@ -458,7 +464,7 @@ export class ListingsService {
)
await this.emailService.listingApproved(
params.user,
{ id: params.listingInfo.id, name: params.listingInfo.name },
{ id: params.listingInfo.id, name: params.listingInfo.name, juris: params.jurisId },
userInfo.emails,
userInfo.publicUrl
)
Expand Down
17 changes: 17 additions & 0 deletions backend/core/src/migration/1699916046696-enable-geocoding-flag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class enableGeocodingFlag1699916046696 implements MigrationInterface {
name = "enableGeocodingFlag1699916046696"

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "jurisdictions" ADD "enable_geocoding_preferences" boolean NOT NULL DEFAULT false`
)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "jurisdictions" DROP COLUMN "enable_geocoding_preferences"`
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IsBoolean, IsNumber, IsOptional, IsString, ValidateNested } from "class
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"
import { ApiProperty } from "@nestjs/swagger"
import { MultiselectLink } from "./multiselect-link"
import { ValidationMethod } from "./validation-method-enum"

export class MultiselectOption {
@Expose()
Expand Down Expand Up @@ -38,7 +39,34 @@ export class MultiselectOption {
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty({ required: false })
collectAddress?: boolean | null
collectAddress?: boolean

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty({
required: false,
enum: ValidationMethod,
enumName: "ValidationMethod",
})
validationMethod?: ValidationMethod

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsNumber({}, { groups: [ValidationsGroupsEnum.default] })
@ApiProperty({ required: false })
radiusSize?: number

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty({ required: false })
collectName?: boolean

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty({ required: false })
collectRelationship?: boolean

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ValidationMethod {
radius = "radius",
map = "map",
none = "none",
}
1 change: 1 addition & 0 deletions backend/core/src/seeder/seeds/jurisdictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const activeJurisdictions: JurisdictionCreateDto[] = [
enableUtilitiesIncluded: true,
enableListingOpportunity: false,
listingApprovalPermissions: [UserRoleEnum.admin],
enableGeocodingPreferences: true,
},
]

Expand Down
2 changes: 2 additions & 0 deletions backend/core/test/jurisdictions/jurisdictions.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe("Jurisdictions", () => {
enableUtilitiesIncluded: false,
enablePartnerSettings: false,
enableListingOpportunity: false,
enableGeocodingPreferences: false,
})
.expect(201)

Expand Down Expand Up @@ -127,6 +128,7 @@ describe("Jurisdictions", () => {
enableUtilitiesIncluded: false,
enablePartnerSettings: false,
enableListingOpportunity: false,
enableGeocodingPreferences: false,
})
.expect(201)
expect(res.body).toHaveProperty("id")
Expand Down
14 changes: 9 additions & 5 deletions backend/core/test/listings/listings.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ describe("Listings", () => {
expect.objectContaining({
id: adminId,
}),
{ id: listing.id, name: listing.name },
{ id: listing.id, name: listing.name, juris: listing.jurisdiction.id },
expect.arrayContaining(["[email protected]", "[email protected]"]),
process.env.PARTNERS_PORTAL_URL
)
Expand All @@ -530,7 +530,7 @@ describe("Listings", () => {
expect.objectContaining({
id: adminId,
}),
{ id: listing.id, name: listing.name },
{ id: listing.id, name: listing.name, juris: listing.jurisdiction.id },
expect.arrayContaining(["[email protected]", "[email protected]"]),
process.env.PARTNERS_PORTAL_URL
)
Expand Down Expand Up @@ -561,7 +561,7 @@ describe("Listings", () => {
expect.objectContaining({
id: adminId,
}),
{ id: listing.id, name: listing.name },
{ id: listing.id, name: listing.name, juris: listing.jurisdiction.id },
expect.arrayContaining(["[email protected]", "[email protected]"]),
bayArea.publicUrl
)
Expand Down Expand Up @@ -617,7 +617,11 @@ describe("Listings", () => {
expect.objectContaining({
id: adminId,
}),
{ id: listingResponse.body.id, name: listingResponse.body.name },
{
id: listingResponse.body.id,
name: listingResponse.body.name,
juris: listingResponse.body.jurisdiction.id,
},
expect.arrayContaining(["[email protected]", "[email protected]"]),
process.env.PARTNERS_PORTAL_URL
)
Expand Down Expand Up @@ -650,7 +654,7 @@ describe("Listings", () => {
expect.objectContaining({
id: adminId,
}),
{ id: listing.id, name: listing.name },
{ id: listing.id, name: listing.name, juris: listing.jurisdiction.id },
expect.arrayContaining([
"[email protected]",
"[email protected]",
Expand Down
27 changes: 27 additions & 0 deletions backend/core/types/src/backend-swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3871,6 +3871,9 @@ export interface Jurisdiction {

/** */
enableUtilitiesIncluded: boolean

/** */
enableGeocodingPreferences: boolean
}

export interface User {
Expand Down Expand Up @@ -4306,6 +4309,9 @@ export interface JurisdictionCreate {
/** */
enableUtilitiesIncluded: boolean

/** */
enableGeocodingPreferences: boolean

/** */
multiselectQuestions: Id[]
}
Expand Down Expand Up @@ -4347,6 +4353,9 @@ export interface JurisdictionUpdate {
/** */
enableUtilitiesIncluded: boolean

/** */
enableGeocodingPreferences: boolean

/** */
multiselectQuestions: Id[]
}
Expand Down Expand Up @@ -4573,6 +4582,18 @@ export interface MultiselectOption {
/** */
collectAddress?: boolean

/** */
validationMethod?: ValidationMethod

/** */
radiusSize?: number

/** */
collectName?: boolean

/** */
collectRelationship?: boolean

/** */
exclusive?: boolean
}
Expand Down Expand Up @@ -6507,6 +6528,12 @@ export enum ListingEventType {
"lotteryResults" = "lotteryResults",
}

export enum ValidationMethod {
"radius" = "radius",
"map" = "map",
"none" = "none",
}

export enum ApplicationSection {
"programs" = "programs",
"preferences" = "preferences",
Expand Down
4 changes: 3 additions & 1 deletion shared-helpers/__tests__/testHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ export const multiselectQuestionPreference: MultiselectQuestion = {
url: "https://www.example.com",
},
],
collectAddress: false,
},
{ text: "Work in County", ordinal: 1 },
{ text: "Work in County", ordinal: 1, collectAddress: false },
],
applicationSection: ApplicationSection.preferences,
}
Expand Down Expand Up @@ -110,6 +111,7 @@ export const jurisdiction: Jurisdiction = {
enablePartnerSettings: true,
enableAccessibilityFeatures: false,
enableUtilitiesIncluded: true,
enableGeocodingPreferences: false,
id: "67c22813-6080-441d-a496-03f2d06f2635",
createdAt: new Date("2023-02-06T22:32:30.397Z"),
updatedAt: new Date("2023-02-21T21:57:58.346Z"),
Expand Down
Loading

0 comments on commit 5586408

Please sign in to comment.