From 6e7ccf4e7c94b31858eb7696f1565300ce1fbaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Tue, 10 Sep 2024 12:17:51 +0000 Subject: [PATCH 1/2] Allow prison system users to see rulings --- .../modules/case/interceptors/caseFile.interceptor.ts | 11 ++++++++--- .../src/app/modules/file/guards/caseFileCategory.ts | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/case/interceptors/caseFile.interceptor.ts b/apps/judicial-system/backend/src/app/modules/case/interceptors/caseFile.interceptor.ts index d7d74fb30a5c..7dd3dfdf9e71 100644 --- a/apps/judicial-system/backend/src/app/modules/case/interceptors/caseFile.interceptor.ts +++ b/apps/judicial-system/backend/src/app/modules/case/interceptors/caseFile.interceptor.ts @@ -12,8 +12,10 @@ import { CaseAppealState, CaseFileCategory, isDefenceUser, + isIndictmentCase, isPrisonStaffUser, isPrisonSystemUser, + isRestrictionCase, User, } from '@island.is/judicial-system/types' @@ -33,15 +35,18 @@ export class CaseFileInterceptor implements NestInterceptor { if ( isPrisonStaffUser(user) || - data.appealState !== CaseAppealState.COMPLETED + (isRestrictionCase(data.type) && + data.appealState !== CaseAppealState.COMPLETED) ) { data.caseFiles?.splice(0, data.caseFiles.length) } else if (isPrisonSystemUser(user)) { data.caseFiles?.splice( 0, data.caseFiles.length, - ...data.caseFiles.filter( - (cf) => cf.category === CaseFileCategory.APPEAL_RULING, + ...data.caseFiles.filter((cf) => + isIndictmentCase(data.type) + ? cf.category === CaseFileCategory.RULING + : cf.category === CaseFileCategory.APPEAL_RULING, ), ) } diff --git a/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts b/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts index 2d8d88353f35..60f536547067 100644 --- a/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts +++ b/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts @@ -23,4 +23,7 @@ export const defenderCaseFileCategoriesForIndictmentCases = [ CaseFileCategory.DEFENDANT_CASE_FILE, ] -export const prisonAdminCaseFileCategories = [CaseFileCategory.APPEAL_RULING] +export const prisonAdminCaseFileCategories = [ + CaseFileCategory.APPEAL_RULING, + CaseFileCategory.RULING, +] From 37dd3ee6a0315f7b94547f728e2be4765afc3e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Tue, 10 Sep 2024 13:53:02 +0000 Subject: [PATCH 2/2] Fix tests --- .../file/guards/test/limitedAccessViewCaseFileGuard.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts b/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts index e4e7672dc2d6..b46d12eda442 100644 --- a/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts @@ -224,7 +224,10 @@ describe('Limited Access View Case File Guard', () => { describe.each(Object.keys(CaseType))('for %s cases', (type) => { describe.each(completedCaseStates)('in state %s', (state) => { - const allowedCaseFileCategories = [CaseFileCategory.APPEAL_RULING] + const allowedCaseFileCategories = [ + CaseFileCategory.APPEAL_RULING, + CaseFileCategory.RULING, + ] describe.each(allowedCaseFileCategories)( 'prison system users can view %s',