Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): unitCreate and UnitUpdateDto now require only IdDto for… #1956

Merged
merged 6 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ All notable changes to this project will be documented in this file. The format

## Unreleased

## Frontend

- Added:

- Support PDF uploads or webpage links for building selection criteria ([#1893](https://github.com/bloom-housing/bloom/pull/1893)) (Jared White)
Expand Down Expand Up @@ -116,6 +114,7 @@ All notable changes to this project will be documented in this file. The format
- Adds Jurisdictions to users, listings and translations. The migration script assigns the first alpha sorted jurisdiction to users, so this piece may need to be changed for Detroit, if they have more than Detroit in their DB. [#1776](https://github.com/bloom-housing/bloom/pull/1776)
- Added the optional jurisdiction setting notificationsSignUpURL, which now appears on the home page if set ([#1802](https://github.com/bloom-housing/bloom/pull/1802)) (Emily Jablonski)
- Adds Listings managment validations required for publishing a Listing [#1850](https://github.com/bloom-housing/bloom/pull/1850) (Michał Plebański & Emily Jablonski)
- Add UnitCreateDto model changes to prevent form submission from creating UnitType, UnitRentType and AccessibilityType from creating a new DB row on each submission. ([#1956](https://github.com/bloom-housing/bloom/pull/1956))

- Changed:

Expand Down
2 changes: 1 addition & 1 deletion backend/core/src/listings/dto/listing-create.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { PreferenceCreateDto } from "../../preferences/dto/preference.dto"
import { AddressCreateDto } from "../../shared/dto/address.dto"
import { ListingEventCreateDto } from "./listing-event.dto"
import { AssetCreateDto } from "../../assets/dto/asset.dto"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { UnitsSummaryCreateDto } from "../../units-summary/dto/units-summary.dto"
import { ListingDto } from "./listing.dto"
import { ApplicationMethodCreateDto } from "../../application-methods/dto/application-method.dto"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"

export class ListingCreateDto extends OmitType(ListingDto, [
"id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
IsPhoneNumber,
} from "class-validator"
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { OmitType } from "@nestjs/swagger"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"

export class ListingPublishedCreateDto extends OmitType(ListingCreateDto, [
"assets",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
IsPhoneNumber,
} from "class-validator"
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"
import { UnitUpdateDto } from "../../units/dto/unit.dto"
import { ListingUpdateDto } from "./listing-update.dto"
import { ListingReviewOrder } from "../types/listing-review-order-enum"
import { OmitType } from "@nestjs/swagger"
import { AssetUpdateDto } from "../../assets/dto/asset.dto"
import { UnitUpdateDto } from "../../units/dto/unit-update.dto"

export class ListingPublishedUpdateDto extends OmitType(ListingUpdateDto, [
"assets",
Expand Down
2 changes: 1 addition & 1 deletion backend/core/src/listings/dto/listing-update.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { PreferenceUpdateDto } from "../../preferences/dto/preference.dto"
import { AddressUpdateDto } from "../../shared/dto/address.dto"
import { ListingEventUpdateDto } from "./listing-event.dto"
import { AssetUpdateDto } from "../../assets/dto/asset.dto"
import { UnitUpdateDto } from "../../units/dto/unit.dto"
import { UnitsSummaryUpdateDto } from "../../units-summary/dto/units-summary.dto"
import { ListingDto } from "./listing.dto"
import { ApplicationMethodUpdateDto } from "../../application-methods/dto/application-method.dto"
import { UnitUpdateDto } from "../../units/dto/unit-update.dto"

export class ListingUpdateDto extends OmitType(ListingDto, [
"id",
Expand Down
20 changes: 2 additions & 18 deletions backend/core/src/listings/dto/listing.dto.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
import { Listing } from "../entities/listing.entity"
import { Expose, plainToClass, Transform, Type } from "class-transformer"
import {
ArrayMaxSize,
IsDate,
IsDefined,
IsNumber,
IsOptional,
IsString,
IsUUID,
ValidateNested,
IsNumberString,
IsEnum,
IsArray,
IsBooleanString,
} from "class-validator"
import { IsDefined, IsNumber, IsOptional, IsString, ValidateNested } from "class-validator"
import moment from "moment"
import { PreferenceDto } from "../../preferences/dto/preference.dto"
import { OmitType } from "@nestjs/swagger"
import { AddressDto } from "../../shared/dto/address.dto"
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"
import { ListingStatus } from "../types/listing-status-enum"
import { AvailabilityFilterEnum, ListingFilterKeys } from "../types/listing-filter-keys-enum"
import { PaginationFactory, PaginationAllowsAllQueryParams } from "../../shared/dto/pagination.dto"
import { BaseFilter } from "../../shared/dto/filter.dto"
import { UnitCreateDto, UnitDto, UnitUpdateDto } from "../../units/dto/unit.dto"
import { UnitDto } from "../../units/dto/unit.dto"
import { ReservedCommunityTypeDto } from "../../reserved-community-type/dto/reserved-community-type.dto"
import { AssetDto } from "../../assets/dto/asset.dto"
import { ListingEventDto } from "./listing-event.dto"
Expand Down
4 changes: 3 additions & 1 deletion backend/core/src/property/dto/property.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { Exclude, Expose, Type } from "class-transformer"
import { IsDate, IsDefined, IsOptional, IsUUID, ValidateNested } from "class-validator"
import { Property } from "../entities/property.entity"
import { AddressDto, AddressUpdateDto } from "../../shared/dto/address.dto"
import { UnitCreateDto, UnitDto, UnitUpdateDto } from "../../units/dto/unit.dto"
import { UnitDto } from "../../units/dto/unit.dto"
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"
import { UnitUpdateDto } from "../../units/dto/unit-update.dto"

export class PropertyDto extends OmitType(Property, [
"units",
Expand Down
2 changes: 1 addition & 1 deletion backend/core/src/seeds/listings/listing-coliseum-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { CSVFormattingType } from "../../csv/types/csv-formatting-type-enum"
import { ListingStatus } from "../../listings/types/listing-status-enum"
import { Listing } from "../../listings/entities/listing.entity"
import { BaseEntity, DeepPartial } from "typeorm"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { ListingDefaultSeed } from "./listing-default-seed"
import { UnitStatus } from "../../units/types/unit-status-enum"
import { ListingReviewOrder } from "../../listings/types/listing-review-order-enum"
import { CountyCode } from "../../shared/types/county-code"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"

const coliseumProperty: PropertySeedType = {
accessibility:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ListingDefaultSeed } from "./listing-default-seed"
import { getDefaultUnits, getDefaultProperty, getDefaultAmiChart } from "./shared"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { BaseEntity } from "typeorm"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"
import { CountyCode } from "../../shared/types/county-code"

export class ListingDefaultBmrChartSeed extends ListingDefaultSeed {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ListingDefaultSeed } from "./listing-default-seed"
import { getDefaultProperty } from "./shared"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { BaseEntity } from "typeorm"
import { AmiChartCreateDto } from "../../ami-charts/dto/ami-chart.dto"
import { UnitSeedType } from "./listings"
import { AmiChart } from "../../ami-charts/entities/ami-chart.entity"
import { UnitStatus } from "../../units/types/unit-status-enum"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"
import { CountyCode } from "../../shared/types/county-code"

export const missingAmiLevelsChart: Omit<AmiChartCreateDto, "jurisdiction"> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ListingDefaultSeed } from "./listing-default-seed"
import { getDefaultAmiChart, getDefaultProperty } from "./shared"
import { tritonAmiChart } from "./listing-triton-seed"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { BaseEntity } from "typeorm"
import { UnitSeedType } from "./listings"
import { UnitStatus } from "../../units/types/unit-status-enum"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"
import { CountyCode } from "../../shared/types/county-code"

export class ListingDefaultMultipleAMIAndPercentages extends ListingDefaultSeed {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ListingDefaultSeed } from "./listing-default-seed"
import { getDefaultAmiChart, getDefaultUnits, getDefaultProperty } from "./shared"
import { tritonAmiChart } from "./listing-triton-seed"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { BaseEntity } from "typeorm"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"
import { CountyCode } from "../../shared/types/county-code"

export class ListingDefaultMultipleAMI extends ListingDefaultSeed {
Expand Down
2 changes: 1 addition & 1 deletion backend/core/src/seeds/listings/listing-default-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { AmiChart } from "../../ami-charts/entities/ami-chart.entity"
import { Property } from "../../property/entities/property.entity"
import { Unit } from "../../units/entities/unit.entity"
import { User } from "../../auth/entities/user.entity"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import {
getDefaultAmiChart,
getDefaultAssets,
Expand All @@ -22,6 +21,7 @@ import {
PriorityTypes,
} from "./shared"
import { ApplicationMethod } from "../../application-methods/entities/application-method.entity"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"
import { Jurisdiction } from "../../jurisdictions/entities/jurisdiction.entity"
import { CountyCode } from "../../shared/types/county-code"

Expand Down
2 changes: 1 addition & 1 deletion backend/core/src/seeds/listings/listing-triton-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { ListingStatus } from "../../listings/types/listing-status-enum"
import { CSVFormattingType } from "../../csv/types/csv-formatting-type-enum"
import { AmiChart } from "../../ami-charts/entities/ami-chart.entity"
import { ListingDefaultSeed } from "./listing-default-seed"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { BaseEntity, DeepPartial } from "typeorm"
import { Listing } from "../../listings/entities/listing.entity"
import { UnitStatus } from "../../units/types/unit-status-enum"
import { ListingReviewOrder } from "../../listings/types/listing-review-order-enum"
import { CountyCode } from "../../shared/types/county-code"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"

export const tritonAmiChart: Omit<AmiChartCreateDto, "jurisdiction"> = {
name: "San Jose TCAC 2019",
Expand Down
2 changes: 1 addition & 1 deletion backend/core/src/seeds/listings/listings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PropertyCreateDto } from "../../property/dto/property.dto"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { ApplicationMethodCreateDto } from "../../application-methods/dto/application-method.dto"
import { PreferenceCreateDto } from "../../preferences/dto/preference.dto"
import { ListingEventCreateDto } from "../../listings/dto/listing-event.dto"
Expand All @@ -8,6 +7,7 @@ import { AmiChartCreateDto } from "../../ami-charts/dto/ami-chart.dto"
import { BaseEntity } from "typeorm"
import { UserCreateDto } from "../../auth/dto/user-create.dto"
import { ListingCreateDto } from "../../listings/dto/listing-create.dto"
import { UnitCreateDto } from "../../units/dto/unit-create.dto"

export type PropertySeedType = Omit<
PropertyCreateDto,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { OmitType } from "@nestjs/swagger"
import { UnitAmiChartOverrideDto } from "./unit-ami-chart-override.dto"

export class UnitAmiChartOverrideCreateDto extends OmitType(UnitAmiChartOverrideDto, [
"id",
"createdAt",
"updatedAt",
] as const) {}
28 changes: 28 additions & 0 deletions backend/core/src/units/dto/unit-ami-chart-override-update.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { OmitType } from "@nestjs/swagger"
import { Expose, Type } from "class-transformer"
import { IsDate, IsOptional, IsUUID } from "class-validator"
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"
import { UnitAmiChartOverrideDto } from "./unit-ami-chart-override.dto"

export class UnitAmiChartOverrideUpdateDto extends OmitType(UnitAmiChartOverrideDto, [
"id",
"createdAt",
"updatedAt",
] as const) {
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsUUID(4, { groups: [ValidationsGroupsEnum.default] })
id?: string

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsDate({ groups: [ValidationsGroupsEnum.default] })
@Type(() => Date)
createdAt?: Date

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsDate({ groups: [ValidationsGroupsEnum.default] })
@Type(() => Date)
updatedAt?: Date
}
32 changes: 0 additions & 32 deletions backend/core/src/units/dto/unit-ami-chart-override.dto.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
import { OmitType } from "@nestjs/swagger"
import { UnitAmiChartOverride } from "../entities/unit-ami-chart-override.entity"
import { Expose, Type } from "class-transformer"
import { IsDate, IsOptional, IsUUID } from "class-validator"
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"

export class UnitAmiChartOverrideDto extends OmitType(UnitAmiChartOverride, [] as const) {}

export class UnitAmiChartOverrideCreateDto extends OmitType(UnitAmiChartOverrideDto, [
"id",
"createdAt",
"updatedAt",
] as const) {}

export class UnitAmiChartOverrideUpdateDto extends OmitType(UnitAmiChartOverrideDto, [
"id",
"createdAt",
"updatedAt",
] as const) {
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsUUID(4, { groups: [ValidationsGroupsEnum.default] })
id?: string

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsDate({ groups: [ValidationsGroupsEnum.default] })
@Type(() => Date)
createdAt?: Date

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsDate({ groups: [ValidationsGroupsEnum.default] })
@Type(() => Date)
updatedAt?: Date
}
51 changes: 51 additions & 0 deletions backend/core/src/units/dto/unit-create.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { OmitType } from "@nestjs/swagger"
import { Expose, Type } from "class-transformer"
import { IsDefined, IsOptional, ValidateNested } from "class-validator"
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"
import { IdDto } from "../../shared/dto/id.dto"
import { UnitDto } from "./unit.dto"
import { UnitAmiChartOverrideCreateDto } from "./unit-ami-chart-override-create.dto"

export class UnitCreateDto extends OmitType(UnitDto, [
"id",
"createdAt",
"updatedAt",
"amiChart",
"unitType",
"unitRentType",
"priorityType",
"amiChartOverride",
] as const) {
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => IdDto)
amiChart?: IdDto

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsDefined({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => IdDto)
unitType?: IdDto

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsDefined({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => IdDto)
unitRentType?: IdDto

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsDefined({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => IdDto)
priorityType?: IdDto

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => UnitAmiChartOverrideCreateDto)
amiChartOverride?: UnitAmiChartOverrideCreateDto
}
Loading