def __init__(self, context, request, **kwargs): AnalysesView.__init__(self, context, request, **kwargs) self.form_id = "{}_qcanalyses".format(api.get_uid(context)) self.allow_edit = False self.show_select_column = False self.show_search = False self.omit_form = True self.catalog = CATALOG_ANALYSIS_LISTING self.contentFilter = { "portal_type": "ReferenceAnalysis", "getInstrumentUID": api.get_uid(self.context), "sort_on": "getResultCaptureDate", "sort_order": "reverse" } self.columns["getReferenceAnalysesGroupID"] = { "title": _("QC Sample ID"), "sortable": False } self.columns["Partition"] = { "title": _("Reference Sample"), "sortable": False } self.columns["Retractions"] = {"title": "", "sortable": False} self.review_states[0]["columns"] = [ "Service", "getReferenceAnalysesGroupID", "Partition", "Result", "Uncertainty", "CaptureDate", "Retractions" ] self.review_states[0]["transitions"] = [{}] self.chart = EvolutionChart()
def __init__(self, context, request): AnalysesView.__init__(self, context, request) self.contentFilter = { 'portal_type': 'ReferenceAnalysis', 'path': {'query': "/".join(self.context.getPhysicalPath()), 'level': 0}} self.columns = { 'id': {'title': _('ID'), 'toggle': False}, 'getReferenceAnalysesGroupID': { 'title': _('QC Sample ID'), 'toggle': True}, 'Category': {'title': _('Category'), 'toggle': True}, 'Service': {'title': _('Service'), 'toggle': True}, 'Worksheet': {'title': _('Worksheet'), 'toggle': True}, 'Method': { 'title': _('Method'), 'sortable': False, 'toggle': True}, 'Instrument': { 'title': _('Instrument'), 'sortable': False, 'toggle': True}, 'Result': {'title': _('Result'), 'toggle': True}, 'CaptureDate': { 'title': _('Captured'), 'index': 'getResultCaptureDate', 'toggle': True}, 'Uncertainty': {'title': _('+-'), 'toggle': True}, 'DueDate': {'title': _('Due Date'), 'index': 'getDueDate', 'toggle': True}, 'retested': {'title': _('Retested'), 'type': 'boolean', 'toggle': True}, 'state_title': {'title': _('State'), 'toggle': True}, } self.review_states = [ {'id': 'default', 'title': _('All'), 'contentFilter': {}, 'transitions': [], 'columns':['id', 'getReferenceAnalysesGroupID', 'Category', 'Service', 'Worksheet', 'Method', 'Instrument', 'Result', 'CaptureDate', 'Uncertainty', 'DueDate', 'state_title'], }, ] self.chart = EvolutionChart()
def __init__(self, context, request, **kwargs): AnalysesView.__init__(self, context, request, **kwargs) self.catalog = CATALOG_ANALYSIS_LISTING self.contentFilter = { "portal_type": "ReferenceAnalysis", "getInstrumentUID": api.get_uid(self.context), "sort_on": "getResultCaptureDate", "sort_order": "reverse" } self.columns['getReferenceAnalysesGroupID'] = { 'title': _('QC Sample ID'), 'sortable': False } self.columns['Partition'] = { 'title': _('Reference Sample'), 'sortable': False } self.columns['Retractions'] = {'title': '', 'sortable': False} self.review_states[0]['columns'] = [ 'Service', 'getReferenceAnalysesGroupID', 'Partition', 'Result', 'Uncertainty', 'CaptureDate', 'Retractions' ] self.chart = EvolutionChart()
class InstrumentReferenceAnalysesView(AnalysesView): """View for the table of Reference Analyses linked to the Instrument. Only shows the Reference Analyses (Control and Blanks), the rest of regular and duplicate analyses linked to this instrument are not displayed. """ def __init__(self, context, request, **kwargs): AnalysesView.__init__(self, context, request, **kwargs) self.form_id = "{}_qcanalyses".format(api.get_uid(context)) self.allow_edit = False self.show_select_column = False self.show_search = False self.omit_form = True self.catalog = CATALOG_ANALYSIS_LISTING self.contentFilter = { "portal_type": "ReferenceAnalysis", "getInstrumentUID": api.get_uid(self.context), "sort_on": "getResultCaptureDate", "sort_order": "reverse" } self.columns["getReferenceAnalysesGroupID"] = { "title": _("QC Sample ID"), "sortable": False } self.columns["Partition"] = { "title": _("Reference Sample"), "sortable": False } self.columns["Retractions"] = {"title": "", "sortable": False} self.review_states[0]["columns"] = [ "Service", "getReferenceAnalysesGroupID", "Partition", "Result", "Uncertainty", "CaptureDate", "Retractions" ] self.review_states[0]["transitions"] = [{}] self.chart = EvolutionChart() def isItemAllowed(self, obj): allowed = super(InstrumentReferenceAnalysesView, self).isItemAllowed(obj) return allowed or obj.getResult != "" def folderitem(self, obj, item, index): item = super(InstrumentReferenceAnalysesView, self).folderitem(obj, item, index) analysis = api.get_object(obj) # Partition is used to group/toggle QC Analyses sample = analysis.getSample() item["replace"]["Partition"] = get_link(api.get_url(sample), api.get_id(sample)) # Get retractions field item["Retractions"] = "" report = analysis.getRetractedAnalysesPdfReport() if report: url = api.get_url(analysis) href = "{}/at_download/RetractedAnalysesPdfReport".format(url) attrs = {"class": "pdf", "target": "_blank"} title = _("Retractions") link = get_link(href, title, **attrs) item["Retractions"] = title item["replace"]["Retractions"] = link # Add the analysis to the QC Chart self.chart.add_analysis(analysis) return item
def __init__(self, context, request): super(ReferenceAnalysesView, self).__init__(context, request) self.form_id = "{}_qcanalyses".format(api.get_uid(context)) self.allow_edit = False self.show_select_column = False self.show_search = False self.omit_form = True self.show_search = False self.contentFilter = { "portal_type": "ReferenceAnalysis", "path": { "query": "/".join(self.context.getPhysicalPath()), "level": 0} } self.columns = collections.OrderedDict(( ("id", { "title": _("ID"), "sortable": False, "toggle": False}), ("getReferenceAnalysesGroupID", { "title": _("QC Sample ID"), "sortable": False, "toggle": True}), ("Category", { "title": _("Category"), "sortable": False, "toggle": True}), ("Service", { "title": _("Service"), "sortable": False, "toggle": True}), ("Worksheet", { "title": _("Worksheet"), "sortable": False, "toggle": True}), ("Method", { "title": _("Method"), "sortable": False, "toggle": True}), ("Instrument", { "title": _("Instrument"), "sortable": False, "toggle": True}), ("Result", { "title": _("Result"), "sortable": False, "toggle": True}), ("CaptureDate", { "title": _("Captured"), "sortable": False, "toggle": True}), ("Uncertainty", { "title": _("+-"), "sortable": False, "toggle": True}), ("DueDate", { "title": _("Due Date"), "sortable": False, "toggle": True}), ("retested", { "title": _("Retested"), "sortable": False, "type": "boolean", "toggle": True}), ("state_title", { "title": _("State"), "sortable": False, "toggle": True}), )) self.review_states = [ { "id": "default", "title": _("All"), "contentFilter": {}, "transitions": [], "columns": self.columns.keys() }, ] self.chart = EvolutionChart()
class ReferenceAnalysesView(AnalysesView): """Reference Analyses on this sample """ def __init__(self, context, request): super(ReferenceAnalysesView, self).__init__(context, request) self.form_id = "{}_qcanalyses".format(api.get_uid(context)) self.allow_edit = False self.show_select_column = False self.show_search = False self.omit_form = True self.show_search = False self.contentFilter = { "portal_type": "ReferenceAnalysis", "path": { "query": "/".join(self.context.getPhysicalPath()), "level": 0} } self.columns = collections.OrderedDict(( ("id", { "title": _("ID"), "sortable": False, "toggle": False}), ("getReferenceAnalysesGroupID", { "title": _("QC Sample ID"), "sortable": False, "toggle": True}), ("Category", { "title": _("Category"), "sortable": False, "toggle": True}), ("Service", { "title": _("Service"), "sortable": False, "toggle": True}), ("Worksheet", { "title": _("Worksheet"), "sortable": False, "toggle": True}), ("Method", { "title": _("Method"), "sortable": False, "toggle": True}), ("Instrument", { "title": _("Instrument"), "sortable": False, "toggle": True}), ("Result", { "title": _("Result"), "sortable": False, "toggle": True}), ("CaptureDate", { "title": _("Captured"), "sortable": False, "toggle": True}), ("Uncertainty", { "title": _("+-"), "sortable": False, "toggle": True}), ("DueDate", { "title": _("Due Date"), "sortable": False, "toggle": True}), ("retested", { "title": _("Retested"), "sortable": False, "type": "boolean", "toggle": True}), ("state_title", { "title": _("State"), "sortable": False, "toggle": True}), )) self.review_states = [ { "id": "default", "title": _("All"), "contentFilter": {}, "transitions": [], "columns": self.columns.keys() }, ] self.chart = EvolutionChart() def is_analysis_edition_allowed(self, analysis_brain): """see AnalysesView.is_analysis_edition_allowed """ return False def folderitem(self, obj, item, index): """Service triggered each time an item is iterated in folderitems. The use of this service prevents the extra-loops in child objects. :obj: the instance of the class to be foldered :item: dict containing the properties of the object to be used by the template :index: current index of the item """ item = super(ReferenceAnalysesView, self).folderitem(obj, item, index) if not item: return None item["Category"] = obj.getCategoryTitle ref_analysis = api.get_object(obj) ws = ref_analysis.getWorksheet() if not ws: logger.warn( "No Worksheet found for ReferenceAnalysis {}" .format(obj.getId)) else: item["Worksheet"] = ws.Title() anchor = "<a href='%s'>%s</a>" % (ws.absolute_url(), ws.Title()) item["replace"]["Worksheet"] = anchor # Add the analysis to the QC Chart self.chart.add_analysis(obj) return item
class ReferenceAnalysesView(AnalysesView): """ Reference Analyses on this sample """ implements(IViewView) def __init__(self, context, request): AnalysesView.__init__(self, context, request) self.contentFilter = { 'portal_type': 'ReferenceAnalysis', 'path': {'query': "/".join(self.context.getPhysicalPath()), 'level': 0}} self.columns = { 'id': {'title': _('ID'), 'toggle': False}, 'getReferenceAnalysesGroupID': { 'title': _('QC Sample ID'), 'toggle': True}, 'Category': {'title': _('Category'), 'toggle': True}, 'Service': {'title': _('Service'), 'toggle': True}, 'Worksheet': {'title': _('Worksheet'), 'toggle': True}, 'Method': { 'title': _('Method'), 'sortable': False, 'toggle': True}, 'Instrument': { 'title': _('Instrument'), 'sortable': False, 'toggle': True}, 'Result': {'title': _('Result'), 'toggle': True}, 'CaptureDate': { 'title': _('Captured'), 'index': 'getResultCaptureDate', 'toggle': True}, 'Uncertainty': {'title': _('+-'), 'toggle': True}, 'DueDate': {'title': _('Due Date'), 'index': 'getDueDate', 'toggle': True}, 'retested': {'title': _('Retested'), 'type': 'boolean', 'toggle': True}, 'state_title': {'title': _('State'), 'toggle': True}, } self.review_states = [ {'id': 'default', 'title': _('All'), 'contentFilter': {}, 'transitions': [], 'columns':['id', 'getReferenceAnalysesGroupID', 'Category', 'Service', 'Worksheet', 'Method', 'Instrument', 'Result', 'CaptureDate', 'Uncertainty', 'DueDate', 'state_title'], }, ] self.chart = EvolutionChart() def isItemAllowed(self, obj): """ :obj: it is a brain """ allowed = super(ReferenceAnalysesView, self).isItemAllowed(obj) return allowed if not allowed else obj.getResult != '' def folderitem(self, obj, item, index): """ :obj: it is a brain """ item = super(ReferenceAnalysesView, self).folderitem(obj, item, index) if not item: return None item['Category'] = obj.getCategoryTitle wss = self.rc.getBackReferences( obj.UID, relationship="WorksheetAnalysis") if not wss: logger.warn( 'No Worksheet found for ReferenceAnalysis {}' .format(obj.getId)) elif wss and len(wss) == 1: # TODO-performance: We are getting the object here... ws = wss[0].getSourceObject() item['Worksheet'] = ws.Title() anchor = '<a href="%s">%s</a>' % (ws.absolute_url(), ws.Title()) item['replace']['Worksheet'] = anchor else: logger.warn( 'More than one Worksheet found for ReferenceAnalysis {}' .format(obj.getId)) # Add the analysis to the QC Chart self.chart.add_analysis(obj) return item
class InstrumentReferenceAnalysesView(AnalysesView): """ View for the table of Reference Analyses linked to the Instrument. Only shows the Reference Analyses (Control and Blanks), the rest of regular and duplicate analyses linked to this instrument are not displayed. """ def __init__(self, context, request, **kwargs): AnalysesView.__init__(self, context, request, **kwargs) self.catalog = CATALOG_ANALYSIS_LISTING self.contentFilter = { "portal_type": "ReferenceAnalysis", "getInstrumentUID": api.get_uid(self.context), "sort_on": "getResultCaptureDate", "sort_order": "reverse" } self.columns['getReferenceAnalysesGroupID'] = { 'title': _('QC Sample ID'), 'sortable': False } self.columns['Partition'] = { 'title': _('Reference Sample'), 'sortable': False } self.columns['Retractions'] = {'title': '', 'sortable': False} self.review_states[0]['columns'] = [ 'Service', 'getReferenceAnalysesGroupID', 'Partition', 'Result', 'Uncertainty', 'CaptureDate', 'Retractions' ] self.chart = EvolutionChart() def isItemAllowed(self, obj): """ :obj: it is a brain """ allowed = super(InstrumentReferenceAnalysesView, self).isItemAllowed(obj) return allowed or obj.getResult != '' def folderitem(self, obj, item, index): item = super(InstrumentReferenceAnalysesView, self).folderitem(obj, item, index) analysis = api.get_object(obj) # Partition is used to group/toggle QC Analyses sample = analysis.getSample() item['replace']['Partition'] = get_link(api.get_url(sample), api.get_id(sample)) # Get retractions field item['Retractions'] = '' report = analysis.getRetractedAnalysesPdfReport() if report: url = api.get_url(analysis) href = "{}/at_download/RetractedAnalysesPdfReport".format(url) attrs = {"class": "pdf", "target": "_blank"} title = _("Retractions") link = get_link(href, title, **attrs) item['Retractions'] = title item['replace']['Retractions'] = link # Add the analysis to the QC Chart self.chart.add_analysis(analysis) return item