def update(self): """ Fetches the different kinds of risks we are interested in. Actioned Nodes -------------- Title: "Risks that have been identified, evaluated and have an Action Plan" Unactioned Nodes ---------------- Title: "Risks that have been identified but do NOT have an Action Plan" Unanswered Nodes ---------------- Title: "Hazards/problems that have been "parked" and are still to be dealt with" Risk not present nodes ---------------------- Title: "Hazards/problems that have been managed or are not present in your organisation" """ if survey.redirectOnSurveyUpdate(self.request): return super(OSHAActionPlanReportDownload, self).update() # Returns all identified nodes, with or without action plans self.nodes = self.getNodes() # Get the extra attributes as per #1517, #1518: self.actioned_nodes = utils.get_actioned_nodes(self.nodes) self.unactioned_nodes = utils.get_unactioned_nodes(self.nodes) self.unanswered_nodes = utils.get_unanswered_nodes(self.session) risk_not_present_nodes = utils.get_risk_not_present_nodes(self.session) # From the non-present risks, filter out risks from the (un-)/actioned # categories. A "priority" risk will always appear in the action plan, # even if it has been answered with "Yes" self.risk_not_present_nodes = [ n for n in risk_not_present_nodes if n not in self.actioned_nodes and n not in self.unactioned_nodes ] lang = getattr(self.request, 'LANGUAGE', 'en') if "-" in lang: elems = lang.split("-") lang = "{0}_{1}".format(elems[0], elems[1].upper()) self.title_custom_risks = translate(_( 'title_other_risks', default=u'Added risks (by you)'), target_language=lang)
def update(self): """ Fetches the different kinds of risks we are interested in. Actioned Nodes -------------- Title: "Risks that have been identified, evaluated and have an Action Plan" Unactioned Nodes ---------------- Title: "Risks that have been identified but do NOT have an Action Plan" Unanswered Nodes ---------------- Title: "Hazards/problems that have been "parked" and are still to be dealt with" Risk not present nodes ---------------------- Title: "Hazards/problems that have been managed or are not present in your organisation" """ if survey.redirectOnSurveyUpdate(self.request): return super(OSHAActionPlanReportDownload, self).update() # Returns all identified nodes, with or without action plans self.nodes = self.getNodes() # Get the extra attributes as per #1517, #1518: self.actioned_nodes = utils.get_actioned_nodes(self.nodes) self.unactioned_nodes = utils.get_unactioned_nodes(self.nodes) self.unanswered_nodes = utils.get_unanswered_nodes(self.session) risk_not_present_nodes = utils.get_risk_not_present_nodes(self.session) # From the non-present risks, filter out risks from the (un-)/actioned # categories. A "priority" risk will always appear in the action plan, # even if it has been answered with "Yes" self.risk_not_present_nodes = [ n for n in risk_not_present_nodes if n not in self.actioned_nodes and n not in self.unactioned_nodes ] lang = getattr(self.request, 'LANGUAGE', 'en') if "-" in lang: elems = lang.split("-") lang = "{0}_{1}".format(elems[0], elems[1].upper()) self.title_custom_risks = translate(_('title_other_risks', default=u'Added risks (by you)'), target_language=lang)
def update(self): """ Fetches the different kinds of risks we are interested in. Actioned Nodes -------------- Title: "Risks that have been identified, evaluated and have an Action Plan" Unactioned Nodes ---------------- Title: "Risks that have been identified but do NOT have an Action Plan" Unanswered Nodes ---------------- Title: "Hazards/problems that have been "parked" and are still to be dealt with" Risk not present nodes ---------------------- Title: "Hazards/problems that have been managed or are not present in your organisation" """ if survey.redirectOnSurveyUpdate(self.request): return super(OSHAActionPlanReportDownload, self).update() self.nodes = self.getNodes() # Returns all identified nodes, with or # without action plans # Get the extra attributes as per #1517, #1518: self.actioned_nodes = utils.get_actioned_nodes(self.nodes) self.unactioned_nodes = utils.get_unactioned_nodes(self.nodes) self.unanswered_nodes = utils.get_unanswered_nodes(self.session) self.risk_not_present_nodes = \ utils.get_risk_not_present_nodes(self.session)
def testUnansweredNodes(self): self.createData() self.assertEqual(len(utils.get_unanswered_nodes(self.survey)), 0)