21
21
from bika .lims .browser .worksheet .tools import checkUserManage
22
22
from bika .lims .browser .worksheet .tools import showRejectionMessage
23
23
from bika .lims .utils import t
24
+ from bika .lims .vocabularies import CatalogVocabulary
24
25
25
26
26
27
class AddAnalysesView (BikaListingView ):
@@ -102,9 +103,6 @@ def __call__(self):
102
103
103
104
showRejectionMessage (self .context )
104
105
105
- translate = self .context .translate
106
-
107
- form_id = self .form_id
108
106
form = self .request .form
109
107
rc = getToolByName (self .context , REFERENCE_CATALOG )
110
108
if 'submitted' in form :
@@ -123,6 +121,25 @@ def __call__(self):
123
121
_ ("No analyses were added to this worksheet." ))
124
122
self .request .RESPONSE .redirect (self .context .absolute_url () +
125
123
"/add_analyses" )
124
+ elif (
125
+ 'list_getCategoryTitle' in form or
126
+ 'list_Title' in form or
127
+ 'list_getClientTitle' in form
128
+ ):
129
+ # Apply filter elements
130
+ # Note that the name of those fields is '..Title', but we
131
+ # are getting their UID.
132
+ category = form .get ('list_getCategoryTitle' , '' )
133
+ if category :
134
+ self .contentFilter ['getCategoryUID' ] = category
135
+
136
+ service = form .get ('list_Title' , '' )
137
+ if service :
138
+ self .contentFilter ['getServiceUID' ] = service
139
+
140
+ client = form .get ('list_getClientTitle' , '' )
141
+ if client :
142
+ self .contentFilter ['getClientUID' ] = client
126
143
127
144
self ._process_request ()
128
145
@@ -197,32 +214,33 @@ def folderitem(self, obj, item, index):
197
214
return item
198
215
199
216
def getServices (self ):
200
- bsc = getToolByName (self .context , 'bika_setup_catalog' )
201
- return [c .Title for c in
202
- bsc (portal_type = 'AnalysisService' ,
203
- getCategoryUID = self .request .get ('list_getCategoryUID' , '' ),
204
- inactive_state = 'active' ,
205
- sort_on = 'sortable_title' )]
217
+ vocabulary = CatalogVocabulary (self )
218
+ vocabulary .catalog = 'bika_setup_catalog'
219
+ categoryUID = self .request .get ('list_getCategoryUID' , '' )
220
+ if categoryUID :
221
+ return vocabulary (
222
+ portal_type = 'AnalysisService' ,
223
+ getCategoryUID = categoryUID ,
224
+ sort_on = 'sortable_title'
225
+ )
226
+ return vocabulary (
227
+ portal_type = 'AnalysisService' ,
228
+ sort_on = 'sortable_title'
229
+ )
206
230
207
231
def getClients (self ):
208
- pc = getToolByName (self .context , 'portal_catalog' )
209
- return [c .Title for c in
210
- pc (portal_type = 'Client' ,
211
- inactive_state = 'active' ,
212
- sort_on = 'sortable_title' )]
232
+ vocabulary = CatalogVocabulary (self )
233
+ return vocabulary (portal_type = 'Client' , sort_on = 'sortable_title' )
213
234
214
235
def getCategories (self ):
215
- bsc = getToolByName (self .context , 'bika_setup_catalog' )
216
- return [c .Title for c in
217
- bsc (portal_type = 'AnalysisCategory' ,
218
- inactive_state = 'active' ,
219
- sort_on = 'sortable_title' )]
236
+ vocabulary = CatalogVocabulary (self )
237
+ vocabulary .catalog = 'bika_setup_catalog'
238
+ return vocabulary (
239
+ portal_type = 'AnalysisCategory' , sort_on = 'sortable_title' )
220
240
221
241
def getWorksheetTemplates (self ):
222
242
""" Return WS Templates """
223
- profiles = []
224
- bsc = getToolByName (self .context , 'bika_setup_catalog' )
225
- return [(c .UID , c .Title ) for c in
226
- bsc (portal_type = 'WorksheetTemplate' ,
227
- inactive_state = 'active' ,
228
- sort_on = 'sortable_title' )]
243
+ vocabulary = CatalogVocabulary (self )
244
+ vocabulary .catalog = 'bika_setup_catalog'
245
+ return vocabulary (
246
+ portal_type = 'WorksheetTemplate' , sort_on = 'sortable_title' )
0 commit comments