예제 #1
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
예제 #2
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
예제 #3
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