-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
405 additions
and
58 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
backend/core/migrations/0046_riskassessment_ebios_rm_study.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 5.1.4 on 2024-12-11 11:07 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0045_alter_appliedcontrol_category_and_more"), | ||
("ebios_rm", "0003_remove_ebiosrmstudy_risk_assessments"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="riskassessment", | ||
name="ebios_rm_study", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="risk_assessments", | ||
to="ebios_rm.ebiosrmstudy", | ||
verbose_name="EBIOS RM study", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
backend/ebios_rm/migrations/0003_remove_ebiosrmstudy_risk_assessments.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated by Django 5.1.4 on 2024-12-11 11:07 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("ebios_rm", "0002_alter_roto_target_objective"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="ebiosrmstudy", | ||
name="risk_assessments", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/+layout.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { loadDetail } from '$lib/utils/load'; | ||
import type { PageServerLoad } from './$types'; | ||
import { getModelInfo } from '$lib/utils/crud'; | ||
|
||
export const load: PageServerLoad = async (event) => { | ||
return await loadDetail({ event, model: getModelInfo('ebios-rm'), id: event.params.id }); | ||
}; |
45 changes: 41 additions & 4 deletions
45
frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/+page.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
import { loadDetail } from '$lib/utils/load'; | ||
import type { PageServerLoad } from './$types'; | ||
import { defaultWriteFormAction } from '$lib/utils/actions'; | ||
import { BASE_API_URL } from '$lib/utils/constants'; | ||
import { getModelInfo } from '$lib/utils/crud'; | ||
import { modelSchema } from '$lib/utils/schemas'; | ||
import type { ModelInfo } from '$lib/utils/types'; | ||
import { type Actions } from '@sveltejs/kit'; | ||
import { superValidate } from 'sveltekit-superforms'; | ||
import { zod } from 'sveltekit-superforms/adapters'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ params, fetch }) => { | ||
const URLModel = 'ebios-rm'; | ||
const model: ModelInfo = getModelInfo(URLModel); | ||
|
||
const endpoint = model.endpointUrl | ||
? `${BASE_API_URL}/${model.endpointUrl}/${params.id}/` | ||
: `${BASE_API_URL}/${model.urlModel}/${params.id}/`; | ||
const res = await fetch(endpoint); | ||
const data = await res.json(); | ||
|
||
const initialData = { | ||
risk_matrix: data.risk_matrix.id, | ||
ebios_rm_study: params.id | ||
}; | ||
|
||
const createSchema = modelSchema('risk-assessments'); | ||
const createRiskAnalysisForm = await superValidate(initialData, zod(createSchema), { | ||
errors: false | ||
}); | ||
|
||
return { createRiskAnalysisForm, model: getModelInfo('risk-assessments') }; | ||
}; | ||
|
||
export const load: PageServerLoad = async (event) => { | ||
return await loadDetail({ event, model: getModelInfo('ebios-rm'), id: event.params.id }); | ||
export const actions: Actions = { | ||
create: async (event) => { | ||
// const redirectToWrittenObject = Boolean(event.params.model === 'entity-assessments'); | ||
return defaultWriteFormAction({ | ||
event, | ||
urlModel: 'risk-assessments', | ||
action: 'create' | ||
// redirectToWrittenObject: redirectToWrittenObject | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.