| @@ 1363-1406 (lines=44) @@ | ||
| 1360 | return analyst_member.getProperty('fullname') |
|
| 1361 | return analyst |
|
| 1362 | ||
| 1363 | def isVerifiable(self): |
|
| 1364 | """ |
|
| 1365 | Checks it the current Worksheet can be verified. This is, its |
|
| 1366 | not a cancelled Worksheet and all the analyses that contains |
|
| 1367 | are verifiable too. Note that verifying a Worksheet is in fact, |
|
| 1368 | the same as verifying all the analyses that contains. Therefore, the |
|
| 1369 | 'verified' state of a Worksheet shouldn't be a 'real' state, |
|
| 1370 | rather a kind-of computed state, based on the statuses of the analyses |
|
| 1371 | it contains. This is why this function checks if the analyses |
|
| 1372 | contained are verifiable, cause otherwise, the Worksheet will |
|
| 1373 | never be able to reach a 'verified' state. |
|
| 1374 | :returns: True or False |
|
| 1375 | """ |
|
| 1376 | # Check if the worksheet is active |
|
| 1377 | workflow = getToolByName(self, "portal_workflow") |
|
| 1378 | objstate = workflow.getInfoFor(self, 'cancellation_state', 'active') |
|
| 1379 | if objstate == "cancelled": |
|
| 1380 | return False |
|
| 1381 | ||
| 1382 | # Check if the worksheet state is to_be_verified |
|
| 1383 | review_state = workflow.getInfoFor(self, "review_state") |
|
| 1384 | if review_state == 'to_be_verified': |
|
| 1385 | # This means that all the analyses from this worksheet have |
|
| 1386 | # already been transitioned to a 'verified' state, and so the |
|
| 1387 | # woksheet itself |
|
| 1388 | return True |
|
| 1389 | else: |
|
| 1390 | # Check if the analyses contained in this worksheet are |
|
| 1391 | # verifiable. Only check those analyses not cancelled and that |
|
| 1392 | # are not in a kind-of already verified state |
|
| 1393 | canbeverified = True |
|
| 1394 | omit = ['published', 'retracted', 'rejected', 'verified'] |
|
| 1395 | for a in self.getAnalyses(): |
|
| 1396 | st = workflow.getInfoFor(a, 'cancellation_state', 'active') |
|
| 1397 | if st == 'cancelled': |
|
| 1398 | continue |
|
| 1399 | st = workflow.getInfoFor(a, 'review_state') |
|
| 1400 | if st in omit: |
|
| 1401 | continue |
|
| 1402 | # Can the analysis be verified? |
|
| 1403 | if not a.isVerifiable(self): |
|
| 1404 | canbeverified = False |
|
| 1405 | break |
|
| 1406 | return canbeverified |
|
| 1407 | ||
| 1408 | def isUserAllowedToVerify(self, member): |
|
| 1409 | """ |
|
| @@ 2830-2872 (lines=43) @@ | ||
| 2827 | return user_email(self, self.Creator()) |
|
| 2828 | ||
| 2829 | # TODO Workflow, AnalysisRequest Move to guards.verify? |
|
| 2830 | def isVerifiable(self): |
|
| 2831 | """Checks it the current Analysis Request can be verified. This is, its |
|
| 2832 | not a cancelled Analysis Request and all the analyses that contains |
|
| 2833 | are verifiable too. Note that verifying an Analysis Request is in fact, |
|
| 2834 | the same as verifying all the analyses that contains. Therefore, the |
|
| 2835 | 'verified' state of an Analysis Request shouldn't be a 'real' state, |
|
| 2836 | rather a kind-of computed state, based on the statuses of the analyses |
|
| 2837 | it contains. This is why this function checks if the analyses |
|
| 2838 | contained are verifiable, cause otherwise, the Analysis Request will |
|
| 2839 | never be able to reach a 'verified' state. |
|
| 2840 | :returns: True or False |
|
| 2841 | """ |
|
| 2842 | # Check if the analysis request is active |
|
| 2843 | workflow = getToolByName(self, "portal_workflow") |
|
| 2844 | objstate = workflow.getInfoFor(self, 'cancellation_state', 'active') |
|
| 2845 | if objstate == "cancelled": |
|
| 2846 | return False |
|
| 2847 | ||
| 2848 | # Check if the analysis request state is to_be_verified |
|
| 2849 | review_state = workflow.getInfoFor(self, "review_state") |
|
| 2850 | if review_state == 'to_be_verified': |
|
| 2851 | # This means that all the analyses from this analysis request have |
|
| 2852 | # already been transitioned to a 'verified' state, and so the |
|
| 2853 | # analysis request itself |
|
| 2854 | return True |
|
| 2855 | else: |
|
| 2856 | # Check if the analyses contained in this analysis request are |
|
| 2857 | # verifiable. Only check those analyses not cancelled and that |
|
| 2858 | # are not in a kind-of already verified state |
|
| 2859 | canbeverified = True |
|
| 2860 | omit = ['published', 'retracted', 'rejected', 'verified'] |
|
| 2861 | for a in self.getAnalyses(full_objects=True): |
|
| 2862 | st = workflow.getInfoFor(a, 'cancellation_state', 'active') |
|
| 2863 | if st == 'cancelled': |
|
| 2864 | continue |
|
| 2865 | st = workflow.getInfoFor(a, 'review_state') |
|
| 2866 | if st in omit: |
|
| 2867 | continue |
|
| 2868 | # Can the analysis be verified? |
|
| 2869 | if not a.isVerifiable(self): |
|
| 2870 | canbeverified = False |
|
| 2871 | break |
|
| 2872 | return canbeverified |
|
| 2873 | ||
| 2874 | def getObjectWorkflowStates(self): |
|
| 2875 | """ |
|