Skip to content

Commit

Permalink
1381/listings management, application addresses (#1425)
Browse files Browse the repository at this point in the history
* 1381 wip

* last toggleable fields

* add office hours

* translations

* details

* Add applicationPickUpAddressType and applicationDropOffAddressType columns to Listing model

* new backend fields for dropoff address

* details page

* submit issues

* show address types

* remove unused application methods

* cleanup

* application submission notes

* default values load in the form

* default values for postmark date

* typing issues w add page

* use existing addresses on listing page

* can really share addresses

* Add additionalApplicationSubmissionNotes migration (#1441)

* pr feedback

* pr feedback pr 2

* changelog

* type yes/no

* combine types

* fixup address fxn

* update migration

* office hours fix

* test updated config yaml

* testing circleci config update

* updated circleci config test

* Updated config.yml

* Updated config.yml

* update migration file

Co-authored-by: Michal Plebanski <michalp@airnauts.com>
Co-authored-by: Sean Albert <smabert@gmail.com>
  • Loading branch information
3 people authored Jul 2, 2021
1 parent 37197bd commit 32b916c
Show file tree
Hide file tree
Showing 33 changed files with 1,110 additions and 231 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ All notable changes to this project will be documented in this file. The format
- list and retrieve methods to `/assets` endpoint
- added result_id to Listing model, allow creating `image` and `result` through listing endpoint (cascade)
- added resultLink, isWaitlistOpen and waitlistOpenSpots to Listing model
- Added applicationPickUpAddressType and applicationDropOffAddressType columns to Listing model ([#1425](https://github.com/bloom-housing/bloom/pull/1425)) (Michał Plebański)

- Changed:

Expand Down Expand Up @@ -67,6 +68,7 @@ All notable changes to this project will be documented in this file. The format
- Add Building Features section to listing management ([#1412](https://github.com/bloom-housing/bloom/pull/1412)) (Emily Jablonski)
- Adds units to listings ([#1448](https://github.com/bloom-housing/bloom/pull/1448))
- Add Rankings and Results section to listing management ([#1433](https://github.com/bloom-housing/bloom/pull/1433)) (Emily Jablonski)
- Add Application Address section to listing management ([#1425](https://github.com/bloom-housing/bloom/pull/1425)) (Emily Jablonski)

- Fixed:

Expand Down
33 changes: 5 additions & 28 deletions backend/core/archer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
AmiChart,
ApplicationMethodType,
CountyCode,
CSVFormattingType,
Listing,
ListingStatus,
} from "./types"
import { AmiChart, CountyCode, CSVFormattingType, Listing, ListingStatus } from "./types"

export const SanMateoHUD2019: AmiChart = {
id: "ami_chart_id",
Expand Down Expand Up @@ -247,6 +240,9 @@ export const ArcherListing: Listing = {
applicationOpenDate: new Date("2019-12-31T15:22:57.000-07:00"),
applicationPickUpAddress: undefined,
applicationPickUpAddressOfficeHours: "",
applicationDropOffAddress: null,
applicationDropOffAddressOfficeHours: null,
applicationMailingAddress: null,
countyCode: CountyCode["San Jose"],
depositMax: "",
disableUnitsAccordion: false,
Expand All @@ -272,26 +268,7 @@ export const ArcherListing: Listing = {
longitude: -121.91071,
},
applicationDueDate: new Date("2019-12-31T15:22:57.000-07:00"),
applicationMethods: [
{
type: ApplicationMethodType.POBox,
acceptsPostmarkedApplications: true,
label: "",
externalReference: "",
},
{
type: ApplicationMethodType.LeasingAgent,
acceptsPostmarkedApplications: true,
label: "",
externalReference: "",
},
{
type: ApplicationMethodType.PaperPickup,
acceptsPostmarkedApplications: true,
label: "",
externalReference: "",
},
],
applicationMethods: [],
applicationOrganization: "98 Archer Street",
// TODO confirm not used anywhere
// applicationPhone: "(408) 217-8562",
Expand Down
12 changes: 9 additions & 3 deletions backend/core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,9 @@ export interface Listing {
/** */
property: Property

/** */
additionalApplicationSubmissionNotes?: string

/** */
applicationAddress: CombinedApplicationAddressTypes

Expand Down Expand Up @@ -1869,6 +1872,9 @@ export interface ListingCreate {
/** */
property: Id

/** */
additionalApplicationSubmissionNotes?: string

/** */
applicationAddress: CombinedApplicationAddressTypes

Expand Down Expand Up @@ -2061,6 +2067,9 @@ export interface ListingUpdate {
/** */
property: Id

/** */
additionalApplicationSubmissionNotes?: string

/** */
applicationAddress: CombinedApplicationAddressTypes

Expand Down Expand Up @@ -3328,9 +3337,6 @@ export enum ApplicationMethodType {
"Internal" = "Internal",
"FileDownload" = "FileDownload",
"ExternalLink" = "ExternalLink",
"PaperPickup" = "PaperPickup",
"POBox" = "POBox",
"LeasingAgent" = "LeasingAgent",
}

export enum InputType {
Expand Down
25 changes: 0 additions & 25 deletions backend/core/scripts/listings-update-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,6 @@ const [listingFilePath] = process.argv.slice(2)

function convertApplicationMethods(listing: any) {
const applicationMethods: Array<ApplicationMethodDto> = []
if (listing.acceptsPostmarkedApplications) {
applicationMethods.push(
plainToClass(ApplicationMethodDto, {
type: ApplicationMethodType.LeasingAgent,
acceptsPostmarkedApplications: listing.acceptsPostmarkedApplications as boolean,
})
)
}
if (listing.acceptingApplicationsByPoBox) {
applicationMethods.push(
plainToClass(ApplicationMethodDto, {
type: ApplicationMethodType.POBox,
acceptsPostmarkedApplications: false,
})
)
}
if (listing.blankPaperApplicationCanBePickedUp) {
applicationMethods.push(
plainToClass(ApplicationMethodDto, {
type: ApplicationMethodType.PaperPickup,
acceptsPostmarkedApplications: false,
})
)
}

if ("attachments" in listing) {
listing.attachments.forEach((attachment) => {
Expand Down Expand Up @@ -64,7 +40,6 @@ function convertApplicationMethods(listing: any) {

;[
"acceptingApplicationsAtLeasingAgent",
"acceptingApplicationsByPoBox",
"acceptingOnlineApplications",
"acceptsPostmarkedApplications",
"blankPaperApplicationCanBePickedUp",
Expand Down
42 changes: 36 additions & 6 deletions backend/core/src/listings/dto/listing.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import { AssetCreateDto, AssetDto, AssetUpdateDto } from "../../assets/dto/asset

export class ListingDto extends OmitType(Listing, [
"applications",
"applicationAddress",
"applicationFlaggedSets",
"applicationPickUpAddress",
"image",
"jurisdiction",
"leasingAgents",
Expand Down Expand Up @@ -63,6 +61,18 @@ export class ListingDto extends OmitType(Listing, [
@Type(() => AddressDto)
applicationPickUpAddress: AddressDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => AddressCreateDto)
applicationDropOffAddress: AddressCreateDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => AddressCreateDto)
applicationMailingAddress: AddressCreateDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
Expand Down Expand Up @@ -291,8 +301,6 @@ export class ListingCreateDto extends OmitType(ListingDto, [
"createdAt",
"updatedAt",
"preferences",
"applicationAddress",
"applicationPickUpAddress",
"image",
"leasingAgentAddress",
"leasingAgents",
Expand Down Expand Up @@ -337,6 +345,18 @@ export class ListingCreateDto extends OmitType(ListingDto, [
@Type(() => AddressCreateDto)
applicationPickUpAddress: AddressCreateDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => AddressCreateDto)
applicationDropOffAddress: AddressCreateDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => AddressCreateDto)
applicationMailingAddress: AddressCreateDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
Expand Down Expand Up @@ -460,8 +480,6 @@ export class ListingUpdateDto extends OmitType(ListingDto, [
"createdAt",
"updatedAt",
"preferences",
"applicationAddress",
"applicationPickUpAddress",
"image",
"leasingAgentAddress",
"urlSlug",
Expand Down Expand Up @@ -523,6 +541,18 @@ export class ListingUpdateDto extends OmitType(ListingDto, [
@Type(() => AddressUpdateDto)
applicationPickUpAddress: AddressUpdateDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => AddressCreateDto)
applicationDropOffAddress: AddressCreateDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => AddressCreateDto)
applicationMailingAddress: AddressCreateDto | null

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
Expand Down
47 changes: 47 additions & 0 deletions backend/core/src/listings/entities/listing.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { Jurisdiction } from "../../jurisdictions/entities/jurisdiction.entity"
import { ReservedCommunityType } from "../../reserved-community-type/entities/reserved-community-type.entity"
import { Asset } from "../../assets/entities/asset.entity"
import { AssetCreateDto } from "../../assets/dto/asset.dto"
import { ListingApplicationAddressType } from "../types/listing-application-address-type"

@Entity({ name: "listings" })
class Listing extends BaseEntity {
Expand All @@ -63,6 +64,12 @@ class Listing extends BaseEntity {
@Type(() => Date)
updatedAt: Date

@Column({ type: "text", nullable: true })
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsString({ groups: [ValidationsGroupsEnum.default] })
additionalApplicationSubmissionNotes?: string | null

@OneToMany(() => Preference, (preference) => preference.listing, { cascade: true })
@Expose()
@ValidateNested({ groups: [ValidationsGroupsEnum.default], each: true })
Expand Down Expand Up @@ -151,6 +158,46 @@ class Listing extends BaseEntity {
@IsString({ groups: [ValidationsGroupsEnum.default] })
applicationPickUpAddressOfficeHours: string | null

@Column({ type: "enum", enum: ListingApplicationAddressType, nullable: true })
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsEnum(ListingApplicationAddressType, { groups: [ValidationsGroupsEnum.default] })
@ApiProperty({
enum: ListingApplicationAddressType,
enumName: "ListingApplicationAddressType",
})
applicationPickUpAddressType?: ListingApplicationAddressType | null

@Column({ type: "jsonb", nullable: true })
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => AddressDto)
applicationDropOffAddress: AddressDto | null

@Column({ type: "text", nullable: true })
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsString({ groups: [ValidationsGroupsEnum.default] })
applicationDropOffAddressOfficeHours: string | null

@Column({ type: "enum", enum: ListingApplicationAddressType, nullable: true })
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsEnum(ListingApplicationAddressType, { groups: [ValidationsGroupsEnum.default] })
@ApiProperty({
enum: ListingApplicationAddressType,
enumName: "ListingApplicationAddressType",
})
applicationDropOffAddressType?: ListingApplicationAddressType | null

@Column({ type: "jsonb", nullable: true })
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => AddressDto)
applicationMailingAddress: AddressDto | null

@Column({ type: "text", nullable: true })
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ export enum ApplicationMethodType {
Internal = "Internal",
FileDownload = "FileDownload",
ExternalLink = "ExternalLink",
PaperPickup = "PaperPickup",
POBox = "POBox",
LeasingAgent = "LeasingAgent",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum ListingApplicationAddressType {
leasingAgent = "leasingAgent",
mailingAddress = "mailingAddress",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class addPickUpAndDropOffColumnsToListing1624959910201 implements MigrationInterface {
name = "addPickUpAndDropOffColumnsToListing1624959910201"

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TYPE "listings_application_pick_up_address_type_enum" AS ENUM('leasingAgent', 'mailingAddress')`);
await queryRunner.query(`ALTER TABLE "listings" ADD "application_pick_up_address_type" "listings_application_pick_up_address_type_enum"`);

await queryRunner.query(`CREATE TYPE "listings_application_drop_off_address_type_enum" AS ENUM('leasingAgent', 'mailingAddress')`);
await queryRunner.query(`ALTER TABLE "listings" ADD "application_drop_off_address_type" "listings_application_drop_off_address_type_enum"`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "application_drop_off_address_type"`);
await queryRunner.query(`DROP TYPE "listings_application_drop_off_address_type_enum"`);
await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "application_pick_up_address_type"`);
await queryRunner.query(`DROP TYPE "listings_application_pick_up_address_type_enum"`);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class applicationDropOffAndMailingAddresses1624985582782 implements MigrationInterface {
name = 'applicationDropOffAndMailingAddresses1624985582782'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "listings" ADD "application_mailing_address" jsonb`);
await queryRunner.query(`ALTER TABLE "listings" ADD "application_drop_off_address_office_hours" text`);
await queryRunner.query(`ALTER TABLE "listings" ADD "application_drop_off_address" jsonb`);

}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "application_mailing_address"`);
await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "application_drop_off_address_office_hours" text`);
await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "application_drop_off_address" jsonb`);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class addAdditionalNotesColumnToListing1625041988613 implements MigrationInterface {
name = 'addAdditionalNotesColumnToListing1625041988613'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "listings" ADD "additional_application_submission_notes" text`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "additional_application_submission_notes"`);
}

}
Loading

0 comments on commit 32b916c

Please sign in to comment.