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

feat(j-s): Display service status #16177

Merged
merged 85 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
ff2e71f
Locks subpoena fields when arraignment date has been set
gudjong Sep 25, 2024
4293520
Show subpoena status
oddsson Sep 25, 2024
3005fd4
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Sep 25, 2024
cf631db
Move arraignment date message handling to the server side
gudjong Sep 25, 2024
9192246
Updates tests and fixes date comparison
gudjong Sep 25, 2024
f6f6642
Change subpoena data structure
oddsson Sep 25, 2024
7f04ec8
Checkpoint
oddsson Sep 25, 2024
26e2c13
Map ServiceStatus to human readable text
oddsson Sep 25, 2024
2eb5958
Merge branch 'main' of github.com:island-is/island.is into j-s/indict…
gudjong Sep 25, 2024
f3a4c67
Merge branch 'main' of github.com:island-is/island.is into j-s/indict…
gudjong Sep 26, 2024
1a182ed
Defender and electronically service
oddsson Sep 26, 2024
c3e5bf9
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Sep 26, 2024
8124dbf
Schedules new subpoenas
gudjong Sep 26, 2024
5f3824a
Enforces operation ordering
gudjong Sep 26, 2024
33fe470
Only sends query parameters with new subpoena requests
gudjong Sep 26, 2024
e5d9426
Service to defender
oddsson Sep 26, 2024
b8e5d0f
Sort in asc order
oddsson Sep 26, 2024
332031f
Cleanup
oddsson Sep 26, 2024
9fd338d
Checkpoint
oddsson Sep 26, 2024
4c86a72
Merge branch 'main' of github.com:island-is/island.is into j-s/indict…
gudjong Sep 27, 2024
414ec71
Supports multiple subpoenas per defendant
gudjong Sep 27, 2024
778daa1
Updates unit tests
gudjong Sep 27, 2024
8331d61
Updates unit test
gudjong Sep 27, 2024
9d0bb0f
Merge branch 'main' of github.com:island-is/island.is into j-s/indict…
gudjong Sep 27, 2024
185d7dd
Fixes some typs and null reference guards
gudjong Sep 30, 2024
331ea57
Improved type declaration
gudjong Sep 30, 2024
798c7f0
Improved date formatting
gudjong Sep 30, 2024
0fd6b37
Improves indexing
gudjong Sep 30, 2024
478a009
Fixes spelling
gudjong Sep 30, 2024
5eadabe
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Sep 30, 2024
22d975f
Fixes indexing
gudjong Sep 30, 2024
cdaffc0
Fixes optional arguments
gudjong Sep 30, 2024
279f2f4
Removes redundant constructor
gudjong Sep 30, 2024
20bf0f1
Merge branch 'main' into j-s/indictment-case-new-subpoena
kodiakhq[bot] Sep 30, 2024
0cae899
Fix key error
oddsson Sep 30, 2024
4488df1
Merge branch 'j-s/indictment-case-new-subpoena' of github.com:island-…
oddsson Sep 30, 2024
de016e3
Remove unused import
oddsson Sep 30, 2024
e816352
Remove unused import
oddsson Sep 30, 2024
49b739c
Fix tests
oddsson Sep 30, 2024
4623825
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Sep 30, 2024
cc28e2f
Merge branch 'j-s/indictment-case-new-subpoena' of github.com:island-…
oddsson Sep 30, 2024
5698673
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Sep 30, 2024
d6a350e
Checkpoint
oddsson Sep 30, 2024
5fdf789
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Sep 30, 2024
deff5b5
Checkpoint
oddsson Sep 30, 2024
1c65b49
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Oct 1, 2024
df0c842
Checkpoint
oddsson Oct 1, 2024
ee3b101
Save subpoena status in DB
oddsson Oct 1, 2024
8155869
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Oct 2, 2024
b5c0ba5
Error handling
oddsson Oct 2, 2024
99ea3bc
Move error handling
oddsson Oct 2, 2024
02dcc7f
Update police.service.ts
unakb Oct 2, 2024
6d72860
Merge
oddsson Oct 2, 2024
b513dbc
Update police.service.ts
unakb Oct 2, 2024
856e5c5
Update police.service.ts
unakb Oct 2, 2024
4a2145f
Update police.service.ts
unakb Oct 2, 2024
c68dd1e
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Oct 2, 2024
42d7781
Error handling in frontend
oddsson Oct 2, 2024
57fb69c
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Oct 3, 2024
48d0279
Cleanup
oddsson Oct 3, 2024
f5a4083
Cleanup
oddsson Oct 3, 2024
c447ec9
Cleanup
oddsson Oct 3, 2024
ce21c01
Revert processing
oddsson Oct 3, 2024
b2bd115
Cleanup
oddsson Oct 3, 2024
0cd6e05
Error handling
oddsson Oct 3, 2024
9c6300f
Add to prosecutor screen
oddsson Oct 3, 2024
fc50785
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Oct 3, 2024
3ea937e
Remove double encoding code
oddsson Oct 3, 2024
6d4dad1
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Oct 4, 2024
1d9bb2a
Hide ServiceAnnouncement if no subpoena id
oddsson Oct 4, 2024
4060591
Merge branch 'main' into j-s/show-subpoena-status
unakb Oct 4, 2024
265a601
Use correct data
oddsson Oct 4, 2024
46a08ef
Merge branch 'main' of github.com:island-is/island.is into j-s/show-s…
oddsson Oct 4, 2024
4bd035a
Merge branch 'j-s/show-subpoena-status' of github.com:island-is/islan…
oddsson Oct 4, 2024
7d0eeb8
Add defender national id
oddsson Oct 4, 2024
227b99d
Fix Slack log
oddsson Oct 4, 2024
fa1b71e
Rename interface
oddsson Oct 4, 2024
2ceb311
fix(j-s): xrd fixes
unakb Oct 4, 2024
37b3077
Merge branch 'j-s/show-subpoena-status' of https://github.com/island-…
unakb Oct 4, 2024
995e2bc
Update app.service.ts
unakb Oct 4, 2024
57ca30c
Update updateSubpoena.dto.ts
unakb Oct 4, 2024
a11885c
fix(j-s): module import
unakb Oct 6, 2024
04907bb
Merge branch 'main' into j-s/show-subpoena-status
kodiakhq[bot] Oct 6, 2024
684c512
Revert "fix(j-s): module import"
unakb Oct 6, 2024
915d5cd
Update createTestingPoliceModule.ts
unakb Oct 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { Institution } from '../institution'
import {
PoliceCaseFile,
PoliceCaseInfo,
SubpoenaStatus,
UploadPoliceCaseFileResponse,
} from '../police'
import { backendModuleConfig } from './backend.config'
Expand Down Expand Up @@ -306,6 +307,13 @@ export class BackendService extends DataSource<{ req: Request }> {
return this.get(`case/${caseId}/policeFiles`)
}

getSubpoenaStatus(
caseId: string,
subpoenaId: string,
): Promise<SubpoenaStatus> {
return this.get(`case/${caseId}/subpoenaStatus/${subpoenaId}`)
}

getPoliceCaseInfo(caseId: string): Promise<PoliceCaseInfo[]> {
return this.get(`case/${caseId}/policeCaseInfo`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { Defendant } from './models/defendant.model'
export { DeleteDefendantResponse } from './models/delete.response'
export { CivilClaimant } from './models/civilClaimant.model'
export { DeleteCivilClaimantResponse } from './models/deleteCivilClaimant.response'
export { Subpoena } from './models/subpoena.model'
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Field, ID, ObjectType } from '@nestjs/graphql'
import { Field, ID, ObjectType, registerEnumType } from '@nestjs/graphql'

import { ServiceStatus } from '@island.is/judicial-system/types'

registerEnumType(ServiceStatus, { name: 'ServiceStatus' })

@ObjectType()
export class Subpoena {
Expand All @@ -14,15 +18,27 @@ export class Subpoena {
@Field(() => String, { nullable: true })
subpoenaId?: string

@Field(() => Boolean, { nullable: true })
acknowledged?: boolean
@Field(() => String, { nullable: true })
defendantId?: string

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

@Field(() => ServiceStatus, { nullable: true })
serviceStatus?: ServiceStatus

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

@Field(() => String, { nullable: true })
registeredBy?: string
servedBy?: string
oddsson marked this conversation as resolved.
Show resolved Hide resolved

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

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Allow } from 'class-validator'

import { Field, ID, InputType } from '@nestjs/graphql'

@InputType()
export class SubpoenaStatusQueryInput {
@Allow()
@Field(() => ID)
readonly caseId!: string

@Allow()
@Field(() => ID)
readonly subpoenaId!: string
}
1 change: 1 addition & 0 deletions apps/judicial-system/api/src/app/modules/police/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { PoliceCaseInfo } from './models/policeCaseInfo.model'
export { SubpoenaStatus } from './models/subpoenaStatus.model'
export { PoliceCaseFile } from './models/policeCaseFile.model'
export { UploadPoliceCaseFileResponse } from './models/uploadPoliceCaseFile.response'
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Field, ObjectType } from '@nestjs/graphql'

import { ServiceStatus } from '@island.is/judicial-system/types'

@ObjectType()
export class SubpoenaStatus {
@Field(() => ServiceStatus)
readonly serviceStatus!: ServiceStatus

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

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

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

@Field(() => String, { nullable: true })
readonly defenderNationalId?: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import type { User } from '@island.is/judicial-system/types'
import { BackendService } from '../backend'
import { PoliceCaseFilesQueryInput } from './dto/policeCaseFiles.input'
import { PoliceCaseInfoQueryInput } from './dto/policeCaseInfo.input'
import { SubpoenaStatusQueryInput } from './dto/subpoenaStatus.input'
import { UploadPoliceCaseFileInput } from './dto/uploadPoliceCaseFile.input'
import { PoliceCaseFile } from './models/policeCaseFile.model'
import { PoliceCaseInfo } from './models/policeCaseInfo.model'
import { SubpoenaStatus } from './models/subpoenaStatus.model'
import { UploadPoliceCaseFileResponse } from './models/uploadPoliceCaseFile.response'

@UseGuards(JwtGraphQlAuthGuard)
Expand Down Expand Up @@ -49,6 +51,26 @@ export class PoliceResolver {
)
}

@Query(() => SubpoenaStatus, { nullable: true })
subpoenaStatus(
@Args('input', { type: () => SubpoenaStatusQueryInput })
input: SubpoenaStatusQueryInput,
@CurrentGraphQlUser() user: User,
@Context('dataSources')
{ backendService }: { backendService: BackendService },
): Promise<SubpoenaStatus> {
this.logger.debug(
`Getting subpoena status for subpoena ${input.subpoenaId} of case ${input.caseId}`,
)

return this.auditTrailService.audit(
user.id,
AuditedAction.GET_SUBPOENA_STATUS,
backendService.getSubpoenaStatus(input.caseId, input.subpoenaId),
input.caseId,
)
}

@Query(() => [PoliceCaseInfo], { nullable: true })
policeCaseInfo(
@Args('input', { type: () => PoliceCaseInfoQueryInput })
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
'use strict'

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((transaction) =>
queryInterface
.changeColumn(
'subpoena',
'acknowledged',
{ type: Sequelize.STRING, allowNull: true },
{ transaction },
)
.then(
() =>
queryInterface.renameColumn(
'subpoena',
'acknowledged',
'service_status',
{ transaction },
),

queryInterface.renameColumn(
'subpoena',
'acknowledged_date',
'service_date',
{ transaction },
),

queryInterface.renameColumn(
'subpoena',
'registered_by',
'served_by',
{ transaction },
),

queryInterface.addColumn(
'subpoena',
'defender_national_id',
{
type: Sequelize.STRING,
allowNull: true,
},
{ transaction },
),
),
)
},

down: (queryInterface) => {
return queryInterface.sequelize.transaction((transaction) =>
queryInterface
.renameColumn('subpoena', 'service_status', 'acknowledged', {
transaction,
})
.then(
() =>
queryInterface.changeColumn(
'subpoena',
'acknowledged',
{
type: 'BOOLEAN USING CAST("acknowledged" as BOOLEAN)',
allowNull: true,
},
{ transaction },
),

queryInterface.renameColumn(
'subpoena',
'service_date',
'acknowledged_date',
{ transaction },
),

queryInterface.renameColumn(
'subpoena',
'served_by',
'registered_by',
{ transaction },
),

queryInterface.removeColumn('subpoena', 'defender_national_id', {
transaction,
}),
),
)
},
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import CryptoJS from 'crypto-js'
import format from 'date-fns/format'
import { Base64 } from 'js-base64'
import { Op } from 'sequelize'
import { Sequelize } from 'sequelize-typescript'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { CanActivate } from '@nestjs/common'

import { JwtAuthGuard, RolesGuard } from '@island.is/judicial-system/auth'
import { indictmentCases } from '@island.is/judicial-system/types'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from '@island.is/judicial-system/types'

import { type Case } from '../case'
import { CaseString } from '../case/models/caseString.model'
import { DateLog } from '../case/models/dateLog.model'
import { eventModuleConfig } from './event.config'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { CanActivate } from '@nestjs/common'

import { RolesGuard } from '@island.is/judicial-system/auth'

import { CaseExistsGuard, CaseReadGuard } from '../../../case'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import {
} from '@island.is/judicial-system/auth'
import type { User } from '@island.is/judicial-system/types'

import { prosecutorRepresentativeRule, prosecutorRule } from '../../guards'
import {
districtCourtJudgeRule,
prosecutorRepresentativeRule,
prosecutorRule,
} from '../../guards'
import {
Case,
CaseExistsGuard,
Expand All @@ -30,6 +34,7 @@ import {
CaseReadGuard,
CurrentCase,
} from '../case'
import { Subpoena } from '../subpoena'
import { UploadPoliceCaseFileDto } from './dto/uploadPoliceCaseFile.dto'
import { PoliceCaseFile } from './models/policeCaseFile.model'
import { PoliceCaseInfo } from './models/policeCaseInfo.model'
Expand Down Expand Up @@ -69,6 +74,26 @@ export class PoliceController {
return this.policeService.getAllPoliceCaseFiles(theCase.id, user)
}

@RolesRules(
prosecutorRule,
prosecutorRepresentativeRule,
districtCourtJudgeRule,
)
@Get('subpoenaStatus/:subpoenaId')
@ApiOkResponse({
type: Subpoena,
description: 'Gets subpoena status',
})
getSubpoenaStatus(
@Param('subpoenaId') subpoenaId: string,
@CurrentCase() theCase: Case,
@CurrentHttpUser() user: User,
): Promise<Subpoena> {
this.logger.debug(`Gets subpoena status in case ${theCase.id}`)

return this.policeService.getSubpoenaStatus(subpoenaId, user)
}

@RolesRules(prosecutorRule, prosecutorRepresentativeRule)
@UseInterceptors(CaseOriginalAncestorInterceptor)
@Get('policeCaseInfo')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { forwardRef, Module } from '@nestjs/common'

import { AwsS3Module, CaseModule, EventModule } from '../index'
import { AwsS3Module, CaseModule, EventModule, SubpoenaModule } from '../index'
import { PoliceController } from './police.controller'
import { PoliceService } from './police.service'

Expand All @@ -9,6 +9,7 @@ import { PoliceService } from './police.service'
forwardRef(() => CaseModule),
forwardRef(() => EventModule),
forwardRef(() => AwsS3Module),
forwardRef(() => SubpoenaModule),
],
providers: [PoliceService],
exports: [PoliceService],
Expand Down
Loading