Пример #1
0
    def __init__(self, context, request):
        AnalysesView.__init__(self, context, request)
        self.icon = "++resource++bika.lims.images/worksheet_big.png"
        self.contentFilter = {}
        self.show_select_row = False
        self.show_sort_column = False
        self.allow_edit = True

        self.columns = {
            'Pos': {'title': _('Position')},
            'DueDate': {'title': _('Due date')},
            'Category': {'title': _('Category')},
            'Service': {'title': _('Analysis')},
            'Result': {'title': _('Result')},
            'Uncertainty': {'title': _('+-')},
            'retested': {'title': _('Retested'), 'type':'boolean'},
##            'Attachments': {'title': _('Attachments')},
            'state_title': {'title': _('State')},
        }
        self.review_states = [
            {'title': _('All'), 'id':'all',
             'transitions': ['submit', 'verify', 'retract', 'unassign'],
             'columns':['Pos',
                        'Category',
                        'Service',
                        'Result',
                        'Uncertainty',
##                        'Attachments',
                        'DueDate',
                        'state_title'],
             },
        ]
Пример #2
0
    def __init__(self, context, request):
        AnalysesView.__init__(self, context, request)
        self.contentFilter = {'portal_type':'ReferenceAnalysis',
                              'path': {'query':"/".join(self.context.getPhysicalPath()),
                                       'level':0}}
        self.show_select_row = False
        self.show_sort_column = False
        self.show_select_column = False
        self.allow_edit = False

        self.columns = {
            'id': {'title': _('ID')},
            'Category': {'title': _('Category')},
            'Service': {'title': _('Service')},
            'Worksheet': {'title': _('Worksheet')},
            'Result': {'title': _('Result')},
            'Uncertainty': {'title': _('+-')},
            'DueDate': {'title': _('Due Date')},
            'retested': {'title': _('Retested'), 'type':'boolean'},
            'state_title': {'title': _('State')},
        }
        self.review_states = [
            {'id':'all',
             'title': _('All'),
             'transitions': [],
             'columns':['id',
                        'Category',
                        'Service',
                        'Worksheet',
                        'Result',
                        'Uncertainty',
                        'DueDate',
                        'state_title'],
             },
        ]
Пример #3
0
    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()
Пример #4
0
    def __init__(self, context, request):
        BaseView.__init__(self, context, request)
        self.catalog = 'bika_analysis_catalog'
        self.contentFilter = {'portal_type':'Analysis',
                              'review_state':'sample_received',
                              'worksheetanalysis_review_state':'unassigned'}
        self.icon = self.portal_url + "/++resource++bika.lims.images/worksheet_big.png"
        self.contentFilter = {}
        self.show_select_row = False
        self.show_sort_column = False
        self.allow_edit = True
        self.show_categories = False
        self.expand_all_categories = False

        self.columns = {
            'Pos': {'title': _('Position')},
            'DueDate': {'title': _('Due Date')},
            'Service': {'title': _('Analysis')},
            'getPriority': {'title': _('Priority')},
            'Method': {'title': _('Method')},
            'DetectionLimit': {
                'title': _('DL'),
                'sortable': False,
                'toggle': False},
            'Result': {'title': _('Result'),
                       'input_width': '6',
                       'input_class': 'ajax_calculate numeric',
                       'sortable': False},
            'Uncertainty': {'title': _('+-')},
            'ResultDM': {'title': _('Dry')},
            'retested': {'title': "<img src='++resource++bika.lims.images/retested.png' title='%s'/>" % _('Retested'),
                         'type':'boolean'},
            'Attachments': {'title': _('Attachments')},
            'Instrument': {'title': _('Instrument')},
            'state_title': {'title': _('State')},
            'Priority': { 'title': _('Priority'), 'index': 'Priority'},
        }
        self.review_states = [
            {'id':'default',
             'title': _('All'),
             'contentFilter':{},
             'transitions': [{'id':'submit'},
                             {'id':'verify'},
                             {'id':'retract'},
                             {'id':'unassign'}],
             'columns':['Pos',
                        'Service',
                        'Priority',
                        'Method',
                        'Instrument',
                        'DetectionLimit',
                        'Result',
                        'Uncertainty',
                        'DueDate',
                        'state_title',
                        'Attachments']
             },
        ]
Пример #5
0
 def __init__(self, context, request):
     BaseView.__init__(self, context, request)
     self.context = context
     self.request = request
     self.analyst = None
     self.instrument = None
     self.contentFilter = {
         'getWorksheetUID': context.UID(),
         'sort_on': 'sortable_title'
     }
     self.sort_on = 'sortable_title'
     self.icon = self.portal_url + "/++resource++bika.lims.images/worksheet_big.png"
     self.allow_edit = True
     self.show_categories = False
     self.expand_all_categories = False
     self.columns = {
         'Pos': {'title': _('Position')},
         'DueDate': {'title': _('Due Date')},
         'Service': {'title': _('Analysis')},
         'Method': {'title': _('Method')},
         'DetectionLimit': {
             'title': _('DL'),
             'sortable': False,
             'toggle': False},
         'Result': {'title': _('Result'),
                    'input_width': '6',
                    'input_class': 'ajax_calculate numeric',
                    'sortable': False},
         'Uncertainty': {'title': _('+-')},
         'retested': {'title': "<img src='++resource++bika.lims.images/retested.png' title='%s'/>" % _('Retested'),
                      'type':'boolean'},
         'Attachments': {'title': _('Attachments')},
         'Instrument': {'title': _('Instrument')},
         'state_title': {'title': _('State')},
     }
     self.review_states = [
         {'id':'default',
          'title': _('All'),
          'contentFilter':{},
          'transitions': [{'id':'submit'},
                          {'id':'verify'},
                          {'id':'retract'},
                          {'id':'unassign'}],
          'columns':['Pos',
                     'Service',
                     'Method',
                     'Instrument',
                     'DetectionLimit',
                     'Result',
                     'Uncertainty',
                     'DueDate',
                     'state_title',
                     'Attachments']
          },
     ]
     self.bika_setup = api.get_bika_setup()
     self.uids_strpositions = self.get_uids_strpositions()
     self.items_rowspans = dict()
Пример #6
0
    def __init__(self, context, request):
        AnalysesView.__init__(self, context, request)
        self.catalog = 'bika_analysis_catalog'
        self.contentFilter = {'portal_type':'ReferenceAnalysis',
                              'path': {'query':"/".join(self.context.getPhysicalPath()),
                                       'level':0}}
        self.show_select_row = False
        self.show_sort_column = False
        self.show_select_column = False
        self.allow_edit = False

        self.columns = {
            'id': {'title': _('ID'), 'toggle':False},
            'getReferenceAnalysesGroupID':
                {'title': _('QC Sample ID'),
                 'sortable': False,
                 '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},
            'Captured': {'title': _('Captured'), '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',
                        'Captured',
                        'Uncertainty',
                        'DueDate',
                        'state_title'],
             },
        ]
        self.anjson = {}
Пример #7
0
    def __init__(self, context, request):
        AnalysesView.__init__(self, context, request)
        self.catalog = 'bika_analysis_catalog'
        self.contentFilter = {'portal_type':'ReferenceAnalysis',
                              'path': {'query':"/".join(self.context.getPhysicalPath()),
                                       'level':0}}
        self.show_select_row = False
        self.show_sort_column = False
        self.show_select_column = False
        self.allow_edit = False

        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},
            'Captured': {'title': _('Captured'), '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',
                        'Captured',
                        'Uncertainty',
                        'DueDate',
                        'state_title'],
             },
        ]
        self.anjson = {}
Пример #8
0
 def __init__(self, context, request, **kwargs):
     AnalysesView.__init__(self, context, request)
     self.show_select_column = False
     self.allow_edit = False
     self.show_workflow_action_buttons = False
     for k, v in kwargs.items():
         self.contentFilter[k] = v
     self.columns['Request'] = {'title': _("Request"), 'sortable': False}
     # Add Request column
     pos = self.review_states[0]['columns'].index('Service') + 1
     self.review_states[0]['columns'].insert(pos, 'Request')
Пример #9
0
 def __init__(self, context, request, **kwargs):
     AnalysesView.__init__(self, context, request)
     for k,v in kwargs.items():
         self.contentFilter[k] = v
     if kwargs.get('getPointOfCapture', '') == 'lab':
         self.allow_edit = False
         self.columns['Request'] = {'title': _("Request"),
                                    'sortable':False}
         # Add Request column
         pos = self.review_states[0]['columns'].index('Service') + 1
         self.review_states[0]['columns'].insert(pos, 'Request')
Пример #10
0
 def __call__(self):
     ar = self.context
     self.tables = {}
     for poc in POINTS_OF_CAPTURE:
         if self.context.getAnalyses(getPointOfCapture=poc):
             t = AnalysesView(ar,
                              self.request,
                              getPointOfCapture = poc)
             t.allow_edit = False
             t.show_select_column = False
             self.tables[POINTS_OF_CAPTURE.getValue(poc)] = t.contents_table()
     return self.template()
Пример #11
0
 def __init__(self, context, request, **kwargs):
     AnalysesView.__init__(self, context, request)
     self.show_select_column = False
     self.allow_edit = False
     self.show_workflow_action_buttons = False
     for k,v in kwargs.items():
         self.contentFilter[k] = v
     self.columns['Request'] = {'title': _("Request"),
                                'sortable':False}
     # Add Request column
     pos = self.review_states[0]['columns'].index('Service') + 1
     self.review_states[0]['columns'].insert(pos, 'Request')
Пример #12
0
 def __init__(self, context, request, **kwargs):
     AnalysesView.__init__(self, context, request)
     self.show_select_column = False
     self.allow_edit = False
     self.show_workflow_action_buttons = False
     for k, v in kwargs.items():
         self.contentFilter[k] = v
     self.columns["Request"] = {"title": _("Request"), "sortable": False}
     self.columns["Priority"] = {"title": _("Priority"), "sortable": False}
     # Add Request and Priority columns
     pos = self.review_states[0]["columns"].index("Service") + 1
     self.review_states[0]["columns"].insert(pos, "Request")
     pos += 1
     self.review_states[0]["columns"].insert(pos, "Priority")
Пример #13
0
 def __init__(self, context, request, **kwargs):
     AnalysesView.__init__(self, context, request)
     self.show_workflow_action_buttons = False
     for k,v in kwargs.items():
         self.contentFilter[k] = v
     self.contentFilter['getSampleUID'] = context.UID()
     self.columns['Request'] = {
         'title': _("Request"),
         'attr': 'getParentTitle',
         'replace_url': 'getParentURL',
         'sortable': False}
     # Add Request columns
     pos = self.review_states[0]['columns'].index('Service') + 1
     self.review_states[0]['columns'].insert(pos, 'Request')
     pos += 1
Пример #14
0
    def folderitems(self):
        """Returns an array of dictionaries, each dictionary represents an
        analysis row to be rendered in the list. The array returned is sorted
        in accordance with the layout positions set for the analyses this
        worksheet contains when the analyses were added in the worksheet.

        :returns: list of dicts with the items to be rendered in the list
        """
        items = BaseView.folderitems(self)

        # Fill empty positions from the layout with fake rows. The worksheet
        # can be generated by making use of a WorksheetTemplate, so there is
        # the chance that some slots of this worksheet being empty. We need to
        # render a row still, at lest to display the slot number (Pos)
        self.fill_empty_slots(items)

        # Sort the items in accordance with the layout
        items = sorted(items, key=itemgetter("pos_sortkey"))

        # Fill the slot header cells (first cell of each row). Each slot
        # contains the analyses that belong to the same parent
        # (AnalysisRequest, ReferenceSample), so the information about the
        # parent must be displayed in the first cell of each slot.
        self.fill_slots_headers(items)

        return items
Пример #15
0
    def isItemAllowed(self, obj):
        """
        Checks if the passed in Analysis must be displayed in the list. If the
        'filtering by department' option is enabled in Bika Setup, this
        function checks if the Analysis Service associated to the Analysis
        is assigned to any of the currently selected departments (information
        stored in a cookie). In addition, the function checks if the Analysis
        matches with the filtering criterias set in the advanced filter bar.
        If no criteria in the advanced filter bar has been set and the option
        'filtering by department' is disblaed, returns True.

        :param obj: A single Analysis brain
        :type obj: CatalogBrain
        :returns: True if the item can be added to the list. Otherwise, False
        :rtype: bool
        """
        # The isItemAllowed function from the base class AnalysesView already
        # takes into account filtering by department
        allowed = AnalysesView.isItemAllowed(self, obj)
        if not allowed:
            return False

        if self.filter_bar_enabled:
            # Advanced filter bar is enabled. Check if the Analysis matches
            # with the filtering criterias.
            return self.filter_bar_check_item(obj)

        # By default, display the analysis
        return True
Пример #16
0
    def isItemAllowed(self, obj):
        """
        Checks if the passed in Analysis must be displayed in the list. If the
        'filtering by department' option is enabled in Bika Setup, this
        function checks if the Analysis Service associated to the Analysis
        is assigned to any of the currently selected departments (information
        stored in a cookie). In addition, the function checks if the Analysis
        matches with the filtering criterias set in the advanced filter bar.
        If no criteria in the advanced filter bar has been set and the option
        'filtering by department' is disblaed, returns True.

        :param obj: A single Analysis brain
        :type obj: CatalogBrain
        :returns: True if the item can be added to the list. Otherwise, False
        :rtype: bool
        """
        # The isItemAllowed function from the base class AnalysesView already
        # takes into account filtering by department
        allowed = AnalysesView.isItemAllowed(self, obj)
        if not allowed:
            return False

        if self.filter_bar_enabled:
            # Advanced filter bar is enabled. Check if the Analysis matches
            # with the filtering criterias.
            return self.filter_bar_check_item(obj)

        # By default, display the analysis
        return True
Пример #17
0
 def __init__(self, context, request, **kwargs):
     AnalysesView.__init__(self, context, request)
     self.show_workflow_action_buttons = False
     for k, v in kwargs.items():
         self.contentFilter[k] = v
     self.contentFilter['getSampleUID'] = context.UID()
     self.columns['Request'] = {
         'title': _("Request"),
         'attr': 'getParentTitle',
         'replace_url': 'getParentURL',
         'sortable': False
     }
     # Add Request columns
     pos = self.review_states[0]['columns'].index('Service') + 1
     self.review_states[0]['columns'].insert(pos, 'Request')
     pos += 1
Пример #18
0
 def folderitems(self):
     self.contentsMethod = self.context.getAnalyses
     items = AnalysesView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key('obj'):
             continue
         obj = items[x]['obj']
         ar = obj.aq_parent
         items[x]['replace']['Request'] = "<a href='%s'>%s</a>"%(ar.absolute_url(), ar.Title())
     return items
Пример #19
0
 def folderitems(self):
     self.contentsMethod = self.context.getAnalyses
     items = AnalysesView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key("obj"):
             continue
         obj = items[x]["obj"]
         ar = obj.aq_parent
         items[x]["replace"]["Request"] = "<a href='%s'>%s</a>" % (ar.absolute_url(), ar.Title())
         items[x]["replace"]["Priority"] = " "  # TODO this space is required for it to work
     return items
Пример #20
0
    def __call__(self):
        ar = self.context
        workflow = getToolByName(ar, 'portal_workflow')

        if workflow.getInfoFor(ar, 'cancellation_state') == "cancelled":
            self.request.response.redirect(ar.absolute_url())
        elif not(getSecurityManager().checkPermission(ManageResults, ar)):
            self.request.response.redirect(ar.absolute_url())
        else:
            self.tables = {}
            for poc in POINTS_OF_CAPTURE:
                if self.context.getAnalyses(getPointOfCapture=poc):
                    t = AnalysesView(ar,
                                     self.request,
                                     getPointOfCapture = poc)
                    t.allow_edit = True
                    t.review_states[0]['transitions'] = ['submit', 'retract', 'verify']
                    t.show_select_column = True
                    self.tables[POINTS_OF_CAPTURE.getValue(poc)] = t.contents_table()
            return self.template()
Пример #21
0
 def folderitems(self):
     self.contentsMethod = self.context.getAnalyses
     items = AnalysesView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key('obj'):
             continue
         obj = items[x]['obj']
         ar = obj.aq_parent
         items[x]['replace']['Request'] = \
             "<a href='%s'>%s</a>"%(ar.absolute_url(), ar.Title())
     return items
Пример #22
0
    def folderitem(self, obj, item, index):
        """
        Applies new properties to the item (analysis) that is currently being
        rendered as a row in the list.
        :param obj: analysis to be rendered as a row in the list
        :param item: dict representation of the analysis, suitable for the list
        :param index: current position of the item within the list
        :type obj: ATContentType/DexterityContentType
        :type item: dict
        :type index: int
        :return: the dict representation of the item
        :rtype: dict
        """
        item = BaseView.folderitem(self, obj, item, index)
        item_obj = api.get_object(obj)
        uid = item['uid']

        # Slot is the row position where all analyses sharing the same parent
        # (eg. AnalysisRequest, SampleReference), will be displayed as a group
        slot = self.get_item_slot(uid)
        item['Pos'] = slot

        # The position string contains both the slot + the position of the
        # analysis within the slot: "position_sortkey" will be used to sort all
        # the analyses to be displayed in the list
        str_position = self.uids_strpositions[uid]
        item['pos_sortkey'] = str_position

        item['colspan'] = {'Pos': 1}
        item['Service'] = item_obj.Title()
        item['Category'] = item_obj.getCategoryTitle()
        item['DueDate'] = self.ulocalized_time(item_obj, long_format=0)
        item['class']['Service'] = 'service_title'

        # To prevent extra loops, we compute here the number of analyses to be
        # rendered within each slot. This information will be useful later for
        # applying rowspan to the first cell of each slot, that contains info
        # about the parent of all the analyses contained in that slot (e.g
        # Analysis Request ID, Sample Type, etc.)
        rowspans = self.items_rowspans.get(slot, 0) + 1
        remarks = item.get('Remarks', None)
        remarks_edit = 'Remarks' in item.get('allow_edit', [])
        remarks_enabled = self.bika_setup.getEnableAnalysisRemarks()
        if remarks_enabled and (remarks or remarks_edit):
            # Increase in one unit the rowspan, cause the comment field for
            # this analysis will be rendered in a new row, below the row that
            # displays the current item
            rowspans += 1
        # We map this rowspan information in items_rowspan, that will be used
        # later during the rendereing of slot headers (first cell of each row)
        self.items_rowspans[slot] = rowspans

        return item
Пример #23
0
    def __init__(self, context, request, **kwargs):
        AnalysesView.__init__(self, context, request, **kwargs)
        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'
        ]

        analyses = self.context.getReferenceAnalyses()
        asuids = [an.UID() for an in analyses]
        self.catalog = 'bika_analysis_catalog'
        self.contentFilter = {'UID': asuids}
        self.anjson = {}
Пример #24
0
    def __init__(self, context, request, **kwargs):
        AnalysesView.__init__(self, context, request, **kwargs)
        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']


        analyses = self.context.getReferenceAnalyses()
        asuids = [an.UID() for an in analyses]
        self.catalog = 'bika_analysis_catalog'
        self.contentFilter = {'UID': asuids}
        self.anjson = {}
Пример #25
0
    def isItemAllowed(self, obj):
        """Returns true if the current analysis to be rendered has a slot
        assigned for the current layout.

        :param obj: analysis to be rendered as a row in the list
        :type obj: ATContentType/DexterityContentType
        :return: True if the obj has an slot assigned. Otherwise, False.
        :rtype: bool
        """
        uid = api.get_uid(obj)
        if not self.get_item_slot(uid):
            logger.warning("Slot not assigned to item %s" % uid)
            return False
        return BaseView.isItemAllowed(self, obj)
Пример #26
0
 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()
Пример #27
0
    def folderitem(self, obj, item, index):
        """
        In this case obj should be a brain
        """
        item = AnalysesView.folderitem(self, obj, item, index)
        if not item:
            return None

        # Worksheet
        item['Worksheet'] = ''
        wss = self.worksheet_catalog(getAnalysesUIDs={
                    "query": obj.UID,
                    "operator": "or"
                })
        if wss and len(wss) == 1:
            item['Worksheet'] = wss[0].Title
            anchor = '<a href="%s">%s</a>' % (wss[0].getURL(), wss[0].Title)
            item['replace']['Worksheet'] = anchor

        return item
Пример #28
0
    def folderitem(self, obj, item, index):
        """
        In this case obj should be a brain
        """
        item = AnalysesView.folderitem(self, obj, item, index)
        if not item:
            return None

        # Worksheet
        item['Worksheet'] = ''
        wss = self.worksheet_catalog(getAnalysesUIDs={
            "query": obj.UID,
            "operator": "or"
        })
        if wss and len(wss) == 1:
            item['Worksheet'] = wss[0].Title
            anchor = '<a href="%s">%s</a>' % (wss[0].getURL(), wss[0].Title)
            item['replace']['Worksheet'] = anchor

        return item
Пример #29
0
    def folderitems(self):
        items = AnalysesView.folderitems(self)
        items.sort(key=itemgetter('CaptureDate'), reverse=True)
        for i in range(len(items)):
            obj = items[i]['obj']
            imgtype = ""
            if obj.portal_type == 'ReferenceAnalysis':
                antype = QCANALYSIS_TYPES.getValue(obj.getReferenceType())
                if obj.getReferenceType() == 'c':
                    imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/control.png'/>&nbsp;" % (
                        antype, self.context.absolute_url())
                if obj.getReferenceType() == 'b':
                    imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/blank.png'/>&nbsp;" % (
                        antype, self.context.absolute_url())
                items[i]['replace']['Partition'] = "<a href='%s'>%s</a>" % (
                    obj.aq_parent.absolute_url(), obj.aq_parent.id)
            elif obj.portal_type == 'DuplicateAnalysis':
                antype = QCANALYSIS_TYPES.getValue('d')
                imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/duplicate.png'/>&nbsp;" % (
                    antype, self.context.absolute_url())
                items[i]['sortcode'] = '%s_%s' % (
                    obj.getSample().id, obj.getService().getKeyword())
            else:
                items[i]['sortcode'] = '%s_%s' % (
                    obj.getSample().id, obj.getService().getKeyword())

            items[i]['before']['Service'] = imgtype

            # Get retractions field
            pdf = obj.getRetractedAnalysesPdfReport()
            title = ''
            anchor = ''
            try:
                if pdf:
                    filesize = 0
                    title = _('Retractions')
                    anchor = "<a class='pdf' target='_blank' href='%s/at_download/RetractedAnalysesPdfReport'>%s</a>" % \
                             (obj.absolute_url(), _("Retractions"))
                    filesize = pdf.get_size()
                    filesize = filesize / 1024 if filesize > 0 else 0
            except:
                # POSKeyError: 'No blob file'
                # Show the record, but not the link
                title = _('Retraction report unavailable')
                anchor = title
            items[i]['Retractions'] = title
            items[i]['replace']['Retractions'] = anchor

            # Create json
            qcid = obj.aq_parent.id
            serviceref = "%s (%s)" % (items[i]['Service'], items[i]['Keyword'])
            trows = self.anjson.get(serviceref, {})
            anrows = trows.get(qcid, [])
            anid = '%s.%s' % (items[i]['getReferenceAnalysesGroupID'],
                              items[i]['id'])

            rr = obj.aq_parent.getResultsRangeDict()
            uid = obj.getServiceUID()
            if uid in rr:
                specs = rr[uid]
                try:
                    smin = float(specs.get('min', 0))
                    smax = float(specs.get('max', 0))
                    error = float(specs.get('error', 0))
                    target = float(specs.get('result', 0))
                    result = float(items[i]['Result'])
                    error_amount = ((target / 100) *
                                    error) if target > 0 else 0
                    upper = smax + error_amount
                    lower = smin - error_amount

                    anrow = {
                        'date': items[i]['CaptureDate'],
                        'min': smin,
                        'max': smax,
                        'target': target,
                        'error': error,
                        'erroramount': error_amount,
                        'upper': upper,
                        'lower': lower,
                        'result': result,
                        'unit': items[i]['Unit'],
                        'id': items[i]['uid']
                    }
                    anrows.append(anrow)
                    trows[qcid] = anrows
                    self.anjson[serviceref] = trows
                except:
                    pass

        return items
Пример #30
0
    def __init__(self, context, request, **kwargs):
        AnalysesView.__init__(self, context, request)
        self.title = _("Analyses pending")
        self.show_select_all_checkbox = False
        self.show_categories = False
        self.pagesize = 50
        # Get temp objects that are too time consuming to obtain every time
        self.worksheet_catalog = getToolByName(context,
                                               CATALOG_WORKSHEET_LISTING)
        # Check if the filter bar functionality is activated or not
        self.filter_bar_enabled =\
            self.context.bika_setup.getDisplayAdvancedFilterBarForAnalyses()

        # each editable item needs it's own allow_edit
        # which is a list of field names.
        self.allow_edit = True

        self.columns['AnalysisRequest'] = {
            'title': _('Analysis Request'),
            'attr': 'getAnalysisRequestTitle',
            'replace_url': 'getAnalysisRequestURL',
            'sortable': False
        }
        self.columns['Worksheet'] = {
            'title': _('Worksheet'),
            'sortable': False
        }
        self.review_states = [
            {
                'id':
                'default',
                'title':
                _('Results pending'),
                'transitions': [
                    {
                        'id': 'sample'
                    },
                    {
                        'id': 'submit'
                    },
                    {
                        'id': 'cancel'
                    },
                    # {'id': 'assign'}
                ],
                'contentFilter': {
                    'review_state':
                    ['sample_received', 'assigned', 'attachment_due'],
                    'cancellation_state':
                    'active',
                },
                'columns': [
                    'AnalysisRequest',
                    'Worksheet',
                    'Service',
                    'Result',
                    'Uncertainty',
                    'Partition',
                    'Method',
                    'Instrument',
                    'Analyst',
                    'state_title',
                ]
            },
            {
                'id':
                'to_be_verified',
                'title':
                _('To be verified'),
                'transitions': [{
                    'id': 'verify'
                }, {
                    'id': 'cancel'
                }],
                'contentFilter': {
                    'review_state': ['to_be_verified'],
                    'cancellation_state': 'active',
                },
                'columns': [
                    'AnalysisRequest',
                    'Worksheet',
                    'Service',
                    'Result',
                    'Uncertainty',
                    'Partition',
                    'Method',
                    'Instrument',
                    'Analyst',
                    'state_title',
                ]
            },
        ]
Пример #31
0
    def __init__(self, context, request, **kwargs):
        AnalysesView.__init__(self, context, request)
        self.title = _("Analyses pending")
        self.show_select_all_checkbox = False
        self.show_categories = False
        self.pagesize = 50
        # Get temp objects that are too time consuming to obtain every time
        self.worksheet_catalog = getToolByName(context,
                                               CATALOG_WORKSHEET_LISTING)

        # each editable item needs it's own allow_edit
        # which is a list of field names.
        self.allow_edit = False

        self.columns['AnalysisRequest'] = {
            'title': _('Analysis Request'),
            'attr': 'getRequestID',
            'replace_url': 'getRequestURL',
            'sortable': False
        }
        self.columns['Worksheet'] = {
            'title': _('Worksheet'),
            'sortable': False
        }
        self.review_states = [
            {
                'id':
                'default',
                'title':
                _('Assignment pending'),
                'transitions': [
                    {
                        'id': 'submit'
                    },
                ],
                'contentFilter': {
                    'review_state': ['unassigned'],
                    'cancellation_state': 'active',
                },
                'columns': [
                    'AnalysisRequest',
                    'Service',
                    'Result',
                    'Uncertainty',
                    'Partition',
                    'Method',
                    'Instrument',
                    'DetectionLimit',
                    'Specification',
                    'state_title',
                ]
            },
            {
                'id':
                'results_pending',
                'title':
                _('Results pending'),
                'transitions': [
                    {
                        'id': 'submit'
                    },
                ],
                'contentFilter': {
                    'review_state': ['unassigned', 'assigned'],
                    'cancellation_state': 'active',
                },
                'columns': [
                    'AnalysisRequest',
                    'Worksheet',
                    'Service',
                    'Result',
                    'Uncertainty',
                    'Partition',
                    'Method',
                    'Instrument',
                    'DetectionLimit',
                    'Specification',
                    'Analyst',
                    'state_title',
                ]
            },
            {
                'id':
                'to_be_verified',
                'title':
                _('To be verified'),
                'transitions': [{
                    'id': 'verify'
                }, {
                    'id': 'retract'
                }],
                'contentFilter': {
                    'review_state': ['to_be_verified'],
                    'cancellation_state': 'active',
                },
                'columns': [
                    'AnalysisRequest',
                    'Worksheet',
                    'Service',
                    'Result',
                    'Uncertainty',
                    'Partition',
                    'Method',
                    'Instrument',
                    'DetectionLimit',
                    'Specification',
                    'Analyst',
                    'state_title',
                ]
            },
            {
                'id':
                'verified',
                'title':
                _('Verified'),
                'transitions': [],
                'contentFilter': {
                    'review_state': ['verified'],
                    'cancellation_state': 'active',
                },
                'columns': [
                    'AnalysisRequest',
                    'Worksheet',
                    'Service',
                    'Result',
                    'Uncertainty',
                    'Partition',
                    'Method',
                    'Instrument',
                    'DetectionLimit',
                    'Specification',
                    'Analyst',
                    'state_title',
                ]
            },
        ]
Пример #32
0
    def folderitems(self):
        items = AnalysesView.folderitems(self)
        items.sort(key=itemgetter('CaptureDate'), reverse=True)
        for i in range(len(items)):
            obj = items[i]['obj']
            imgtype = ""
            if obj.portal_type == 'ReferenceAnalysis':
                antype = QCANALYSIS_TYPES.getValue(obj.getReferenceType())
                if obj.getReferenceType() == 'c':
                    imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/control.png'/>&nbsp;" % (antype, self.context.absolute_url())
                if obj.getReferenceType() == 'b':
                    imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/blank.png'/>&nbsp;" % (antype, self.context.absolute_url())
                items[i]['replace']['Partition'] = "<a href='%s'>%s</a>" % (obj.aq_parent.absolute_url(), obj.aq_parent.id)
            elif obj.portal_type == 'DuplicateAnalysis':
                antype = QCANALYSIS_TYPES.getValue('d')
                imgtype = "<img title='%s' src='%s/++resource++bika.lims.images/duplicate.png'/>&nbsp;" % (antype, self.context.absolute_url())
                items[i]['sortcode'] = '%s_%s' % (obj.getSample().id, obj.getService().getKeyword())
            else:
                items[i]['sortcode'] = '%s_%s' % (obj.getSample().id, obj.getService().getKeyword())

            items[i]['before']['Service'] = imgtype

            # Get retractions field
            pdf = obj.getRetractedAnalysesPdfReport()
            title = ''
            anchor = ''
            try:
                if pdf:
                    filesize = 0
                    title = _('Retractions')
                    anchor = "<a class='pdf' target='_blank' href='%s/at_download/RetractedAnalysesPdfReport'>%s</a>" % \
                             (obj.absolute_url(), _("Retractions"))
                    filesize = pdf.get_size()
                    filesize = filesize / 1024 if filesize > 0 else 0
            except:
                # POSKeyError: 'No blob file'
                # Show the record, but not the link
                title = _('Retraction report unavailable')
                anchor = title
            items[i]['Retractions'] = title
            items[i]['replace']['Retractions'] = anchor


            # Create json
            qcid = obj.aq_parent.id;
            serviceref = "%s (%s)" % (items[i]['Service'], items[i]['Keyword'])
            trows = self.anjson.get(serviceref, {});
            anrows = trows.get(qcid, []);
            anid = '%s.%s' % (items[i]['getReferenceAnalysesGroupID'],
                              items[i]['id'])

            rr = obj.aq_parent.getResultsRangeDict()
            uid = obj.getServiceUID()
            if uid in rr:
                specs = rr[uid];
                try:
                    smin  = float(specs.get('min', 0))
                    smax = float(specs.get('max', 0))
                    error  = float(specs.get('error', 0))
                    target = float(specs.get('result', 0))
                    result = float(items[i]['Result'])
                    error_amount = ((target / 100) * error) if target > 0 else 0
                    upper  = smax + error_amount
                    lower   = smin - error_amount

                    anrow = { 'date': items[i]['CaptureDate'],
                              'min': smin,
                              'max': smax,
                              'target': target,
                              'error': error,
                              'erroramount': error_amount,
                              'upper': upper,
                              'lower': lower,
                              'result': result,
                              'unit': items[i]['Unit'],
                              'id': items[i]['uid'] }
                    anrows.append(anrow);
                    trows[qcid] = anrows;
                    self.anjson[serviceref] = trows
                except:
                    pass

        return items
Пример #33
0
 def __init__(self, context, request):
     AnalysesView.__init__(self, context, request)
     self.icon = "++resource++bika.lims.images/worksheet_big.png"
     self.title = "%s: %s" % (context.Title(), _("Add Analyses"))
     self.description = _("")
Пример #34
0
    def __init__(self, context, request, **kwargs):
        AnalysesView.__init__(self, context, request)
        self.title = _("Analyses pending")
        self.show_select_all_checkbox = False
        self.show_categories = False
        self.pagesize = 50
        # Get temp objects that are too time consuming to obtain every time
        self.worksheet_catalog = getToolByName(
            context, CATALOG_WORKSHEET_LISTING)
        # Check if the filter bar functionality is activated or not
        self.filter_bar_enabled =\
            self.context.bika_setup.getDisplayAdvancedFilterBarForAnalyses()

        # each editable item needs it's own allow_edit
        # which is a list of field names.
        self.allow_edit = True

        self.columns['AnalysisRequest'] = {
            'title': _('Analysis Request'),
            'attr': 'getRequestID',
            'replace_url': 'getRequestURL',
            'sortable': False
            }
        self.columns['Worksheet'] = {
            'title': _('Worksheet'),
            'sortable': False
            }
        self.review_states = [
            {'id': 'default',
             'title':  _('Results pending'),
             'transitions': [{'id': 'sample'},
                             {'id': 'submit'},
                             {'id': 'cancel'},
                             # {'id': 'assign'}
                             ],
             'contentFilter': {'review_state': [
                'sample_received', 'assigned', 'attachment_due'],
                'cancellation_state': 'active', },
             'columns': ['AnalysisRequest',
                         'Worksheet',
                         'Service',
                         'Result',
                         'Uncertainty',
                         'Partition',
                         'Method',
                         'Instrument',
                         'Analyst',
                         'state_title',
                         ]
             },
            {'id': 'to_be_verified',
             'title':  _('To be verified'),
             'transitions': [{'id': 'verify'},
                             {'id': 'cancel'}
                             ],
             'contentFilter': {
                'review_state': ['to_be_verified'],
                'cancellation_state': 'active', },
             'columns': ['AnalysisRequest',
                         'Worksheet',
                         'Service',
                         'Result',
                         'Uncertainty',
                         'Partition',
                         'Method',
                         'Instrument',
                         'Analyst',
                         'state_title',
                         ]
             },
        ]
Пример #35
0
    def folderitems(self):
        self.analyst = self.context.getAnalyst().strip()
        self.instrument = self.context.getInstrument()
        self.contentsMethod = self.context.getFolderContents
        items = AnalysesView.folderitems(self)
        layout = self.context.getLayout()
        highest_position = 0
        for x, item in enumerate(items):
            obj = item['obj']
            pos = [int(slot['position']) for slot in layout if
                   slot['analysis_uid'] == obj.UID()][0]
            highest_position = max(highest_position, pos)
            items[x]['Pos'] = pos
            items[x]['colspan'] = {'Pos':1}
            service = obj.getService()
            method = service.getMethod()
            items[x]['Service'] = service.Title()
            items[x]['Method'] = method and method.Title() or ''
            items[x]['class']['Service'] = 'service_title'
            items[x]['Category'] = service.getCategory().Title()
            if obj.portal_type == "ReferenceAnalysis":
                items[x]['DueDate'] = ''
            else:
                items[x]['DueDate'] = self.ulocalized_time(obj.getDueDate())

            items[x]['Order'] = ''

        # insert placeholder row items in the gaps
        empties = []
        used = [int(slot['position']) for slot in layout]
        for pos in range(1, highest_position + 1):
            if pos not in used:
                empties.append(pos)
                item = {}
                item.update({
                    'obj': self.context,
                    'id': self.context.id,
                    'uid': self.context.UID(),
                    'title': self.context.Title(),
                    'type_class': 'blank-worksheet-row',
                    'url': self.context.absolute_url(),
                    'relative_url': self.context.absolute_url(),
                    'view_url': self.context.absolute_url(),
                    'path': "/".join(self.context.getPhysicalPath()),
                    'before': {},
                    'after': {},
                    'choices': {},
                    'class': {},
                    'state_class': 'state-empty',
                    'allow_edit': [],
                    'colspan': {'Pos':len(self.columns) + len(self.interim_fields)},
                    'rowspan': {'Pos':1},
                    'Pos': pos,
                    'Service': '',
                    'Attachments': '',
                    'state_title': 's'})
                item['replace'] = {
                    'Pos': "<table width='100%' cellpadding='0' cellspacing='0'>" + \
                            "<tr><td class='pos'>%s</td>" % pos + \
                            "<td align='right'>&nbsp;</td></tr></table>",
                    'select_column': '',
                    }
                items.append(item)

        items = sorted(items, key = itemgetter('Service'))
        items = sorted(items, key = itemgetter('Pos'))

        slot_items = {} # pos:[item_nrs]
        for x in range(len(items)):
            p = items[x]['Pos']
            if p in slot_items:
                slot_items[p].append(x)
            else:
                slot_items[p] = [x, ]
        actual_table_position = -1
        # The first item in items[this position] gets a rowspan for it's
        # "Position" column, which spans all other table rows in this position.
        for pos, pos_items in slot_items.items():
            actual_table_position += 1
            x = pos_items[0]
            if pos in empties:
                continue

            # set Pos column for this row, to have a rowspan
            items[x]['rowspan'] = {'Pos': len(pos_items)}

            # fill the rowspan with a little table
            obj = items[x]['obj']
            # parent is either an AR, a Worksheet, or a
            # ReferenceSample (analysis parent).
            parent = obj.aq_parent
            if parent.aq_parent.portal_type == "WorksheetFolder":
                # we're a duplicate; get original object's client
                client = obj.getAnalysis().aq_parent.aq_parent
            elif parent.aq_parent.portal_type == "ReferenceSupplier":
                # we're a reference sample; get reference definition
                client = obj.getReferenceDefinition()
            else:
                client = parent.aq_parent
            pos_text = "<table class='worksheet-position' width='100%%' cellpadding='0' cellspacing='0' style='padding-bottom:5px;'><tr>" + \
                       "<td class='pos' rowspan='3'>%s</td>" % pos
            pos_text += "<td class='pos_top'><a href='%s'>%s</a></td>" % \
                (client.absolute_url(), client.Title())
            pos_text += "<td class='pos_top_icons' rowspan='3'>"
            if obj.portal_type == 'DuplicateAnalysis':
                pos_text += "<img title='%s' src='%s/++resource++bika.lims.images/duplicate.png'/>" % (_("Duplicate"), self.context.absolute_url())
                pos_text += "<br/>"
            elif obj.portal_type == 'ReferenceAnalysis' and obj.ReferenceType == 'b':
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/blank.png'></a>" % (parent.absolute_url(), parent.Title())
                pos_text += "<br/>"
            elif obj.portal_type == 'ReferenceAnalysis' and obj.ReferenceType == 'c':
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/control.png'></a>" % (parent.absolute_url(), parent.Title())
                pos_text += "<br/>"
            if parent.portal_type == 'AnalysisRequest':
                sample = parent.getSample()
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/sample.png'></a>" % (sample.absolute_url(), sample.Title())
            pos_text += "</td></tr>"

            pos_text += "<tr><td>"
            if parent.portal_type == 'AnalysisRequest':
                pos_text += "<a href='%s'>%s</a>" % (parent.absolute_url(), parent.Title())
            elif parent.portal_type == 'ReferenceSample':
                pos_text += "<a href='%s'>%s</a>" % (parent.absolute_url(), parent.Title())
            elif parent.portal_type == 'Worksheet':
                parent = obj.getAnalysis().aq_parent
                pos_text += "<a href='%s'>(%s)</a>" % (parent.absolute_url(), parent.Title())
            pos_text += "</td></tr>"

            # sampletype
            pos_text += "<tr><td>"
            if obj.portal_type == 'Analysis':
                pos_text += obj.aq_parent.getSample().getSampleType().Title()
            elif obj.portal_type == 'ReferenceAnalysis':
                pos_text += "" #obj.aq_parent.getReferenceDefinition().Title()
            elif obj.portal_type == 'DuplicateAnalysis':
                pos_text += obj.getAnalysis().aq_parent.getSample().getSampleType().Title()
            pos_text += "</td></tr>"

            # samplingdeviation
            if obj.portal_type == 'Analysis':
                deviation = obj.aq_parent.getSample().getSamplingDeviation()
                if deviation:
                    pos_text += "<tr><td>"
                    pos_text += deviation.Title()
                    pos_text += "</td></tr>"

##            # barcode
##            barcode = parent.id.replace("-", "")
##            if obj.portal_type == 'DuplicateAnalysis':
##                barcode += "D"
##            pos_text += "<tr><td class='barcode' colspan='3'><div id='barcode_%s'></div>" % barcode + \
##                "<script type='text/javascript'>$('#barcode_%s').barcode('%s', 'code39', {'barHeight':15, addQuietZone:false, showHRI: false })</script>" % (barcode, barcode) + \
##                "</td></tr>"

            pos_text += "</table>"

            items[x]['replace']['Pos'] = pos_text

        for k,v in self.columns.items():
            self.columns[k]['sortable'] = False

        return items
Пример #36
0
    def folderitems(self):
        self.analyst = self.context.getAnalyst().strip()
        self.instrument = self.context.getInstrument()
        items = BaseView.folderitems(self)
        layout = self.context.getLayout()
        highest_position = 0
        new_items = []
        for x, item in enumerate(items):
            obj = item['obj'].getObject()
            pos = [
                slot['position'] for slot in layout
                if slot['analysis_uid'] == obj.UID()
            ][0]

            # compensate for possible bad data (dbw#104)
            if type(pos) in (list, tuple):
                pos = pos[0]
                if pos == 'new':
                    continue
            pos = int(pos)

            highest_position = max(highest_position, pos)
            items[x]['Pos'] = pos
            items[x]['colspan'] = {'Pos': 1}
            method = obj.getMethod()
            items[x]['Service'] = obj.Title()
            #items[x]['Method'] = method and method.Title() or ''
            items[x]['class']['Service'] = 'service_title'
            items[x]['Category'] = obj.getCategoryTitle()
            if obj.portal_type == "ReferenceAnalysis":
                items[x]['DueDate'] = self.ulocalized_time(
                    obj.aq_parent.getExpiryDate(), long_format=0)
            else:
                items[x]['DueDate'] = self.ulocalized_time(obj.getDueDate())

            items[x]['Order'] = ''
            # instrument = obj.getInstrument()
            #items[x]['Instrument'] = instrument and instrument.Title() or ''

            new_items.append(item)
        items = new_items

        # insert placeholder row items in the gaps
        # This is done badly to compensate for possible bad data (dbw#104)
        empties = []
        used = []
        for slot in layout:
            position = slot['position']
            if type(position) in (list, tuple):
                position = position[0]
                if position == 'new':
                    continue
            position = int(position)
            used.append(position)

        for pos in range(1, highest_position + 1):
            if pos not in used:
                empties.append(pos)
                item = {}
                item.update({
                    'obj': self.context,
                    'id': self.context.id,
                    'uid': self.context.UID(),
                    'title': self.context.Title(),
                    'type_class': 'blank-worksheet-row',
                    'url': self.context.absolute_url(),
                    'relative_url': self.context.absolute_url(),
                    'view_url': self.context.absolute_url(),
                    'path': "/".join(self.context.getPhysicalPath()),
                    'before': {},
                    'after': {},
                    'choices': {},
                    'class': {},
                    'state_class': 'state-empty',
                    'allow_edit': [],
                    'colspan': {
                        'Pos': len(self.columns) + len(self.interim_fields)
                    },
                    'rowspan': {
                        'Pos': 1
                    },
                    'Pos': pos,
                    'Service': '',
                    'Attachments': '',
                    'state_title': 's',
                })
                item['replace'] = {
                    'Pos': "<table width='100%' cellpadding='0' cellspacing='0'>" + \
                            "<tr><td class='pos'>%s</td>" % pos + \
                            "<td align='right'>&nbsp;</td></tr></table>",
                    'select_column': '',
                    }
                items.append(item)

        items = sorted(items, key=itemgetter('Service'))
        try:
            items = sorted(items, key=itemgetter('Pos'))
        except:
            pass

        slot_items = {}  # pos:[item_nrs]
        for x in range(len(items)):
            p = items[x]['Pos']
            if p in slot_items:
                slot_items[p].append(x)
            else:
                slot_items[p] = [
                    x,
                ]
        actual_table_position = -1
        # The first item in items[this position] gets a rowspan for it's
        # "Position" column, which spans all other table rows in this position.
        for pos, pos_items in slot_items.items():
            actual_table_position += 1
            x = pos_items[0]
            if pos in empties:
                continue

            # set Pos column for this row, to have a rowspan
            # Analysis Remarks only allowed for Analysis types
            # Needs to look inside all slot analyses, cause some of them can
            # have remarks entered and can have different analysis statuses
            rowspan = len(pos_items)
            remarksenabled = self.context.bika_setup.getEnableAnalysisRemarks()
            for pos_subitem in pos_items:
                subitem = items[pos_subitem]
                isanalysis = subitem['obj'].portal_type == 'Analysis'
                hasremarks = True if subitem.get('Remarks', '') else False
                remarksedit = remarksenabled and 'Remarks' in subitem.get(
                    'allow_edit', [])
                if isanalysis and (hasremarks or remarksedit):
                    rowspan += 1
            items[x]['rowspan'] = {'Pos': rowspan}
            # TODO-performance: getting the object here...
            obj = items[x]['obj'].getObject()
            # fill the rowspan with a little table
            # parent is either an AR, a Worksheet, or a
            # ReferenceSample (analysis parent).
            parent = obj.aq_parent
            if parent.aq_parent.portal_type == "WorksheetFolder":
                # we're a duplicate; get original object's client
                client = obj.getAnalysis().aq_parent.aq_parent
            elif parent.aq_parent.portal_type == "Supplier":
                # we're a reference sample; get reference definition
                client = obj.getReferenceDefinition()
            else:
                client = parent.aq_parent
            pos_text = "<table class='worksheet-position' width='100%%' cellpadding='0' cellspacing='0' style='padding-bottom:5px;'><tr>" + \
                       "<td class='pos' rowspan='3'>%s</td>" % pos

            if obj.portal_type == 'ReferenceAnalysis':
                pos_text += "<td class='pos_top'>%s</td>" % obj.getReferenceAnalysesGroupID(
                )
            elif obj.portal_type == 'DuplicateAnalysis' and \
                obj.getAnalysis().portal_type == 'ReferenceAnalysis':
                pos_text += "<td class='pos_top'><a href='%s'>%s</a></td>" % \
                    (obj.aq_parent.absolute_url(), obj.aq_parent.id)
            elif client:
                pos_text += "<td class='pos_top'><a href='%s'>%s</a></td>" % \
                    (client.absolute_url(), client.Title())
            else:
                pos_text += "<td class='pos_top'>&nbsp;</td>"

            pos_text += "<td class='pos_top_icons' rowspan='3'>"
            if obj.portal_type == 'DuplicateAnalysis':
                pos_text += "<img title='%s' src='%s/++resource++bika.lims.images/duplicate.png'/>" % (
                    _("Duplicate").encode('utf-8'),
                    self.context.absolute_url())
                pos_text += "<br/>"
            elif obj.portal_type == 'ReferenceAnalysis' and obj.ReferenceType == 'b':
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/blank.png'></a>" % (
                    parent.absolute_url(), parent.Title())
                pos_text += "<br/>"
            elif obj.portal_type == 'ReferenceAnalysis' and obj.ReferenceType == 'c':
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/control.png'></a>" % (
                    parent.absolute_url(), parent.Title())
                pos_text += "<br/>"
            if parent.portal_type == 'AnalysisRequest':
                sample = parent.getSample()
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/sample.png'></a>" % (
                    sample.absolute_url(), sample.Title())
            pos_text += "</td></tr>"

            pos_text += "<tr><td>"
            if parent.portal_type == 'AnalysisRequest':
                pos_text += "<a href='%s'>%s</a>" % (parent.absolute_url(),
                                                     parent.Title())
            elif parent.portal_type == 'ReferenceSample':
                pos_text += "<a href='%s'>%s</a>" % (parent.absolute_url(),
                                                     parent.Title())
            elif obj.portal_type == 'DuplicateAnalysis':
                pos_text += "<a style='white-space:nowrap' href='%s'>%s</a>" % (
                    obj.getAnalysis().aq_parent.absolute_url(),
                    obj.getReferenceAnalysesGroupID())
            elif parent.portal_type == 'Worksheet':
                parent = obj.getAnalysis().aq_parent
                pos_text += "<a href='%s'>(%s)</a>" % (parent.absolute_url(),
                                                       parent.Title())
            pos_text += "</td></tr>"

            # sampletype
            pos_text += "<tr><td>"
            if obj.portal_type == 'Analysis':
                pos_text += obj.aq_parent.getSample().getSampleType().Title()
            elif obj.portal_type == 'ReferenceAnalysis' or \
                (obj.portal_type == 'DuplicateAnalysis' and \
                 obj.getAnalysis().portal_type == 'ReferenceAnalysis'):
                pos_text += ""  #obj.aq_parent.getReferenceDefinition().Title()
            elif obj.portal_type == 'DuplicateAnalysis':
                pos_text += obj.getAnalysis().aq_parent.getSample(
                ).getSampleType().Title()
            pos_text += "</td></tr>"

            # samplingdeviation
            if obj.portal_type == 'Analysis':
                deviation = obj.aq_parent.getSample().getSamplingDeviation()
                if deviation:
                    pos_text += "<tr><td>&nbsp;</td>"
                    pos_text += "<td colspan='2'>"
                    pos_text += deviation.Title()
                    pos_text += "</td></tr>"

##            # barcode
##            barcode = parent.id.replace("-", "")
##            if obj.portal_type == 'DuplicateAnalysis':
##                barcode += "D"
##            pos_text += "<tr><td class='barcode' colspan='3'><div id='barcode_%s'></div>" % barcode + \
##                "<script type='text/javascript'>$('#barcode_%s').barcode('%s', 'code128', {'barHeight':15, addQuietZone:false, showHRI: false })</script>" % (barcode, barcode) + \
##                "</td></tr>"

            pos_text += "</table>"

            items[x]['replace']['Pos'] = pos_text

        for k, v in self.columns.items():
            self.columns[k]['sortable'] = False

        return items
Пример #37
0
    def folderitems(self):
        self.analyst = self.context.getAnalyst().strip()
        self.instrument = self.context.getInstrument()
        self.contentsMethod = self.context.getFolderContents
        items = BaseView.folderitems(self)
        layout = self.context.getLayout()
        highest_position = 0
        new_items = []
        for x, item in enumerate(items):
            obj = item['obj']
            pos = [slot['position'] for slot in layout if
                   slot['analysis_uid'] == obj.UID()][0]

            # compensate for possible bad data (dbw#104)
            if type(pos) in (list, tuple):
                pos = pos[0]
                if pos == 'new':
                    continue
            pos = int(pos)

            highest_position = max(highest_position, pos)
            items[x]['Pos'] = pos
            items[x]['colspan'] = {'Pos':1}
            service = obj.getService()
            method = service.getMethod()
            items[x]['Service'] = service.Title()
            items[x]['Priority'] = ''
            #items[x]['Method'] = method and method.Title() or ''
            items[x]['class']['Service'] = 'service_title'
            items[x]['Category'] = service.getCategory() and service.getCategory().Title() or ''
            if obj.portal_type == "ReferenceAnalysis":
                items[x]['DueDate'] = self.ulocalized_time(obj.aq_parent.getExpiryDate(), long_format=0)
            else:
                items[x]['DueDate'] = self.ulocalized_time(obj.getDueDate())

            items[x]['Order'] = ''
            instrument = obj.getInstrument()
            #items[x]['Instrument'] = instrument and instrument.Title() or ''

            new_items.append(item)
        items = new_items

        # insert placeholder row items in the gaps
        # This is done badly to compensate for possible bad data (dbw#104)
        empties = []
        used = []
        for slot in layout:
            position = slot['position']
            if type(position) in (list, tuple):
                position = position[0]
                if position == 'new':
                    continue
            position = int(position)
            used.append(position)

        for pos in range(1, highest_position + 1):
            if pos not in used:
                empties.append(pos)
                item = {}
                item.update({
                    'obj': self.context,
                    'id': self.context.id,
                    'uid': self.context.UID(),
                    'title': self.context.Title(),
                    'type_class': 'blank-worksheet-row',
                    'url': self.context.absolute_url(),
                    'relative_url': self.context.absolute_url(),
                    'view_url': self.context.absolute_url(),
                    'path': "/".join(self.context.getPhysicalPath()),
                    'before': {},
                    'after': {},
                    'choices': {},
                    'class': {},
                    'state_class': 'state-empty',
                    'allow_edit': [],
                    'colspan': {'Pos':len(self.columns) + len(self.interim_fields)},
                    'rowspan': {'Pos':1},
                    'Pos': pos,
                    'Service': '',
                    'Attachments': '',
                    'state_title': 's',})
                item['replace'] = {
                    'Pos': "<table width='100%' cellpadding='0' cellspacing='0'>" + \
                            "<tr><td class='pos'>%s</td>" % pos + \
                            "<td align='right'>&nbsp;</td></tr></table>",
                    'select_column': '',
                    }
                items.append(item)

        items = sorted(items, key = itemgetter('Service'))
        try:
            items = sorted(items, key = itemgetter('Pos'))
        except:
            pass

        slot_items = {} # pos:[item_nrs]
        for x in range(len(items)):
            p = items[x]['Pos']
            if p in slot_items:
                slot_items[p].append(x)
            else:
                slot_items[p] = [x, ]
        actual_table_position = -1
        # The first item in items[this position] gets a rowspan for it's
        # "Position" column, which spans all other table rows in this position.
        for pos, pos_items in slot_items.items():
            actual_table_position += 1
            x = pos_items[0]
            if pos in empties:
                continue

            # set Pos column for this row, to have a rowspan
            # Analysis Remarks only allowed for Analysis types
            # Needs to look inside all slot analyses, cause some of them can
            # have remarks entered and can have different analysis statuses
            rowspan = len(pos_items)
            remarksenabled = self.context.bika_setup.getEnableAnalysisRemarks()
            for pos_subitem in pos_items:
                subitem = items[pos_subitem]
                isanalysis = subitem['obj'].portal_type == 'Analysis'
                hasremarks = True if subitem.get('Remarks', '') else False
                remarksedit = remarksenabled and 'Remarks' in subitem.get('allow_edit', [])
                if isanalysis and (hasremarks or remarksedit):
                    rowspan += 1
            items[x]['rowspan'] = {'Pos': rowspan}

            obj = items[x]['obj']
            # fill the rowspan with a little table
            # parent is either an AR, a Worksheet, or a
            # ReferenceSample (analysis parent).
            parent = obj.aq_parent
            if parent.aq_parent.portal_type == "WorksheetFolder":
                # we're a duplicate; get original object's client
                client = obj.getAnalysis().aq_parent.aq_parent
            elif parent.aq_parent.portal_type == "Supplier":
                # we're a reference sample; get reference definition
                client = obj.getReferenceDefinition()
            else:
                client = parent.aq_parent
            pos_text = "<table class='worksheet-position' width='100%%' cellpadding='0' cellspacing='0' style='padding-bottom:5px;'><tr>" + \
                       "<td class='pos' rowspan='3'>%s</td>" % pos

            if obj.portal_type == 'ReferenceAnalysis':
                pos_text += "<td class='pos_top'>%s</td>" % obj.getReferenceAnalysesGroupID()
            elif obj.portal_type == 'DuplicateAnalysis' and \
                obj.getAnalysis().portal_type == 'ReferenceAnalysis':
                pos_text += "<td class='pos_top'><a href='%s'>%s</a></td>" % \
                    (obj.aq_parent.absolute_url(), obj.aq_parent.id)
            elif client:
                pos_text += "<td class='pos_top'><a href='%s'>%s</a></td>" % \
                    (client.absolute_url(), client.Title())
            else:
                pos_text += "<td class='pos_top'>&nbsp;</td>"

            pos_text += "<td class='pos_top_icons' rowspan='3'>"
            if obj.portal_type == 'DuplicateAnalysis':
                pos_text += "<img title='%s' src='%s/++resource++bika.lims.images/duplicate.png'/>" % (_("Duplicate").encode('utf-8'), self.context.absolute_url())
                pos_text += "<br/>"
            elif obj.portal_type == 'ReferenceAnalysis' and obj.ReferenceType == 'b':
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/blank.png'></a>" % (parent.absolute_url(), parent.Title())
                pos_text += "<br/>"
            elif obj.portal_type == 'ReferenceAnalysis' and obj.ReferenceType == 'c':
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/control.png'></a>" % (parent.absolute_url(), parent.Title())
                pos_text += "<br/>"
            if parent.portal_type == 'AnalysisRequest':
                sample = parent.getSample()
                pos_text += "<a href='%s'><img title='%s' src='++resource++bika.lims.images/sample.png'></a>" % (sample.absolute_url(), sample.Title())
            pos_text += "</td></tr>"

            pos_text += "<tr><td>"
            if parent.portal_type == 'AnalysisRequest':
                pos_text += "<a href='%s'>%s</a>" % (parent.absolute_url(), parent.Title())
            elif parent.portal_type == 'ReferenceSample':
                pos_text += "<a href='%s'>%s</a>" % (parent.absolute_url(), parent.Title())
            elif obj.portal_type == 'DuplicateAnalysis':
                pos_text += "<a style='white-space:nowrap' href='%s'>%s</a>" % (obj.getAnalysis().aq_parent.absolute_url(), obj.getReferenceAnalysesGroupID())
            elif parent.portal_type == 'Worksheet':
                parent = obj.getAnalysis().aq_parent
                pos_text += "<a href='%s'>(%s)</a>" % (parent.absolute_url(), parent.Title())
            pos_text += "</td></tr>"

            # sampletype
            pos_text += "<tr><td>"
            if obj.portal_type == 'Analysis':
                pos_text += obj.aq_parent.getSample().getSampleType().Title()
            elif obj.portal_type == 'ReferenceAnalysis' or \
                (obj.portal_type == 'DuplicateAnalysis' and \
                 obj.getAnalysis().portal_type == 'ReferenceAnalysis'):
                pos_text += "" #obj.aq_parent.getReferenceDefinition().Title()
            elif obj.portal_type == 'DuplicateAnalysis':
                pos_text += obj.getAnalysis().aq_parent.getSample().getSampleType().Title()
            pos_text += "</td></tr>"

            # samplingdeviation
            if obj.portal_type == 'Analysis':
                deviation = obj.aq_parent.getSample().getSamplingDeviation()
                if deviation:
                    pos_text += "<tr><td>&nbsp;</td>"
                    pos_text += "<td colspan='2'>"
                    pos_text += deviation.Title()
                    pos_text += "</td></tr>"

##            # barcode
##            barcode = parent.id.replace("-", "")
##            if obj.portal_type == 'DuplicateAnalysis':
##                barcode += "D"
##            pos_text += "<tr><td class='barcode' colspan='3'><div id='barcode_%s'></div>" % barcode + \
##                "<script type='text/javascript'>$('#barcode_%s').barcode('%s', 'code128', {'barHeight':15, addQuietZone:false, showHRI: false })</script>" % (barcode, barcode) + \
##                "</td></tr>"

            pos_text += "</table>"

            items[x]['replace']['Pos'] = pos_text
            items[x]['getPriority'] = '' #Icon get added by adapter

        for k,v in self.columns.items():
            self.columns[k]['sortable'] = False

        return items
Пример #38
0
 def createAnalysesView(self, context, request, **kwargs):
     return AnalysesView(context, request, **kwargs)
Пример #39
0
 def folderitems(self):
     items = AnalysesView.folderitems(self)
     items = sorted(items, key = itemgetter('getReferenceAnalysesGroupID'))
     items.reverse()
     return items