| @@ 37-57 (lines=21) @@ | ||
| 34 | self.checkInstrumentsValidity() |
|
| 35 | return self.template() |
|
| 36 | ||
| 37 | def checkInstrumentsValidity(self): |
|
| 38 | """Checks the validity of the instruments used in the Analyses |
|
| 39 | ||
| 40 | If an analysis with an invalid instrument (out-of-date or with |
|
| 41 | calibration tests failed) is found, a warn message will be displayed. |
|
| 42 | """ |
|
| 43 | invalid = [] |
|
| 44 | ||
| 45 | ans = [a.getObject() for a in self.context.getAnalyses()] |
|
| 46 | for an in ans: |
|
| 47 | valid = an.isInstrumentValid() |
|
| 48 | if not valid: |
|
| 49 | inv = '%s (%s)' % (safe_unicode(an.Title()), |
|
| 50 | safe_unicode(an.getInstrument().Title())) |
|
| 51 | if inv not in invalid: |
|
| 52 | invalid.append(inv) |
|
| 53 | if len(invalid) > 0: |
|
| 54 | message = _("Some analyses use out-of-date or uncalibrated " |
|
| 55 | "instruments. Results edition not allowed") |
|
| 56 | message = "%s: %s" % (message, (', '.join(invalid))) |
|
| 57 | self.context.plone_utils.addPortalMessage(message, 'warning') |
|
| 58 | ||
| @@ 171-190 (lines=20) @@ | ||
| 168 | outdict[analysis.getKeyword()] = andict |
|
| 169 | return outdict |
|
| 170 | ||
| 171 | def checkInstrumentsValidity(self): |
|
| 172 | """Checks the validity of the instruments used in the Analyses If an |
|
| 173 | analysis with an invalid instrument (out-of-date or with calibration |
|
| 174 | tests failed) is found, a warn message will be displayed. |
|
| 175 | """ |
|
| 176 | invalid = [] |
|
| 177 | ans = self.context.getAnalyses() |
|
| 178 | for an in ans: |
|
| 179 | valid = an.isInstrumentValid() |
|
| 180 | if not valid: |
|
| 181 | instrument = an.getInstrument() |
|
| 182 | inv = "%s (%s)" % ( |
|
| 183 | safe_unicode(an.Title()), safe_unicode(instrument.Title())) |
|
| 184 | if inv not in invalid: |
|
| 185 | invalid.append(inv) |
|
| 186 | if len(invalid) > 0: |
|
| 187 | message = _("Some analyses use out-of-date or uncalibrated " |
|
| 188 | "instruments. Results edition not allowed") |
|
| 189 | message = "%s: %s" % (message, (", ".join(invalid))) |
|
| 190 | self.context.plone_utils.addPortalMessage(message, "warning") |
|
| 191 | ||