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

Multiple answers backport 1 #720

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 23 additions & 17 deletions src/euphorie/client/browser/risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,19 +603,20 @@ def set_answer_data(self, reply):
# If answer is not present in the request, do not attempt to set
# any answer-related data, since the request might have come
# from a sub-form.
if answer:
self.context.comment = self.webhelpers.get_safe_html(reply.get("comment"))
self.context.postponed = answer == "postponed"
if self.context.postponed:
self.context.identification = None
else:
self.context.identification = answer
if getattr(self.risk, "type", "") in ("top5", "policy"):
self.context.priority = "high"
elif getattr(self.risk, "evaluation_method", "") == "calculated":
self.calculatePriority(self.risk, reply)
elif self.risk is None or self.risk.evaluation_method == "direct":
self.context.priority = reply.get("priority")
if not answer:
return
self.context.comment = self.webhelpers.get_safe_html(reply.get("comment"))
self.context.postponed = answer == "postponed"
if self.context.postponed:
self.context.identification = None
return
self.context.identification = answer
if getattr(self.risk, "type", "") in ("top5", "policy"):
self.context.priority = "high"
elif getattr(self.risk, "evaluation_method", "") == "calculated":
self.calculatePriority(self.risk, reply)
elif self.risk is None or self.risk.evaluation_method == "direct":
self.context.priority = reply.get("priority")

def set_measure_data(self, reply, session):
changed = False
Expand Down Expand Up @@ -950,7 +951,14 @@ def proceed_to_next(self, reply):
target = self.next_question
if target is None:
# We ran out of questions, proceed to the action plan
url = self.webhelpers.traversed_session.absolute_url() + "/@@actionplan"
if self.webhelpers.use_action_plan_phase:
next_view_name = "@@actionplan"
elif self.webhelpers.use_consultancy_phase:
next_view_name = "@@consultancy"
else:
next_view_name = "@@report"
base_url = self.webhelpers.traversed_session.absolute_url()
url = f"{base_url}/{next_view_name}"
return self.request.response.redirect(url)

elif _next == "add_custom_risk":
Expand Down Expand Up @@ -1184,9 +1192,7 @@ def risk_present(self):

@property
def risk_postponed(self):
return self.context.identification is None and (
(self.italy_special and self.context.postponed) or True
)
return self.context.identification is None

@property
def use_problem_description(self):
Expand Down
7 changes: 6 additions & 1 deletion src/euphorie/client/browser/webhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,11 @@ def integrated_action_plan(self):
return False
return getattr(self._survey, "integrated_action_plan", False)

@property
@memoize
def use_action_plan_phase(self):
return not self.integrated_action_plan

@property
@memoize
def in_session(self):
Expand Down Expand Up @@ -1338,7 +1343,7 @@ def survey_tree_data(self):
}
)

if not integrated_action_plan:
if self.use_action_plan_phase:
# The tree for the action section uses the same structure as the
# identification tree, with the only differences that only risks
# and their parent modules are shown and that the entire tree is
Expand Down