Skip to content

Commit

Permalink
Merge branch 'main' into j-s/appeal-table
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored May 10, 2024
2 parents cc5f914 + 1e05ec6 commit bc611b9
Show file tree
Hide file tree
Showing 56 changed files with 2,132 additions and 1,466 deletions.
2 changes: 2 additions & 0 deletions apps/api/infra/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
OccupationalLicenses,
ShipRegistry,
DistrictCommissionersPCard,
DistrictCommissionersLicenses,
DirectorateOfImmigration,
Hunting,
SignatureCollection,
Expand Down Expand Up @@ -395,6 +396,7 @@ export const serviceSetup = (services: {
DrivingLicense,
Payment,
DistrictCommissionersPCard,
DistrictCommissionersLicenses,
Finance,
Education,
NationalRegistry,
Expand Down
56 changes: 32 additions & 24 deletions apps/contentful-apps/pages/fields/link-group-link-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { useCMA, useSDK } from '@contentful/react-apps-toolkit'

import { DEFAULT_LOCALE } from '../../constants'

const RETRY_COUNT = 5

const getSubpageContentTypeId = (pageContentTypeId?: string) => {
if (pageContentTypeId === 'organizationPage') return 'organizationSubpage'
if (pageContentTypeId === 'projectPage') return 'projectSubpage'
Expand All @@ -37,12 +39,6 @@ const useSubpageData = (): SubpageData => {
const fetchPageAbove = async (
pageAboveContentTypeId: string,
): Promise<boolean> => {
await new Promise((resolve) => {
setTimeout(() => {
resolve('')
}, 1000)
})

const pageAboveResponse = await cma.entry.getMany({
query: {
links_to_entry: sdk.entry.getSys().id,
Expand Down Expand Up @@ -71,30 +67,42 @@ const useSubpageData = (): SubpageData => {
return false
}

Promise.allSettled(
// Check for all possible pages and whether they are linking to us
[fetchPageAbove('organizationPage'), fetchPageAbove('projectPage')],
)
.then((results) => {
const subpageDataWasFound = results.some(
(result) => result.status === 'fulfilled' && result.value,
)
if (!subpageDataWasFound) {
setData({
loading: false,
pageAbove: null,
subpageContentType: null,
})
const main = async () => {
let success = false

for (let i = 0; i < RETRY_COUNT; i += 1) {
await new Promise((resolve) => {
setTimeout(() => {
resolve('')
}, (i + 1) * 1000)
})

try {
const results = await Promise.allSettled(
// Check for all possible pages and whether they are linking to us
[fetchPageAbove('organizationPage'), fetchPageAbove('projectPage')],
)
const subpageDataWasFound = results.some(
(result) => result.status === 'fulfilled' && result.value,
)
if (subpageDataWasFound) {
success = true
break
}
} catch (error) {
console.error(error)
}
})
.catch((error) => {
console.error(error)
}
if (!success) {
setData({
loading: false,
pageAbove: null,
subpageContentType: null,
})
})
}
}

main()
}, [cma.contentType, cma.entry, sdk.entry])

return data
Expand Down
2 changes: 2 additions & 0 deletions apps/download-service/infra/download-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Vehicles,
WorkMachines,
DistrictCommissionersLicenses,
DistrictCommissionersPCard,
} from '../../../infra/src/dsl/xroad'

export const serviceSetup = (services: {
Expand Down Expand Up @@ -54,6 +55,7 @@ export const serviceSetup = (services: {
UniversityCareers,
WorkMachines,
Education,
DistrictCommissionersPCard,
DistrictCommissionersLicenses,
)
.ingress({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export class UpdateCaseInput {
@Field(() => CaseIndictmentRulingDecision, { nullable: true })
readonly indictmentRulingDecision?: CaseIndictmentRulingDecision

@Allow()
@Field({ nullable: true })
readonly indictmentReviewerId?: string
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
CaseState,
completedCaseStates,
completedRequestCaseStates,
RequestSharedWithDefender,
} from '@island.is/judicial-system/types'

Expand All @@ -12,13 +12,13 @@ const RequestSharedWithDefenderAllowedStates: {
[RequestSharedWithDefender.READY_FOR_COURT]: [
CaseState.SUBMITTED,
CaseState.RECEIVED,
...completedCaseStates,
...completedRequestCaseStates,
],
[RequestSharedWithDefender.COURT_DATE]: [
CaseState.RECEIVED,
...completedCaseStates,
...completedRequestCaseStates,
],
[RequestSharedWithDefender.NOT_SHARED]: completedCaseStates,
[RequestSharedWithDefender.NOT_SHARED]: completedRequestCaseStates,
}

export const canDefenderViewRequest = (theCase: Case) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use strict'

const replaceEnum = require('sequelize-replace-enum-postgres').default

module.exports = {
async up(queryInterface) {
// replaceEnum does not support transactions
return replaceEnum({
queryInterface,
tableName: 'case',
columnName: 'state',
defaultValue: 'NEW',
newValues: [
'NEW',
'DRAFT',
'WAITING_FOR_CONFIRMATION',
'SUBMITTED',
'RECEIVED',
'MAIN_HEARING',
'ACCEPTED',
'REJECTED',
'DISMISSED',
'COMPLETED', //new value
'DELETED',
],
enumName: 'enum_case_state',
}).then(() =>
queryInterface.sequelize.transaction((transaction) =>
queryInterface.bulkUpdate(
'case',
{ state: 'COMPLETED' },
{ type: 'INDICTMENT', state: 'ACCEPTED' },
{ transaction },
),
),
)
},

async down(queryInterface) {
// replaceEnum does not support transactions
return queryInterface.sequelize
.transaction((transaction) =>
queryInterface.bulkUpdate(
'case',
{ state: 'ACCEPTED' },
{ type: 'INDICTMENT', state: 'COMPLETED' },
{ transaction },
),
)
.then(() =>
replaceEnum({
queryInterface,
tableName: 'case',
columnName: 'state',
defaultValue: 'NEW',
newValues: [
'NEW',
'DRAFT',
'WAITING_FOR_CONFIRMATION',
'SUBMITTED',
'RECEIVED',
'MAIN_HEARING',
'ACCEPTED',
'REJECTED',
'DISMISSED',
'DELETED',
],
enumName: 'enum_case_state',
}),
)
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
lowercase,
} from '@island.is/judicial-system/formatters'
import {
completedCaseStates,
completedRequestCaseStates,
isRestrictionCase,
SessionArrangements,
User,
Expand Down Expand Up @@ -279,7 +279,7 @@ const constructRestrictionCourtRecordPdf = (
)
addFooter(
doc,
completedCaseStates.includes(theCase.state) && user
completedRequestCaseStates.includes(theCase.state) && user
? formatMessage(courtRecord.smallPrint, {
actorName: user.name,
actorInstitution: user.institution?.name || 'NONE',
Expand Down Expand Up @@ -530,7 +530,7 @@ const constructInvestigationCourtRecordPdf = (
)
addFooter(
doc,
completedCaseStates.includes(theCase.state) && user
completedRequestCaseStates.includes(theCase.state) && user
? formatMessage(courtRecord.smallPrint, {
actorName: user.name,
actorInstitution: user.institution?.name || 'NONE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ export class CaseController {

const states = transitionCase(
transition.transition,
theCase.type,
theCase.state,
theCase.appealState,
)
Expand All @@ -311,6 +312,7 @@ export class CaseController {
case CaseTransition.ACCEPT:
case CaseTransition.REJECT:
case CaseTransition.DISMISS:
case CaseTransition.COMPLETE:
update.rulingDate = isIndictmentCase(theCase.type)
? nowFactory()
: theCase.courtEndTime
Expand All @@ -331,6 +333,7 @@ export class CaseController {
...update,
...transitionCase(
CaseTransition.APPEAL,
theCase.type,
states.state ?? theCase.state,
states.appealState ?? theCase.appealState,
),
Expand Down
27 changes: 13 additions & 14 deletions apps/judicial-system/backend/src/app/modules/case/case.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import {
CaseTransition,
CaseType,
CommentType,
completedCaseStates,
DateType,
EventType,
isCompletedCase,
isIndictmentCase,
isRestrictionCase,
NotificationType,
Expand Down Expand Up @@ -419,19 +419,17 @@ export class CaseService {

private async createCase(
caseToCreate: CreateCaseDto,
transaction?: Transaction,
transaction: Transaction,
): Promise<string> {
const theCase = await (transaction
? this.caseModel.create(
{
...caseToCreate,
state: isIndictmentCase(caseToCreate.type)
? CaseState.DRAFT
: undefined,
},
{ transaction },
)
: this.caseModel.create({ ...caseToCreate }))
const theCase = await this.caseModel.create(
{
...caseToCreate,
state: isIndictmentCase(caseToCreate.type)
? CaseState.DRAFT
: undefined,
},
{ transaction },
)

return theCase.id
}
Expand Down Expand Up @@ -1082,7 +1080,7 @@ export class CaseService {
user,
theCase.state,
)
} else if (completedCaseStates.includes(updatedCase.state)) {
} else if (isCompletedCase(updatedCase.state)) {
if (isIndictment) {
await this.addMessagesForCompletedIndictmentCaseToQueue(
updatedCase,
Expand Down Expand Up @@ -1359,6 +1357,7 @@ export class CaseService {
if (receivingCase) {
update.state = transitionCase(
CaseTransition.RECEIVE,
theCase.type,
theCase.state,
theCase.appealState,
).state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { literal, Op } from 'sequelize'

import {
CaseState,
completedCaseStates,
indictmentCases,
investigationCases,
restrictionCases,
Expand Down Expand Up @@ -44,14 +43,16 @@ export const archiveFilter = {
{
[Op.and]: [
{ type: investigationCases },
{ state: completedCaseStates },
{
state: [CaseState.ACCEPTED, CaseState.REJECTED, CaseState.DISMISSED],
},
{ ruling_date: { [Op.lt]: lifetime } },
],
},
{
[Op.and]: [
{ type: indictmentCases },
{ state: completedCaseStates },
{ state: CaseState.COMPLETED },
{ ruling_date: { [Op.lt]: indictmentLifetime } },
],
},
Expand Down
Loading

0 comments on commit bc611b9

Please sign in to comment.