Skip to content

Commit

Permalink
Handle inspecting custom risks properly as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritsvanrees committed Oct 18, 2024
1 parent b3ffa71 commit 2e8c285
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/euphorie/client/browser/risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ def proceed_to_next(self, reply):
url = f"{base_url}/{next_view_name}"
return self.request.response.redirect(url)

elif _next == "add_custom_risk":
elif _next == "add_custom_risk" and self.webhelpers.can_edit_session:
sql_module = (
Session.query(model.Module)
.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
<tal:block replace="tile:statusmessages" />
<h1 i18n:translate="label_custom_risks">Custom risks</h1>

<p tal:content="structure module/description">
<p tal:condition="webhelpers/can_edit_session"
tal:content="structure module/description"
>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem
accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae
ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt
Expand All @@ -37,9 +39,11 @@
action="${context/absolute_url}/@@identification"
method="post"
data-pat-inject="history: record; source: #content; target: #content; &amp;&amp; source: #other-risks; target: #other-risks"
tal:condition="webhelpers/can_edit_session"
>
<p>
<button class="pat-button default"
disabled="${python:'disabled' if not webhelpers.can_edit_session else None}"
name="next"
type="submit"
value="add_custom_risk"
Expand Down
12 changes: 10 additions & 2 deletions src/euphorie/client/browser/templates/risk_actionplan.pt
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,16 @@
name="next"
type="submit"
value="next"
i18n:translate="label_save_and_continue"
>Save and continue</button>
>
<tal:save condition="webhelpers/can_edit_session"
i18n:translate="label_save_and_continue"
>Save and continue
</tal:save>
<tal:continue condition="not:webhelpers/can_edit_session"
i18n:translate="label_next"
>Next
</tal:continue>
</button>
</p>
</form>
</tal:def>
Expand Down
64 changes: 42 additions & 22 deletions src/euphorie/client/browser/templates/risk_identification_custom.pt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<metal:actions fill-slot="page-actions">
<div class="toolbar-section quick-functions"
id="assessment-toolbar-quick-functions"
tal:condition="webhelpers/can_edit_session"
>
<a class="icon icon-trash pat-modal"
href="${context/absolute_url}/@@confirmation-delete-risk#document-content"
Expand All @@ -48,6 +49,7 @@


<fieldset class="content-mirror risk-title pat-inject pat-autosubmit pat-subform"
disabled="${python:'disabled' if not webhelpers.can_edit_session else None}"
data-pat-autosubmit="1000ms"
data-pat-inject="source: #steps; target: #steps ${python:'&amp;&amp; source: #evaluation; target: #evaluation' if not view.skip_evaluation else None} ${python:'&amp;&amp; source: #slide-content-1; target: #slide-content-1' if webhelpers.use_training_module else None}"
>
Expand All @@ -70,6 +72,7 @@
<tal:existing-measures condition="view/use_existing_measures">
<fieldset class="add-measure-in-place-other pat-checklist measures-in-place pat-clone pat-inject pat-subform"
id="add-measure-in-place"
disabled="${python:'disabled' if not webhelpers.can_edit_session else None}"
data-pat-autosubmit="1000ms"
data-pat-clone="template: #in-place-measure-template; trigger-element: #add-in-place-measure-button; remove-confirmation: Are you sure you want to remove this existing measure?"
data-pat-inject="source: #add-measure-in-place; target: #add-measure-in-place ${python:webhelpers.use_training_module and '&amp;&amp; source: #slide-preview-existing-measures; target: #slide-preview-existing-measures' or None}"
Expand Down Expand Up @@ -153,7 +156,9 @@
</tal:existing-measures>


<fieldset class="pat-checklist radio pat-rich">
<fieldset class="pat-checklist radio pat-rich"
disabled="${python:'disabled' if not webhelpers.can_edit_session else None}"
>
<legend>
<tal:intro content="structure view/intro_questions" />
</legend>
Expand Down Expand Up @@ -200,6 +205,7 @@
>
<p class="problem-description"><strong>${here/title}</strong></p>
<fieldset class="pat-checklist radio"
disabled="${python:'disabled' if not webhelpers.can_edit_session else None}"
tal:define="
value context/priority;
"
Expand Down Expand Up @@ -237,7 +243,9 @@
Information
</h3>
<div class="panel-content">
<fieldset class="vertical row">
<fieldset class="vertical row"
disabled="${python:'disabled' if not webhelpers.can_edit_session else None}"
>
<div class="eight columns">

<div class="pat-rich-editor pat-rich toolbar-detached">
Expand Down Expand Up @@ -314,26 +322,38 @@
value="previous"
i18n:translate="label_previous"
>Previous</button>
<button class="pat-button continue"
name="next"
type="submit"
value="add_custom_risk"
tal:condition="not:view/has_next_risk"
i18n:translate="label_save_and_add_new"
>Save and add new risk</button>
<button class="pat-button continue"
name="next"
type="submit"
value="next"
tal:condition="view/has_next_risk"
i18n:translate="label_save_and_continue"
>Save and continue</button>
<button class="pat-button float-after"
name="next"
type="submit"
value="actionplan"
i18n:translate="label_save_and_finish"
>Save and finish</button>
<tal:can-edit condition="webhelpers/can_edit_session">
<button class="pat-button continue"
name="next"
type="submit"
value="add_custom_risk"
tal:condition="not:view/has_next_risk"
i18n:translate="label_save_and_add_new"
>Save and add new risk</button>
<button class="pat-button continue"
name="next"
type="submit"
value="next"
tal:condition="view/has_next_risk"
i18n:translate="label_save_and_continue"
>Save and continue</button>
<button class="pat-button float-after"
name="next"
type="submit"
value="actionplan"
i18n:translate="label_save_and_finish"
>Save and finish</button>
</tal:can-edit>
<tal:cannot-edit condition="not:webhelpers/can_edit_session">
<button class="pat-button continue"
name="next"
type="submit"
value="next"
i18n:translate="label_next"
>Next</button>

</tal:cannot-edit>

</p>

</form>
Expand Down

0 comments on commit 2e8c285

Please sign in to comment.