|
5 | 5 | # Copyright 2018 by it's authors.
|
6 | 6 | # Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
|
7 | 7 |
|
8 |
| -from Products.CMFCore.utils import getToolByName |
| 8 | +from bika.lims import api |
9 | 9 | from bika.health.browser.samples.folder_view import SamplesView
|
10 | 10 |
|
11 | 11 |
|
12 | 12 | class BatchSamplesView(SamplesView):
|
| 13 | + |
13 | 14 | def __init__(self, context, request):
|
14 | 15 | super(BatchSamplesView, self).__init__(context, request)
|
15 | 16 | self.view_url = self.context.absolute_url() + "/samples"
|
16 |
| - if 'path' in self.contentFilter: |
17 |
| - del(self.contentFilter['path']) |
18 |
| - |
19 |
| - def contentsMethod(self, contentFilter): |
20 |
| - tool = getToolByName(self.context, self.catalog) |
21 |
| - state = [x for x in self.review_states if x['id'] == self.review_state['id']][0] |
22 |
| - for k, v in state['contentFilter'].items(): |
23 |
| - self.contentFilter[k] = v |
24 |
| - tool_samples = tool(contentFilter) |
25 |
| - samples = {} |
26 |
| - for sample in (p.getObject() for p in tool_samples): |
27 |
| - for ar in sample.getAnalysisRequests(): |
28 |
| - batch = ar.getBatch() |
29 |
| - batch_uid = batch.UID() if batch else '' |
30 |
| - if batch_uid == self.context.UID(): |
31 |
| - samples[sample.getId()] = sample |
32 |
| - return samples.values() |
| 17 | + self.contentFilter = {'portal_type': 'Sample', |
| 18 | + 'getBatchUIDs': api.get_uid(self.context), |
| 19 | + 'sort_on': 'created', |
| 20 | + 'sort_order': 'reverse', |
| 21 | + 'cancellation_state':'active'} |
0 commit comments