Skip to content

Commit

Permalink
Merge branch 'main' into j-s/defender-case-files-connection
Browse files Browse the repository at this point in the history
  • Loading branch information
gudjong authored Nov 28, 2024
2 parents 5bda7ff + 1fdf64d commit 56b1a69
Show file tree
Hide file tree
Showing 100 changed files with 2,873 additions and 767 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'

module.exports = {
async up(queryInterface, Sequelize) {
return queryInterface.sequelize.transaction((transaction) =>
queryInterface.bulkUpdate(
'defendant',
{
national_id: queryInterface.sequelize.literal(
`REPLACE(national_id, '-', '')`,
),
},
{ national_id: { [Sequelize.Op.like]: '%-%' } },
{ transaction },
),
)
},

async down() {
// Optional: Implement logic to revert the changes if necessary
return
},
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Transform } from 'class-transformer'
import {
ArrayMinSize,
IsArray,
Expand All @@ -7,6 +8,7 @@ import {
IsOptional,
IsString,
MaxLength,
MinLength,
} from 'class-validator'

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
Expand All @@ -20,6 +22,8 @@ import {
RequestSharedWithDefender,
} from '@island.is/judicial-system/types'

import { nationalIdTransformer } from '../../../transformers'

export class CreateCaseDto {
@IsNotEmpty()
@IsEnum(CaseType)
Expand All @@ -32,40 +36,42 @@ export class CreateCaseDto {
readonly indictmentSubtypes?: IndictmentSubtypeMap

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly description?: string

@IsNotEmpty()
@IsArray()
@ArrayMinSize(1)
@MaxLength(255, { each: true })
@IsString({ each: true })
@MaxLength(255, { each: true })
@ApiProperty({ type: String, isArray: true })
readonly policeCaseNumbers!: string[]

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderName?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MinLength(10)
@MaxLength(10)
@Transform(nationalIdTransformer)
@ApiPropertyOptional({ type: String })
readonly defenderNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderEmail?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderPhoneNumber?: string

Expand All @@ -75,8 +81,8 @@ export class CreateCaseDto {
readonly requestSharedWithDefender?: RequestSharedWithDefender

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly leadInvestigator?: string

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { IsNotEmpty, IsString } from 'class-validator'
import { Transform } from 'class-transformer'
import { IsNotEmpty, IsString, MaxLength, MinLength } from 'class-validator'

import { ApiProperty } from '@nestjs/swagger'

import { nationalIdTransformer } from '../../../transformers'

export class InternalCasesDto {
@IsNotEmpty()
@IsString()
@MinLength(10)
@MaxLength(10)
@Transform(nationalIdTransformer)
@ApiProperty({ type: String })
readonly nationalId!: string
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Transform } from 'class-transformer'
import {
ArrayMinSize,
IsArray,
Expand All @@ -6,12 +7,16 @@ import {
IsNotEmpty,
IsOptional,
IsString,
MaxLength,
MinLength,
} from 'class-validator'

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'

import { CaseType, Gender } from '@island.is/judicial-system/types'

import { nationalIdTransformer } from '../../../transformers'

export class InternalCreateCaseDto {
@IsNotEmpty()
@IsEnum(CaseType)
Expand All @@ -27,11 +32,17 @@ export class InternalCreateCaseDto {

@IsNotEmpty()
@IsString()
@MinLength(10)
@MaxLength(10)
@Transform(nationalIdTransformer)
@ApiProperty({ type: String })
readonly prosecutorNationalId!: string

@IsNotEmpty()
@IsString()
@MinLength(10)
@MaxLength(10)
@Transform(nationalIdTransformer)
@ApiProperty({ type: String })
readonly accusedNationalId!: string

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Type } from 'class-transformer'
import { Transform, Type } from 'class-transformer'
import {
ArrayMinSize,
IsArray,
Expand All @@ -10,6 +10,7 @@ import {
IsString,
IsUUID,
MaxLength,
MinLength,
ValidateNested,
} from 'class-validator'

Expand All @@ -36,6 +37,8 @@ import {
UserRole,
} from '@island.is/judicial-system/types'

import { nationalIdTransformer } from '../../../transformers'

class UpdateDateLog {
@IsOptional()
@Type(() => Date)
Expand All @@ -44,8 +47,8 @@ class UpdateDateLog {
readonly date?: Date

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly location?: string
}
Expand All @@ -62,40 +65,42 @@ export class UpdateCaseDto {
readonly indictmentSubtypes?: IndictmentSubtypeMap

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly description?: string

@IsOptional()
@IsArray()
@ArrayMinSize(1)
@MaxLength(255, { each: true })
@IsString({ each: true })
@MaxLength(255, { each: true })
@ApiPropertyOptional({ type: String, isArray: true })
readonly policeCaseNumbers?: string[]

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderName?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MinLength(10)
@MaxLength(10)
@Transform(nationalIdTransformer)
@ApiPropertyOptional({ type: String })
readonly defenderNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderEmail?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderPhoneNumber?: string

Expand All @@ -115,8 +120,8 @@ export class UpdateCaseDto {
readonly courtId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly leadInvestigator?: string

Expand All @@ -133,8 +138,8 @@ export class UpdateCaseDto {
readonly requestedCourtDate?: Date

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly translator?: string

Expand Down Expand Up @@ -217,8 +222,8 @@ export class UpdateCaseDto {
readonly sharedWithProsecutorsOfficeId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly courtCaseNumber?: string

Expand All @@ -240,8 +245,8 @@ export class UpdateCaseDto {
readonly courtDate?: UpdateDateLog

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly courtLocation?: string

Expand Down Expand Up @@ -419,8 +424,8 @@ export class UpdateCaseDto {
readonly defendantStatementDate?: Date

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly appealCaseNumber?: string

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import { Transform } from 'class-transformer'
import {
IsBoolean,
IsEnum,
IsOptional,
IsString,
MaxLength,
MinLength,
} from 'class-validator'

import { ApiPropertyOptional } from '@nestjs/swagger'

import { DefenderChoice, Gender } from '@island.is/judicial-system/types'

import { nationalIdTransformer } from '../../../transformers'

export class CreateDefendantDto {
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean })
readonly noNationalId?: boolean

@IsOptional()
@MaxLength(255)
@IsString()
@MinLength(10)
@MaxLength(10)
@Transform(nationalIdTransformer)
@ApiPropertyOptional({ type: String })
readonly nationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly name?: string

Expand All @@ -34,38 +40,40 @@ export class CreateDefendantDto {
readonly gender?: Gender

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly address?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly citizenship?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderName?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MinLength(10)
@MaxLength(10)
@Transform(nationalIdTransformer)
@ApiPropertyOptional({ type: String })
readonly defenderNationalId?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderEmail?: string

@IsOptional()
@MaxLength(255)
@IsString()
@MaxLength(255)
@ApiPropertyOptional({ type: String })
readonly defenderPhoneNumber?: string

Expand Down
Loading

0 comments on commit 56b1a69

Please sign in to comment.