Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDEV-14 List of Analysis Request Templates appears empty after adding a Sampling Round Template #195

Merged
merged 1 commit into from
Jul 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions bika/lims/browser/widgets/srtemplateartemplateswidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, context, request, fieldvalue, allow_edit):
self.catalog = "bika_setup_catalog"
self.contentFilter = {
'portal_type': 'ARTemplate',
'sort_on': 'sortable_title',
'sort_on': 'title',
'inactive_state': 'active',
}
self.context_actions = {}
Expand All @@ -36,11 +36,13 @@ def __init__(self, context, request, fieldvalue, allow_edit):
self.expand_all_categories = True
self.pagesize = 999999
self.allow_edit = allow_edit
self.clientUID = None
self.form_id = "artemplates"
self.columns = {
'Title': {
'title': _('Service'),
'index': 'sortable_title',
'index': 'title',
'replace_url': 'absolute_url',
'sortable': False,
},
}
Expand All @@ -54,22 +56,19 @@ def __init__(self, context, request, fieldvalue, allow_edit):
self.fieldvalue = fieldvalue
self.selected = [o.UID() for o in fieldvalue]

def folderitems(self):
items = BikaListingView.folderitems(self)
clientUID = self.context.aq_parent.aq_parent.UID()
out_items = []
for item in items:
if not item.has_key('obj'): continue
if item['obj'].getClientUID() and item['obj'].getClientUID()!=clientUID:
# Only display client's and lab's arts
continue
obj = item['obj']
title_link = "<a href='%s'>%s</a>" % (item['url'], item['title'])
item['replace']['Title'] = title_link
item['selected'] = item['uid'] in self.selected
out_items.append(item)
def isItemAllowed(self, obj):
if self.clientUID is None:
self.clientUID = self.context.aq_parent.aq_parent.UID()
# Only display client's and lab's arts
if obj.aq_parent.aq_inner.meta_type == 'Client':
obj_client = obj.getClientUID()
if obj_client != self.clientUID:
return False
return True

return out_items
def folderitem(self, obj, item, index):
item['selected'] = item['uid'] in self.selected
return item


class SRTemplateARTemplatesWidget(TypesWidget):
Expand Down