diff --git a/CHANGES.rst b/CHANGES.rst index b1c6cce7ff..a2d53c3085 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) diff --git a/bika/lims/browser/widgets/worksheettemplatelayoutwidget.py b/bika/lims/browser/widgets/worksheettemplatelayoutwidget.py index dc985dbd52..bf8ad6f92f 100644 --- a/bika/lims/browser/widgets/worksheettemplatelayoutwidget.py +++ b/bika/lims/browser/widgets/worksheettemplatelayoutwidget.py @@ -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() @@ -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 @@ -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.'), +) diff --git a/bika/lims/content/worksheettemplate.py b/bika/lims/content/worksheettemplate.py index abac58da86..24a906676f 100644 --- a/bika/lims/content/worksheettemplate.py +++ b/bika/lims/content/worksheettemplate.py @@ -23,20 +23,23 @@ 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 " @@ -44,16 +47,19 @@ "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( @@ -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( @@ -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." + ) ) ), )) @@ -165,4 +178,5 @@ def _getMethodsVoc(self): items.insert(0, ('', _("Not specified"))) return DisplayList(list(items)) + registerType(WorksheetTemplate, PROJECTNAME) diff --git a/bika/lims/controlpanel/bika_worksheettemplates.py b/bika/lims/controlpanel/bika_worksheettemplates.py index 12fe641bab..88aaf4dbc5 100644 --- a/bika/lims/controlpanel/bika_worksheettemplates.py +++ b/bika/lims/controlpanel/bika_worksheettemplates.py @@ -24,11 +24,17 @@ 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 = "" @@ -36,42 +42,72 @@ def __init__(self, context, request): 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): @@ -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) diff --git a/bika/lims/skins/bika/bika_widgets/worksheettemplatelayoutwidget.pt b/bika/lims/skins/bika/bika_widgets/worksheettemplatelayoutwidget.pt index 61588386a2..d41ddf137e 100644 --- a/bika/lims/skins/bika/bika_widgets/worksheettemplatelayoutwidget.pt +++ b/bika/lims/skins/bika/bika_widgets/worksheettemplatelayoutwidget.pt @@ -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;