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

Dormant Reference Definitions are listed for selection on WS Templates #761

Merged
merged 5 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Changelog

**Fixed**

- #761 Dormant Reference Definitions were listed for selection on WS Templates
- #735 Interim fields not created for QC Analyses on WSs
- #752 Published Date field of Analyses is never set
- #760 Default to empty the Title field when creating a new Analysis Specification (it was showing the UID)
Expand Down
17 changes: 11 additions & 6 deletions bika/lims/browser/widgets/worksheettemplatelayoutwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from Products.Archetypes.Registry import registerWidget
from Products.ATExtensions.widget.records import RecordsWidget


class WorksheetTemplateLayoutWidget(RecordsWidget):
security = ClassSecurityInfo()
_properties = RecordsWidget._properties.copy()
Expand All @@ -20,8 +21,10 @@ class WorksheetTemplateLayoutWidget(RecordsWidget):

security.declarePublic('get_template_rows')
def get_template_rows(self, num_positions, current_field_value):
try: num_pos = int(num_positions)
except ValueError: num_pos = 10
try:
num_pos = int(num_positions)
except ValueError:
num_pos = 10

rows = []
i = 1
Expand All @@ -40,7 +43,9 @@ def get_template_rows(self, num_positions, current_field_value):
rows.append(row)
return rows

registerWidget(WorksheetTemplateLayoutWidget,
title = 'WS Template Analyses Layout',
description = ('Worksheet analyses layout.'),
)

registerWidget(
WorksheetTemplateLayoutWidget,
title='WS Template Analyses Layout',
description=('Worksheet analyses layout.'),
)
98 changes: 56 additions & 42 deletions bika/lims/content/worksheettemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,43 @@
import sys

schema = BikaSchema.copy() + Schema((
RecordsField('Layout',
schemata = 'Layout',
required = 1,
type = 'templateposition',
subfields = ('pos', 'type', 'blank_ref', 'control_ref', 'dup'),
required_subfields = ('pos', 'type'),
subfield_labels = {'pos': _('Position'),
'type': _('Analysis Type'),
'blank_ref': _('Reference'),
'control_ref': _('Reference'),
'dup': _('Duplicate Of')},
widget = WorksheetTemplateLayoutWidget(
RecordsField(
'Layout',
schemata='Layout',
required=1,
type='templateposition',
subfields=('pos', 'type', 'blank_ref', 'control_ref', 'dup'),
required_subfields=('pos', 'type'),
subfield_labels={
'pos': _('Position'),
'type': _('Analysis Type'),
'blank_ref': _('Reference'),
'control_ref': _('Reference'),
'dup': _('Duplicate Of')
},
widget=WorksheetTemplateLayoutWidget(
label=_("Worksheet Layout"),
description =_(
description=_(
"Specify the size of the Worksheet, e.g. corresponding to a "
"specific instrument's tray size. Then select an Analysis 'type' "
"per Worksheet position. Where QC samples are selected, also select "
"which Reference Sample should be used. If a duplicate analysis is "
"selected, indicate which sample position it should be a duplicate of"),
)
),
ReferenceField('Service',
schemata = 'Analyses',
required = 0,
multiValued = 1,
allowed_types = ('AnalysisService',),
relationship = 'WorksheetTemplateAnalysisService',
referenceClass = HoldingReference,
widget = ServicesWidget(
ReferenceField(
'Service',
schemata='Analyses',
required=0,
multiValued=1,
allowed_types=('AnalysisService',),
relationship='WorksheetTemplateAnalysisService',
referenceClass=HoldingReference,
widget=ServicesWidget(
label=_("Analysis Service"),
description=_("Select which Analyses should be included on the Worksheet"),
description=_(
"Select which Analyses should be included on the Worksheet"
),
)
),
ReferenceField(
Expand All @@ -65,34 +71,39 @@
allowed_types=('Method',),
relationship='WorksheetTemplateMethod',
referenceClass=HoldingReference,
widget = SelectionWidget(
widget=SelectionWidget(
format='select',
label=_("Method"),
description=_(
"Restrict the available analysis services and instruments"
"to those with the selected method."
" In order to apply this change to the services list, you "
"should save the change first."),
"should save the change first."
),
),
),
ReferenceField('Instrument',
schemata = "Description",
required = 0,
vocabulary_display_path_bound = sys.maxint,
vocabulary = 'getInstruments',
allowed_types = ('Instrument',),
relationship = 'WorksheetTemplateInstrument',
referenceClass = HoldingReference,
widget = ReferenceWidget(
checkbox_bound = 0,
ReferenceField(
'Instrument',
schemata="Description",
required=0,
vocabulary_display_path_bound=sys.maxint,
vocabulary='getInstruments',
allowed_types=('Instrument',),
relationship='WorksheetTemplateInstrument',
referenceClass=HoldingReference,
widget=ReferenceWidget(
checkbox_bound=0,
label=_("Instrument"),
description=_("Select the preferred instrument"),
description=_(
"Select the preferred instrument"
),
),
),
ComputedField('InstrumentTitle',
expression = "context.getInstrument() and context.getInstrument().Title() or ''",
widget = ComputedWidget(
visible = False,
ComputedField(
'InstrumentTitle',
expression="context.getInstrument() and context.getInstrument().Title() or ''",
widget=ComputedWidget(
visible=False,
),
),
BooleanField(
Expand All @@ -101,9 +112,11 @@
schemata="Description",
widget=BooleanWidget(
label=_("Enable Multiple Use of Instrument in Worksheets."),
description=_("If unchecked, \
Lab Managers won't be able to assign the same Instrument more than one Analyses while \
creating a Worksheet.")
description=_(
"If unchecked, \
Lab Managers won't be able to assign the same Instrument more than one Analyses while \
creating a Worksheet."
)
)
),
))
Expand Down Expand Up @@ -165,4 +178,5 @@ def _getMethodsVoc(self):
items.insert(0, ('', _("Not specified")))
return DisplayList(list(items))


registerType(WorksheetTemplate, PROJECTNAME)
117 changes: 78 additions & 39 deletions bika/lims/controlpanel/bika_worksheettemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,54 +24,90 @@ class WorksheetTemplatesView(BikaListingView):
def __init__(self, context, request):
super(WorksheetTemplatesView, self).__init__(context, request)
self.catalog = 'bika_setup_catalog'
self.contentFilter = {'portal_type': 'WorksheetTemplate',
'sort_on': 'sortable_title'}
self.context_actions = {_('Add'):
{'url': 'createObject?type_name=WorksheetTemplate',
'icon': '++resource++bika.lims.images/add.png'}}
self.contentFilter = {
'portal_type': 'WorksheetTemplate',
'sort_on': 'sortable_title'
}
self.context_actions = {
_('Add'):
{
'url': 'createObject?type_name=WorksheetTemplate',
'icon': '++resource++bika.lims.images/add.png'
}
}
self.title = self.context.translate(_("Worksheet Templates"))
self.form_id = "list_worksheettemplates"
self.description = ""
self.show_sort_column = False
self.show_select_row = False
self.show_select_column = True
self.pagesize = 25
self.icon = '{}/{}/{}'.format(self.portal_url,
'++resource++bika.lims.images',
'worksheettemplate_big.png')

self.icon = '{}/{}/{}'.format(
self.portal_url,
'++resource++bika.lims.images',
'worksheettemplate_big.png'
)
self.columns = {
'Title': {'title': _('Title'),
'index': 'sortable_title'},
'Description': {'title': _('Description'),
'index': 'description',
'toggle': True},
'Instrument': {'title': _('Instrument'),
'index':'getInstrumentTitle',
'toggle': True},
'Title': {
'title': _('Title'),
'index': 'sortable_title'
},
'Description': {
'title': _('Description'),
'index': 'description',
'toggle': True
},
'Instrument': {
'title': _('Instrument'),
'index': 'getInstrumentTitle',
'toggle': True
},
}

self.review_states = [
{'id':'default',
'title': _('Active'),
'contentFilter': {'inactive_state': 'active'},
'transitions': [{'id':'deactivate'}, ],
'columns': ['Title',
'Description',
'Instrument']},
{'id':'inactive',
'title': _('Dormant'),
'contentFilter': {'inactive_state': 'inactive'},
'transitions': [{'id': 'activate'}, ],
'columns': ['Title',
'Description',
'Instrument']},
{'id':'all',
'title': _('All'),
'contentFilter':{},
'columns': ['Title',
'Description',
'Instrument']},
{
'id': 'default',
'title': _('Active'),
'contentFilter': {
'inactive_state': 'active'
},
'transitions': [
{
'id': 'deactivate'
},
],
'columns': [
'Title',
'Description',
'Instrument'
]
},
{
'id': 'inactive',
'title': _('Dormant'),
'contentFilter': {
'inactive_state': 'inactive'
},
'transitions': [
{
'id': 'activate'
},
],
'columns': [
'Title',
'Description',
'Instrument'
]
},
{
'id': 'all',
'title': _('All'),
'contentFilter': {},
'columns': [
'Title',
'Description',
'Instrument'
]
},
]

def folderitem(self, obj, item, index):
Expand All @@ -84,10 +120,13 @@ def folderitem(self, obj, item, index):


schema = ATFolderSchema.copy()


class WorksheetTemplates(ATFolder):
implements(IWorksheetTemplates)
displayContentsTab = False
schema = schema

schemata.finalizeATCTSchema(schema, folderish = True, moveDiscussion = False)

schemata.finalizeATCTSchema(schema, folderish=True, moveDiscussion=False)
atapi.registerType(WorksheetTemplates, PROJECTNAME)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
accessor python: field.getAccessor(context);
current_field_value accessor;
sort_on python:(('title', 'nocase', 'asc'),);
ReferenceDefinitions python:sequence.sort([p.getObject() for p in context.bika_setup_catalog(portal_type='ReferenceDefinition')], sort_on);
ReferenceDefinitions python:sequence.sort([p.getObject() for p in context.bika_setup_catalog(portal_type='ReferenceDefinition') \
if p.inactive_state=='active'], sort_on);
BlankDefinitions python: [r for r in ReferenceDefinitions if r['Blank']];
ControlDefinitions python: [r for r in ReferenceDefinitions if not r['Blank']];
types context/getAnalysisTypes;
Expand Down