Skip to content

Commit

Permalink
Merge branch 'main' into efs_fixes_7_06
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jun 7, 2024
2 parents d7a4ab8 + fbf8efc commit b8ee629
Show file tree
Hide file tree
Showing 37 changed files with 752 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CaseState,
CaseType,
IndictmentCaseReviewDecision,
IndictmentDecision,
} from '@island.is/judicial-system/types'

import { Defendant } from '../../defendant'
Expand Down Expand Up @@ -122,6 +123,9 @@ export class CaseListEntry {
@Field(() => String, { nullable: true })
readonly indictmentVerdictAppealDeadline?: string

@Field(() => IndictmentDecision, { nullable: true })
readonly indictmentDecision?: IndictmentDecision

@Field(() => CaseIndictmentRulingDecision, { nullable: true })
readonly indictmentRulingDecision?: CaseIndictmentRulingDecision
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
CaseLegalProvisions,
CaseType,
IndictmentCaseReviewDecision,
IndictmentDecision,
RequestSharedWithDefender,
SessionArrangements,
UserRole,
Expand Down Expand Up @@ -486,6 +487,12 @@ export class UpdateCaseInput {
readonly indictmentReviewerId?: string

@Allow()
@IsOptional()
@Field(() => IndictmentCaseReviewDecision, { nullable: true })
readonly indictmentReviewDecision?: IndictmentCaseReviewDecision

@Allow()
@IsOptional()
@Field(() => IndictmentDecision, { nullable: true })
readonly indictmentDecision?: IndictmentDecision
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
CaseType,
CourtDocument,
IndictmentCaseReviewDecision,
IndictmentDecision,
RequestSharedWithDefender,
SessionArrangements,
UserRole,
Expand Down Expand Up @@ -51,6 +52,7 @@ registerEnumType(CaseIndictmentRulingDecision, {
registerEnumType(IndictmentCaseReviewDecision, {
name: 'IndictmentCaseReviewDecision',
})
registerEnumType(IndictmentDecision, { name: 'IndictmentDecision' })

@ObjectType()
class DateLog {
Expand Down Expand Up @@ -434,4 +436,7 @@ export class Case {

@Field(() => String, { nullable: true })
readonly indictmentVerdictAppealDeadline?: string

@Field(() => IndictmentDecision, { nullable: true })
readonly indictmentDecision?: IndictmentDecision
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'

module.exports = {
async up(queryInterface, Sequelize) {
return queryInterface.sequelize.transaction((t) =>
queryInterface.addColumn(
'case',
'indictment_decision',
{
type: Sequelize.STRING,
allowNull: true,
},
{ transaction: t },
),
)
},

async down(queryInterface) {
return queryInterface.sequelize.transaction((t) =>
queryInterface.removeColumn('case', 'indictment_decision', {
transaction: t,
}),
)
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
CaseType,
CourtDocument,
IndictmentCaseReviewDecision,
IndictmentDecision,
RequestSharedWithDefender,
SessionArrangements,
UserRole,
Expand Down Expand Up @@ -496,4 +497,9 @@ export class UpdateCaseDto {
@IsEnum(IndictmentCaseReviewDecision)
@ApiPropertyOptional({ enum: IndictmentCaseReviewDecision })
readonly indictmentReviewDecision?: IndictmentCaseReviewDecision

@IsOptional()
@IsEnum(IndictmentDecision)
@ApiPropertyOptional({ enum: IndictmentDecision })
readonly indictmentDecision?: IndictmentDecision
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const districtCourtFields: (keyof UpdateCaseDto)[] = [
'indictmentReturnedExplanation',
'postponedIndefinitelyExplanation',
'indictmentRulingDecision',
'indictmentDecision',
]

const courtOfAppealsFields: (keyof UpdateCaseDto)[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class CaseListInterceptor implements NestInterceptor {
)?.comment,
indictmentReviewer: theCase.indictmentReviewer,
indictmentReviewDecision: theCase.indictmentReviewDecision,
indictmentDecision: theCase.indictmentDecision,
indictmentRulingDecision: theCase.indictmentRulingDecision,
}
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
CaseType,
CourtDocument,
IndictmentCaseReviewDecision,
IndictmentDecision,
RequestSharedWithDefender,
SessionArrangements,
UserRole,
Expand Down Expand Up @@ -1014,6 +1015,17 @@ export class Case extends Model {
@ApiPropertyOptional({ enum: IndictmentCaseReviewDecision })
indictmentReviewDecision?: IndictmentCaseReviewDecision

/**********
* The judge's pending decision in indictment cases - example: POSTPONING
**********/
@Column({
type: DataType.ENUM,
allowNull: true,
values: Object.values(IndictmentDecision),
})
@ApiPropertyOptional({ enum: IndictmentDecision })
indictmentDecision?: IndictmentDecision

/**********
* The md5 hash of the confirmed generated indictment
* Only used for traffic violation cases
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
applyDecorators,
Body,
Controller,
Get,
Expand All @@ -8,7 +9,7 @@ import {
Query,
UseGuards,
} from '@nestjs/common'
import { ApiOkResponse, ApiTags } from '@nestjs/swagger'
import { ApiOkResponse, ApiResponse, ApiTags } from '@nestjs/swagger'

import type { User } from '@island.is/auth-nest-tools'
import { CurrentUser, IdsUserGuard } from '@island.is/auth-nest-tools'
Expand All @@ -20,6 +21,17 @@ import { CasesResponse } from './models/cases.response'
import { SubpoenaResponse } from './models/subpoena.response'
import { CaseService } from './case.service'

const CommonApiResponses = () => {
return applyDecorators(
ApiResponse({ status: 400, description: 'Bad Request' }),
ApiResponse({
status: 401,
description: 'User is not authorized to perform this action',
}),
ApiResponse({ status: 500, description: 'Internal Server Error' }),
)
}

@Controller('api')
@ApiTags('cases')
@UseGuards(IdsUserGuard)
Expand All @@ -31,7 +43,16 @@ export class CaseController {
) {}

@Get('cases')
@ApiOkResponse({ type: String, description: 'Get all cases' })
@ApiOkResponse({
type: CasesResponse,
description:
'Returns all accessible indictment cases for authenticated user',
})
@CommonApiResponses()
@ApiResponse({
status: 404,
description: 'No cases found for authenticated user',
})
async getAllCases(
@CurrentUser() user: User,
@Query() query?: { lang: string },
Expand All @@ -42,7 +63,15 @@ export class CaseController {
}

@Get('case/:caseId')
@ApiOkResponse({ type: CaseResponse, description: 'Get case by id' })
@ApiOkResponse({
type: CaseResponse,
description: 'Returns indictment case by case id',
})
@CommonApiResponses()
@ApiResponse({
status: 404,
description: 'Case for given case id and authenticated user not found',
})
async getCase(
@Param('caseId') caseId: string,
@CurrentUser() user: User,
Expand All @@ -56,7 +85,12 @@ export class CaseController {
@Get('case/:caseId/subpoena')
@ApiOkResponse({
type: () => SubpoenaResponse,
description: 'Get subpoena by case id',
description: 'Returns subpoena by case id',
})
@CommonApiResponses()
@ApiResponse({
status: 404,
description: 'Subpoena for given case id and authenticated user not found',
})
async getSubpoena(
@Param('caseId') caseId: string,
Expand All @@ -70,7 +104,16 @@ export class CaseController {
@Patch('case/:caseId/subpoena')
@ApiOkResponse({
type: () => SubpoenaResponse,
description: 'Update subpoena info',
description: 'Updates subpoena info',
})
@CommonApiResponses()
@ApiResponse({
status: 404,
description: 'Subpoena for given case id and authenticated user not found',
})
@ApiResponse({
status: 403,
description: 'User is not allowed to update subpoena',
})
async updateSubpoena(
@CurrentUser() user: User,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ import { ApiProperty } from '@nestjs/swagger'

import { InternalCaseResponse } from './internal/internalCase.response'

class IndictmentCaseData {
class Items {
@ApiProperty({ type: String })
caseNumber!: string
label!: string

@ApiProperty({ type: Object })
groups!: Groups[]
@ApiProperty({ type: String })
value?: string

@ApiProperty({ type: String, enum: ['email', 'tel'] })
linkType?: 'email' | 'tel'
}

class Groups {
@ApiProperty({ type: String })
label!: string

@ApiProperty({ type: Object })
@ApiProperty({ type: [Items] })
items!: Items[]
}

class Items {
@ApiProperty({ type: String })
label!: string

class IndictmentCaseData {
@ApiProperty({ type: String })
value?: string
caseNumber!: string

@ApiProperty({ type: String })
linkType?: 'email' | 'tel'
@ApiProperty({ type: [Groups] })
groups!: Groups[]
}

export class CaseResponse {
@ApiProperty({ type: Object })
@ApiProperty({ type: IndictmentCaseData })
data!: IndictmentCaseData

static fromInternalCaseResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
InternalServerErrorException,
UseInterceptors,
} from '@nestjs/common'
import { ApiCreatedResponse, ApiTags } from '@nestjs/swagger'
import { ApiOkResponse, ApiResponse, ApiTags } from '@nestjs/swagger'

import { type Logger, LOGGER_PROVIDER } from '@island.is/logging'

Expand All @@ -24,10 +24,11 @@ export class DefenderController {
) {}

@Get('defenders')
@ApiCreatedResponse({
@ApiOkResponse({
type: [Defender],
description: 'Retrieves a list of defenders',
description: 'Returns a list of defenders',
})
@ApiResponse({ status: 500, description: 'Failed to retrieve defenders' })
async getLawyers(): Promise<Defender[]> {
try {
this.logger.debug('Retrieving lawyers from lawyer registry')
Expand Down
Loading

0 comments on commit b8ee629

Please sign in to comment.