| Conditions | 5 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 19 |
| Ratio | 90.48 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 24 | View Code Duplication | def checkInstrumentsValidity(self): |
|
|
|
|||
| 25 | """Checks the validity of the instruments used in the Analyses |
||
| 26 | |||
| 27 | If an analysis with an invalid instrument (out-of-date or with |
||
| 28 | calibration tests failed) is found, a warn message will be displayed. |
||
| 29 | """ |
||
| 30 | invalid = [] |
||
| 31 | |||
| 32 | ans = [a.getObject() for a in self.context.getAnalyses()] |
||
| 33 | for an in ans: |
||
| 34 | valid = an.isInstrumentValid() |
||
| 35 | if not valid: |
||
| 36 | inv = '%s (%s)' % (safe_unicode(an.Title()), |
||
| 37 | safe_unicode(an.getInstrument().Title())) |
||
| 38 | if inv not in invalid: |
||
| 39 | invalid.append(inv) |
||
| 40 | if len(invalid) > 0: |
||
| 41 | message = _("Some analyses use out-of-date or uncalibrated " |
||
| 42 | "instruments. Results edition not allowed") |
||
| 43 | message = "%s: %s" % (message, (', '.join(invalid))) |
||
| 44 | self.context.plone_utils.addPortalMessage(message, 'warn') |
||
| 45 |