def folderitems(self): self.contentsMethod = self.context.getAnalyses items = AnalysesView.folderitems(self) for x in range(len(items)): if not items[x].has_key('obj'): continue obj = items[x]['obj'] ar = obj.aq_parent items[x]['replace']['Request'] = \ "<a href='%s'>%s</a>"%(ar.absolute_url(), ar.Title()) items[x]['replace']['Priority'] = ' ' #TODO this space is required for it to work return items
def folderitems(self): self.contentsMethod = self.context.getAnalyses items = AnalysesView.folderitems(self) for x in range(len(items)): if not items[x].has_key('obj'): continue obj = items[x]['obj'] ar = obj.aq_parent items[x]['replace']['Request'] = \ "<a href='%s'>%s</a>"%(ar.absolute_url(), ar.Title()) items[x]['replace'][ 'Priority'] = ' ' #TODO this space is required for it to work return items
def folderitems(self): items = AnalysesView.folderitems(self) items.sort(key=itemgetter('CaptureDate'), reverse=True) for i in range(len(items)): obj = items[i]['obj'] imgtype = "" if obj.portal_type == 'ReferenceAnalysis': antype = QCANALYSIS_TYPES.getValue(obj.getReferenceType()) if obj.getReferenceType() == 'c': imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/control.png'/> " % ( antype, self.context.absolute_url()) if obj.getReferenceType() == 'b': imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/blank.png'/> " % ( antype, self.context.absolute_url()) items[i]['replace']['Partition'] = "<a href='%s'>%s</a>" % ( obj.aq_parent.absolute_url(), obj.aq_parent.id) elif obj.portal_type == 'DuplicateAnalysis': antype = QCANALYSIS_TYPES.getValue('d') imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/duplicate.png'/> " % ( antype, self.context.absolute_url()) items[i]['sortcode'] = '%s_%s' % ( obj.getSample().id, obj.getService().getKeyword()) else: items[i]['sortcode'] = '%s_%s' % ( obj.getSample().id, obj.getService().getKeyword()) items[i]['before']['Service'] = imgtype # Get retractions field pdf = obj.getRetractedAnalysesPdfReport() title = '' anchor = '' try: if pdf: filesize = 0 title = _('Retractions') anchor = "<a class='pdf' target='_blank' href='%s/at_download/RetractedAnalysesPdfReport'>%s</a>" % \ (obj.absolute_url(), _("Retractions")) filesize = pdf.get_size() filesize = filesize / 1024 if filesize > 0 else 0 except: # POSKeyError: 'No blob file' # Show the record, but not the link title = _('Retraction report unavailable') anchor = title items[i]['Retractions'] = title items[i]['replace']['Retractions'] = anchor # Create json qcid = obj.aq_parent.id serviceref = "%s (%s)" % (items[i]['Service'], items[i]['Keyword']) trows = self.anjson.get(serviceref, {}) anrows = trows.get(qcid, []) anid = '%s.%s' % (items[i]['getReferenceAnalysesGroupID'], items[i]['id']) rr = obj.aq_parent.getResultsRangeDict() uid = obj.getServiceUID() if uid in rr: specs = rr[uid] try: smin = float(specs.get('min', 0)) smax = float(specs.get('max', 0)) error = float(specs.get('error', 0)) target = float(specs.get('result', 0)) result = float(items[i]['Result']) error_amount = ((target / 100) * error) if target > 0 else 0 upper = smax + error_amount lower = smin - error_amount anrow = { 'date': items[i]['CaptureDate'], 'min': smin, 'max': smax, 'target': target, 'error': error, 'erroramount': error_amount, 'upper': upper, 'lower': lower, 'result': result, 'unit': items[i]['Unit'], 'id': items[i]['uid'] } anrows.append(anrow) trows[qcid] = anrows self.anjson[serviceref] = trows except: pass return items