def change_eval_no(self): """ trigger an evaluation process """ requirementId = self.request.get('req_id', default=None) objectId = self.request.get('obj_id', default=None) my_catalog = zapi.getUtility(ICatalog) if objectId != None: obj = my_catalog.searchResults(oid_index=objectId) obj = iter(obj).next() else: obj = self.context evaluations = getEvaluationsDone(obj) if requirementId is not None \ and evaluations is not None: res = my_catalog.searchResults(oid_index=requirementId) if len(res) > 0: requirementObj = iter(res).next() principalId = self.request.principal.id.split('.')[1] pau_utility = queryUtility(IAuthentication) internalPrincipal = pau_utility['principals'][principalId] pfSystem = queryUtility(IScoreSystem, name="Comp_Pass/Fail") inpVal = 'Fail' evaluation = Evaluation(requirementObj, pfSystem, inpVal, internalPrincipal) evaluations.addEvaluation(evaluation) nextURL = self.request.get('nextURL', default=None) if nextURL is not None: return self.request.response.redirect(nextURL) else: return self.request.response.redirect('./@@details.html')
def getEvaluationsDone(self): """returns [<Evaluation for Requirement(u'ReqA1'), value='Fail'>), <Evaluation for Requirement(u'ReqA2'), value='Pass'>] """ retList = [] evaluations = getEvaluationsDone(self) for ev in evaluations.items(): retList.append(ev[1]) return retList
def resumee(self): allObjEvaluations = getEvaluationsDone(self.context) reqs = allObjEvaluations.items() reqs_ok = 0 reqs_fail = 0 for req_tupel in reqs: if req_tupel[1].value == "Pass": reqs_ok += 1 elif req_tupel[1].value == "Fail": reqs_fail += 1 reqs_todo = len(getEvaluationsTodo(self.context)) return (reqs_todo, reqs_ok, reqs_fail)
def reqList2ndLevel(self): """List of Content objects""" evaluations1stLevel = self.context.getEvaluationsDone() attrs = self.context.getRefAttributeNames() retList = [] for attr in attrs: objs = getattr(self.context, attr) if type(objs) is not list: objs = [objs] for obj in objs: if hasattr(obj, "requirements"): evaluations = getEvaluationsDone(obj) #evaluations = self.context.getEvaluationsDone() for ev in evaluations: retList.append({"eval": ev, "obj": self.context}) return retList
def change_eval_no(self): """ trigger an evaluation process """ requirementId = self.request.get('req_id', default=None) objectId = self.request.get('obj_id', default=None) my_catalog = zapi.getUtility(ICatalog) if objectId != None: obj = my_catalog.searchResults(oid_index=objectId) obj = iter(obj).next() else: obj = self.context evaluations = getEvaluationsDone(obj) if requirementId is not None \ and evaluations is not None: res = my_catalog.searchResults(oid_index=requirementId) if len(res) > 0: requirementObj = iter(res).next() principalId = self.request.principal.id.split('.')[1] pau_utility = queryUtility(IAuthentication) if pau_utility.has_key('principals'): internalPrincipal = pau_utility['principals'][principalId] if pau_utility.has_key('LDAPAuthentication'): ldapAuth = pau_utility[u'LDAPAuthentication'] internalPrincipal = ldapAuth.principalInfo(\ ldapAuth.prefix+principalId) pfSystem = queryUtility(IScoreSystem, name="Comp_Pass/Fail") inpVal = 'Fail' evaluation = Evaluation(requirementObj, pfSystem, inpVal, internalPrincipal) evaluations.addEvaluation(evaluation) historyEntry = u"'%s' -> '%s'" % (requirementObj.ikName, inpVal) obj.appendHistoryEntry(historyEntry, request=self.request, withAuthor=True) nextURL = self.request.get('nextURL', default=None) if nextURL is not None: return self.request.response.redirect(nextURL) else: return self.request.response.redirect('./@@details.html')
def appendEvaluationList(obj, document): elemList = [] if hasattr(obj, 'requirement') \ and obj.requirement is not None: my_catalog = zapi.getUtility(ICatalog) res = my_catalog.searchResults(oid_index=obj.requirement) if len(res) > 0: requirementObj = iter(res).next() reqTitle = requirementObj.ikName reqComment = requirementObj.ikComment elemList.append(RptPara(reqTitle, doc=document)) elemList.append(RptPara(reqComment, doc=document)) elemList.append(Spacer(0, 4 * mm)) # Evaluations Done evaluations = getEvaluationsDone(obj) if len(evaluations) > 0: styleSheet = getRptStyleSheet() style1 = styleSheet['Small'] style2 = styleSheet['Infobox'] elemList.append( RptPara('Evaluations Done: ', style=style2, doc=document)) colWidths = [15 * mm, 60 * mm, 20 * mm, 40 * mm] data = [[ RptPara('<b>Pos</b>', style=style1, doc=document), RptPara('<b>Requirement</b>', style=style1, doc=document), RptPara('<b>Value</b>', style=style1, doc=document), RptPara('<b>Evaluator</b>', style=style1, doc=document) ]] rowColor = getTabBackgroundColor() rowColorLight = getTabBackgroundColorLight() ik_tbl_style = TableStyle([\ ('BACKGROUND', (0, 0), (-1, 0), rowColor), ('LEFTPADDING', (0, 0), (-1, -1), 1 * mm), ('RIGHTPADDING', (0, 0), (-1, -1), 1 * mm), ('BOTTOMPADDING', (0, 0), (-1, -1), 1 * mm), ('TOPPADDING', (0, 0), (-1, -1), 2 * mm), ('FONTSIZE', (0, 0), (-1, -1), 8), ('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('ROWBACKGROUNDS',(0,0),(-1,-1),[rowColor, rowColorLight]), ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black), ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ]) pos = 0 for evaluation in evaluations.values(): pos = pos + 1 if evaluation.value == 'Pass': ik_tbl_style.add('BACKGROUND', (2, pos), (2, pos), colors.green) elif evaluation.value == 'Fail': ik_tbl_style.add('BACKGROUND', (2, pos), (2, pos), colors.red) else: pass if len(evaluation.requirement) == 0: data.append([ RptPara(evaluation.requirement.getIndexString(), style=style1, doc=document), RptPara(evaluation.requirement.ikName, style=style1, doc=document), RptPara(evaluation.value, style=style1, doc=document), RptPara(evaluation.evaluator.title, style=style1, doc=document), ]) t0 = Table(data, hAlign='RIGHT', style=ik_tbl_style, colWidths=colWidths) elemList.append(t0) elemList.append(Spacer(0, 3 * mm)) # Evaluations ToDo evaluations = getEvaluationsTodo(obj) if len(evaluations) > 0: styleSheet = getRptStyleSheet() style1 = styleSheet['Small'] style2 = styleSheet['Infobox'] elemList.append( RptPara('Evaluations ToDo: ', style=style2, doc=document)) #colWidths = [75 * mm, 20 * mm, 40 * mm] colWidths = [15 * mm, 120 * mm] data = [[ RptPara('<b>Pos</b>', style=style1, doc=document), RptPara('<b>Requirement</b>', style=style1, doc=document), #RptPara('<b>Value</b>', style=style1, doc=document), #RptPara('<b>Evaluator</b>', style=style1, doc=document) ]] rowColor = getTabBackgroundColor() rowColorLight = getTabBackgroundColorLight() ik_tbl_style = TableStyle([\ ('BACKGROUND', (0, 0), (-1, 0), rowColor), ('LEFTPADDING', (0, 0), (-1, -1), 1 * mm), ('RIGHTPADDING', (0, 0), (-1, -1), 1 * mm), ('BOTTOMPADDING', (0, 0), (-1, -1), 1 * mm), ('TOPPADDING', (0, 0), (-1, -1), 2 * mm), ('FONTSIZE', (0, 0), (-1, -1), 8), ('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('ROWBACKGROUNDS',(0,0),(-1,-1),[rowColor, rowColorLight]), ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black), ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ]) #pos = 0 for evaluation in evaluations: # pos = pos + 1 # if evaluation.value == 'Pass': # ik_tbl_style.add('BACKGROUND', (1, pos), (1, pos), colors.green) # elif evaluation.value == 'Fail': # ik_tbl_style.add('BACKGROUND', (1, pos), (1, pos), colors.red) # else: # pass if len(evaluation.keys()) == 0: data.append([ RptPara(evaluation.getIndexString(), style=style1, doc=document), RptPara(evaluation.ikName, style=style1, doc=document), # RptPara(evaluation.value, # style=style1, # doc=document), # RptPara(evaluation.evaluator.title, # style=style1, # doc=document), ]) t0 = Table(data, hAlign='RIGHT', style=ik_tbl_style, colWidths=colWidths) elemList.append(t0) elemList.append(Spacer(0, 3 * mm)) return elemList