예제 #1
0
    def folderitems(self):
        mtool = getToolByName(self.context, 'portal_membership')
        if mtool.checkPermission(ManageBika, self.context):
            del self.review_states[0]['transitions']
            self.show_select_column = True
            self.review_states.append(
                {'id': 'active',
                 'title': _('Active'),
                 'contentFilter': {'inactive_state': 'active'},
                 'transitions': [{'id':'deactivate'}, ],
                 'columns': ['Title', 'Description']})
            self.review_states.append(
                {'id': 'inactive',
                 'title': _('Dormant'),
                 'contentFilter': {'inactive_state': 'inactive'},
                 'transitions': [{'id':'activate'}, ],
                 'columns': ['Title', 'Description']})

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if 'obj' in items[x]:
                items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                     (items[x]['url'], items[x]['Title'])

        return items
예제 #2
0
    def folderitems(self):
        mtool = getToolByName(self.context, 'portal_membership')
        member = mtool.getAuthenticatedMember()
        roles = member.getRoles()
        self.allow_edit = 'LabManager' in roles or 'Manager' in roles

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'):
                continue
            obj = items[x]['obj']

            cat = obj.getCategoryTitle()
            # Category (upper C) is for display column value
            items[x]['Category'] = cat
            if self.do_cats:
                # category is for bika_listing to groups entries
                items[x]['category'] = cat
                if cat not in self.categories:
                    self.categories.append(cat)

            analyses = [a.UID() for a in self.field_value]
            items[x]['selected'] = items[x]['uid'] in analyses

            items[x]['class']['Title'] = 'service_title'

            calculation = obj.getCalculation()
            items[x]['Calculation'] = calculation and calculation.Title()

            locale = locales.getLocale('en')
            currency = self.context.bika_setup.getCurrency()
            symbol = locale.numbers.currencies[currency].symbol
            items[x]['Price'] = "%s %s" % (symbol, obj.getPrice())
            items[x]['class']['Price'] = 'nowrap'

            after_icons = ''
            if obj.getAccredited():
                after_icons += "<img\
                    src='%s/++resource++bika.lims.images/accredited.png'\
                    title='%s'>" % (self.context.absolute_url(),
                                    _("Accredited"))
            if obj.getReportDryMatter():
                after_icons += "<img\
                    src='%s/++resource++bika.lims.images/dry.png'\
                    title='%s'>" % (self.context.absolute_url(),
                                    _("Can be reported as dry matter"))
            if obj.getAttachmentOption() == 'r':
                after_icons += "<img\
                    src='%s/++resource++bika.lims.images/attach_reqd.png'\
                    title='%s'>" % (self.context.absolute_url(),
                                    _("Attachment required"))
            if obj.getAttachmentOption() == 'n':
                after_icons += "<img\
                    src='%s/++resource++bika.lims.images/attach_no.png'\
                    title='%s'>" % (self.context.absolute_url(),
                                    _('Attachment not permitted'))
            if after_icons:
                items[x]['after']['Title'] = after_icons

        return items
예제 #3
0
파일: client.py 프로젝트: lemoene/Bika-LIMS
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']
            items[x]['SampleID'] = obj.getSampleID()
            items[x]['replace']['SampleID'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['SampleID'])
            items[x]['replace']['Requests'] = ",".join(
                ["<a href='%s'>%s</a>" % (o.absolute_url(), o.Title())
                 for o in obj.getAnalysisRequests()])
            items[x]['ClientReference'] = obj.getClientReference()
            items[x]['ClientSampleID'] = obj.getClientSampleID()
            items[x]['SampleTypeTitle'] = obj.getSampleTypeTitle()
            items[x]['SamplePointTitle'] = obj.getSamplePointTitle()

            datesampled = obj.getDateSampled()
            items[x]['DateSampled'] = TimeOrDate(self.context, datesampled, long_format = 0)
            items[x]['future_DateSampled'] = datesampled.Date() > DateTime() and \
                TimeOrDate(self.context, datesampled) or ''

            items[x]['DateReceived'] = TimeOrDate(self.context, obj.getDateReceived())

            after_icons = ''
            if obj.getSampleType().getHazardous():
                after_icons += "<img title='Hazardous' src='++resource++bika.lims.images/hazardous.png'>"
            if after_icons:
                items[x]['after']['SampleID'] = after_icons

        return items
예제 #4
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']
            items[x]['ID'] = obj.id
            items[x]['Manufacturer'] = obj.getReferenceManufacturer() and \
                 obj.getReferenceManufacturer().Title() or ''
            items[x]['Definition'] = obj.getReferenceDefinition() and \
                 obj.getReferenceDefinition().Title() or ''
            items[x]['DateSampled'] = \
                 TimeOrDate(self.context, obj.getDateSampled())
            items[x]['DateReceived'] = \
                 TimeOrDate(self.context, obj.getDateReceived())
            items[x]['DateOpened'] = \
                 TimeOrDate(self.context, obj.getDateOpened())
            items[x]['ExpiryDate'] = \
                 TimeOrDate(self.context, obj.getExpiryDate())

            after_icons = ''
            if obj.getBlank():
                after_icons += "<img src='++resource++bika.lims.images/blank.png' title='Blank'>"
            if obj.getHazardous():
                after_icons += "<img src='++resource++bika.lims.images/hazardous.png' title='Hazardous'>"
            items[x]['replace']['ID'] = "<a href='%s/base_view'>%s</a>&nbsp;%s" % \
                 (items[x]['url'], items[x]['ID'], after_icons)

        return items
예제 #5
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        outitems = []
        toshow = []
        for val in self.context.getDocuments():
            toshow.append(val.UID())

        for x in range(len(items)):
            if not items[x].has_key('obj'):
                continue
            obj = items[x]['obj']
            if obj.UID() in toshow:
                items[x]['replace']['DocumentID'] = "<a href='%s'>%s</a>" % \
                                                    (items[x]['url'],
                                                     items[x]['DocumentID'])
                items[x]['SmallDesc'] = obj.getSmallDescription()
                items[x]['FileDownload'] = obj.getFile().filename
                filename = obj.getFile().filename if obj.getFile().filename \
                                                     != '' else 'Image'
                items[x]['replace']['FileDownload'] = "<a href='%s'>%s</a>" % \
                                                      (
                                                      obj.getFile().absolute_url_path(),
                                                      filename)
                items[x]['DatetimeCreated'] = self.ulocalized_time(
                    obj.getDatetimeCreated())
                outitems.append(items[x])
        return outitems
예제 #6
0
    def folderitems(self):
        self.filter_indexes = None

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if 'obj' not in items[x]:
                continue
            obj = items[x]['obj']

            bid = obj.getBatchID()
            items[x]['BatchID'] = bid
            items[x]['replace']['BatchID'] = "<a href='%s/%s'>%s</a>" % (items[x]['url'], 'analysisrequests', bid)

            title = obj.Title()
            items[x]['Title'] = title
            items[x]['replace']['Title'] = "<a href='%s/%s'>%s</a>" % (items[x]['url'], 'analysisrequests', title)

            if obj.getClient():
                items[x]['Client'] = obj.getClient().Title()
                items[x]['replace']['Client'] = "<a href='%s'>%s</a>" % ( obj.getClient().absolute_url(), obj.getClient().Title())
            else:
                items[x]['Client'] = ''

            date = obj.Schema().getField('BatchDate').get(obj)
            if callable(date):
                date = date()
            items[x]['BatchDate'] = date
            items[x]['replace']['BatchDate'] = self.ulocalized_time(date)

        return items
예제 #7
0
    def folderitems(self, full_objects=False):
        currency = currency_format(self.context, 'en')
        self.show_all = True
        self.contentsMethod = self.getInvoices
        items = BikaListingView.folderitems(self, full_objects)
        for item in items:
            obj = item['obj']
            number_link = "<a href='%s'>%s</a>" % (
                item['url'], obj.getId()
            )
            item['replace']['id'] = number_link
            
            if obj.getClient():
                item['client'] = obj.getClient().Title()
                item['replace']['client'] = "<a href='%s'>%s</a>" % (
                    obj.getClient().absolute_url(), obj.getClient().Title()
                )

                item['email'] = obj.getClient().getEmailAddress()
                item['replace']['email'] = "<a href='%s'>%s</a>" % (
                    'mailto:%s' % obj.getClient().getEmailAddress(), obj.getClient().getEmailAddress()
                )
                item['phone'] = obj.getClient().getPhone()
            else:
                item['client'] = ''
                item['email'] = ''
                item['phone'] = ''
            
            item['invoicedate'] = self.ulocalized_time(obj.getInvoiceDate())
            item['startdate'] = self.ulocalized_time(obj.getBatchStartDate())
            item['enddate'] = self.ulocalized_time(obj.getBatchEndDate())
            item['subtotal'] = currency(obj.getSubtotal())
            item['vatamount'] = currency(obj.getVATAmount())
            item['total'] = currency(obj.getTotal())
        return items
예제 #8
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        props = self.context.portal_properties.site_properties
        for x in range(len(items)):
            if 'obj' not in items[x]:
                continue
            obj = items[x]['obj']
            obj_url = obj.absolute_url()
            file = obj.getReportFile()
            icon = file.icon

            items[x]['Client'] = ''
            client = obj.getClient()
            if client:
                items[x]['replace']['Client'] = "<a href='%s'>%s</a>" % \
                                                (client.absolute_url(),
                                                 client.Title())
            items[x]['FileSize'] = '%sKb' % (file.get_size() / 1024)
            items[x]['Created'] = self.ulocalized_time(obj.created())
            items[x]['By'] = self.user_fullname(obj.Creator())

            items[x]['replace']['Title'] = \
                "<a href='%s/at_download/ReportFile'>%s</a>" % \
                (obj_url, items[x]['Title'])
        return items
예제 #9
0
    def folderitems(self):
        mtool = getToolByName(self.context, 'portal_membership')
        if mtool.checkPermission(ManageBika, self.context):
            del self.review_states[0]['transitions']
            self.show_select_column = True
            self.review_states.append(
                {'id':'active',
                 'title': _('Active'),
                 'contentFilter': {'inactive_state': 'active'},
                 'transitions': [{'id':'deactivate'}, ],
                 'columns': ['Title', 'Description']})
            self.review_states.append(
                {'id':'inactive',
                 'title': _('Dormant'),
                 'contentFilter': {'inactive_state': 'inactive'},
                 'transitions': [{'id':'activate'}, ],
                 'columns': ['Title', 'Description']})

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Title'])

            # chop the description down to 120-ish chars...
            descr = items[x]['Description'][:100].split(" ")
            descr = " ".join(descr[:-1])
            if len(items[x]['Description']) > 100:
                descr += "..."
            items[x]['Description'] = descr

        return items
예제 #10
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']

            itype = obj.getInstrumentType()
            items[x]['Type'] = itype.Title() if itype else ''
            ibrand = obj.getManufacturer()
            items[x]['Brand'] = ibrand.Title() if ibrand else ''
            items[x]['Model'] = obj.getModel()

            data = obj.getCertificateExpireDate()
            if data == '':
                items[x]['ExpiryDate'] = "No date avaliable"
            else:
                items[x]['ExpiryDate'] = data.asdatetime().strftime(self.date_format_short)
                
            if obj.isOutOfDate():
                items[x]['WeeksToExpire'] = "Out of date"
            else:
                date = int(str(obj.getWeeksToExpire()).split(',')[0].split(' ')[0])
                weeks,days = divmod(date,7)
                items[x]['WeeksToExpire'] = str(weeks)+" weeks"+" "+str(days)+" days"
                
            if obj.getMethod():
                items[x]['Method'] = obj.getMethod().Title() 
                items[x]['replace']['Method'] = "<a href='%s'>%s</a>" % \
                    (obj.getMethod().absolute_url(), items[x]['Method'])
            else:
                items[x]['Method'] = ''
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                (items[x]['url'], items[x]['Title'])

        return items
예제 #11
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'):
                continue
            obj = items[x]['obj']
            service = obj.getService()
            client = obj.aq_parent.aq_parent
            items[x]['getClientOrderNumber'] = obj.getClientOrderNumber()
            items[x]['getDateReceived'] = self.ulocalized_time(obj.getDateReceived())

            DueDate = obj.getDueDate()
            items[x]['getDueDate'] = self.ulocalized_time(DueDate)
            if DueDate < DateTime():
                items[x]['after']['DueDate'] = '<img width="16" height="16" src="%s/++resource++bika.lims.images/late.png" title="%s"/>' % \
                    (self.context.absolute_url(),
                     self.context.translate(_("Late Analysis")))
            items[x]['CategoryTitle'] = service.getCategory().Title()

            if getSecurityManager().checkPermission(EditResults, obj.aq_parent):
                url = obj.aq_parent.absolute_url() + "/manage_results"
            else:
                url = obj.aq_parent.absolute_url()
            items[x]['getRequestID'] = obj.aq_parent.getRequestID()
            items[x]['replace']['getRequestID'] = "<a href='%s'>%s</a>" % \
                 (url, items[x]['getRequestID'])

            items[x]['Client'] = client.Title()
            items[x]['replace']['Client'] = "<a href='%s'>%s</a>" % \
                 (client.absolute_url(), client.Title())
        return items
예제 #12
0
    def folderitems(self):
        self.contentsMethod = self.getClientList
        items = BikaListingView.folderitems(self)
        registry = getUtility(IRegistry)
        if 'bika.lims.client.default_landing_page' in registry:
            landing_page = registry['bika.lims.client.default_landing_page']
        else:
            landing_page = 'analysisrequests'

        for item in items:
            if "obj" not in item:
                continue
            obj = item['obj']

            item['replace']['title'] = "<a href='%s/%s'>%s</a>" % \
                (item['url'], landing_page.encode('ascii'), item['title'])

            item['EmailAddress'] = obj.getEmailAddress()
            item['replace']['EmailAddress'] = "<a href='%s'>%s</a>" % \
                ('mailto:%s' % obj.getEmailAddress(), obj.getEmailAddress())
            item['Phone'] = obj.getPhone()
            item['Fax'] = obj.getFax()
            item['ClientID'] = obj.getClientID()
            item['BulkDiscount'] = obj.getBulkDiscount() and 'Y' or 'N'
            item['MemberDiscountApplies'] = obj.getMemberDiscountApplies() and 'Y' or 'N'

        return items
예제 #13
0
    def folderitems(self):
        mtool = getToolByName(self.context, "portal_membership")
        if mtool.checkPermission(ManageBika, self.context):
            del self.review_states[0]["transitions"]
            self.show_select_column = True
            self.review_states.append(
                {
                    "id": "active",
                    "title": _("Active"),
                    "contentFilter": {"inactive_state": "active"},
                    "transitions": [{"id": "deactivate"}],
                    "columns": ["Title", "Description"],
                }
            )
            self.review_states.append(
                {
                    "id": "inactive",
                    "title": _("Dormant"),
                    "contentFilter": {"inactive_state": "inactive"},
                    "transitions": [{"id": "activate"}],
                    "columns": ["Title", "Description"],
                }
            )

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if "obj" in items[x]:
                items[x]["replace"]["Title"] = "<a href='%s'>%s</a>" % (items[x]["url"], items[x]["Title"])

        return items
예제 #14
0
파일: view.py 프로젝트: xispa/bika.lims
 def folderitems(self, full_objects=False):
     items = BikaListingView.folderitems(self, full_objects=False)
     # Hide Preservation/Sampling workflow actions if the edit columns
     # are not displayed.
     # Hide schedule_sampling if user has no rights
     toggle_cols = self.get_toggle_cols()
     new_states = []
     for i,state in enumerate(self.review_states):
         if state and self.review_state and state['id'] == self.review_state.get('id', ''):
             if 'getSampler' not in toggle_cols \
                or 'DateSampled' not in toggle_cols:
                 if 'hide_transitions' in state:
                     state['hide_transitions'].append('sample')
                 else:
                     state['hide_transitions'] = ['sample',]
             if 'getPreserver' not in toggle_cols \
                or 'getDatePreserved' not in toggle_cols:
                 if 'hide_transitions' in state:
                     state['hide_transitions'].append('preserve')
                 else:
                     state['hide_transitions'] = ['preserve',]
             # Check if the user has the rights to schedule samplings and
             # the check-box 'ScheduleSamplingEnabled' in bikasetup is set
             if self._schedule_sampling_permissions():
                 # Show the workflow transition button 'schedule_sampling'
                 pass
             else:
                 # Hiddes the button
                 state['hide_transitions'] = ['schedule_sampling', ]
         new_states.append(state)
     self.review_states = new_states
     return items
예제 #15
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']

            itype = obj.getInstrumentType()
            items[x]['Type'] = itype.Title() if itype else ''
            ibrand = obj.getManufacturer()
            items[x]['Brand'] = ibrand.Title() if ibrand else ''
            items[x]['Model'] = obj.getModel()

            data = obj.getCertificateExpireDate()
            if data is None:
                items[x]['ExpiryDate'] = _("No date set")
            else:
                items[x]['ExpiryDate'] = data.asdatetime().strftime(self.date_format_short)

            if obj.isOutOfDate():
                items[x]['WeeksToExpire'] = _("Out of date")
            else:
                weeks, days = obj.getWeeksToExpire()
                weeks_to_expire = _("{} weeks and {} day(s)".format(str(weeks), str(days)))
                items[x]['WeeksToExpire'] = weeks_to_expire

            if obj.getMethod():
                items[x]['Method'] = obj.getMethod().Title()
                items[x]['replace']['Method'] = "<a href='%s'>%s</a>" % \
                    (obj.getMethod().absolute_url(), items[x]['Method'])
            else:
                items[x]['Method'] = ''
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                (items[x]['url'], items[x]['Title'])

        return items
예제 #16
0
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     for item in items:
         if not item.has_key('obj'): continue
         obj = item['obj']
         title_link = "<a href='%s'>%s</a>" % (item['url'], item['title'])
         item['replace']['Title'] = title_link
     return items
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if 'obj' in items[x]:
                items[x]['replace']['Title'] = \
                    "<a href='%s'>%s</a>" % (items[x]['url'], items[x]['Title'])

        return items
예제 #18
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key("obj"):
                continue
            items[x]["replace"]["title"] = "<a href='%s'>%s</a>" % (items[x]["url"], items[x]["title"])

        return items
예제 #19
0
파일: client.py 프로젝트: cheslip/Bika-LIMS
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            items[x]['replace']['title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['title'])

        return items
예제 #20
0
 def folderitems(self, full_objects=True):
     items = BikaListingView.folderitems(self, full_objects)
     for x in range(len(items)):
         if not items[x].has_key("obj"):
             continue
         obj = items[x]["obj"]
         items[x]["title"] = obj.Title()
         items[x]["replace"]["title"] = "<a href='%s'>%s</a>" % (items[x]["url"], items[x]["title"])
     return items
예제 #21
0
 def folderitems(self, full_objects=True):
     items = BikaListingView.folderitems(self, full_objects)
     for x in range(len(items)):
         if not items[x].has_key('obj'): continue
         obj = items[x]['obj']
         items[x]['title'] = obj.Title()
         items[x]['replace']['title'] = "<a href='%s'>%s</a>" % \
              (items[x]['url'], items[x]['title'])
     return items
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key("obj"):
             continue
         obj = items[x]["obj"]
         items[x]["Description"] = obj.Description()
         items[x]["replace"]["Title"] = "<a href='%s'>%s</a>" % (items[x]["url"], items[x]["Title"])
     return items
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key('obj'): continue
         obj = items[x]['obj']
         items[x]['Description'] = obj.Description()
         items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
              (items[x]['url'], items[x]['Title'])
     return items
예제 #24
0
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     for item in items:
         obj = item.get("obj", None)
         if obj is None:
             continue
         item['Description'] = obj.Description()
         item['replace']['Title'] = "<a href='{url}'>{Title}</a>".format(**item)
     return items
예제 #25
0
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key('obj'): continue
         obj = items[x]['obj']
         items[x]['Title'] = obj.Title()
         items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                                        (items[x]['url'], items[x]['title'])
         items[x]['ProfileKey'] = obj.getProfileKey()
     return items
예제 #26
0
 def folderitems(self):
     self.contentsMethod = self.getARTemplates
     items = BikaListingView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key('obj'): continue
         obj = items[x]['obj']
         items[x]['Title'] = obj.Title()
         items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
              (items[x]['url'], items[x]['title'])
     return items
예제 #27
0
    def folderitems(self):

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if "obj" not in items[x]:
                continue
            items[x]["replace"]["Title"] = "<a href='%s'>%s</a>" % (items[x]["url"], items[x]["Title"])
            items[x]["getEffectiveDate"] = self.ulocalized_time(items[x]["obj"].getEffectiveDate())
            items[x]["getExpirationDate"] = self.ulocalized_time(items[x]["obj"].getExpirationDate())

        return items
예제 #28
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for item in items:
            obj = item.get("obj", None)
            if obj is None:
                continue
            item['Description'] = obj.Description()
            item['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (item['url'], item['Title'])

        return items
예제 #29
0
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key("obj"):
             continue
         obj = items[x]["obj"]
         items[x]["Title"] = obj.Title()
         items[x]["replace"]["Title"] = "<a href='%s'>%s</a>" % (items[x]["url"], items[x]["Title"])
         st = obj.getSampleType()
         items[x]["SampleType"] = obj.getSampleType().Title() if obj.getSampleType() else ""
     return items
예제 #30
0
파일: client.py 프로젝트: Jondeen/Bika-LIMS
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key('obj'): continue
         obj = items[x]['obj']
         items[x]['Title'] = obj.Title()
         items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
              (items[x]['url'], items[x]['Title'])
         items[x]['SampleType'] = obj.getSampleType().Title() \
             if obj.getSampleType() else ""
     return items
예제 #31
0
    def folderitems(self):
        mtool = getToolByName(self.context, 'portal_membership')
        if mtool.checkPermission(ManageBika, self.context):
            del self.review_states[0]['transitions']
            self.show_select_column = True
            self.review_states.append({
                'id': 'active',
                'title': _('Active'),
                'contentFilter': {
                    'inactive_state': 'active'
                },
                'transitions': [
                    {
                        'id': 'deactivate'
                    },
                ],
                'columns': ['Title', 'Description']
            })
            self.review_states.append({
                'id': 'inactive',
                'title': _('Dormant'),
                'contentFilter': {
                    'inactive_state': 'inactive'
                },
                'transitions': [
                    {
                        'id': 'activate'
                    },
                ],
                'columns': ['Title', 'Description']
            })

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if 'obj' in items[x]:
                items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                     (items[x]['url'], items[x]['Title'])

        return items
예제 #32
0
 def folderitems(self, full_objects=False):
     items = BikaListingView.folderitems(self, full_objects=False)
     # Hide Preservation/Sampling workflow actions if the edit columns
     # are not displayed.
     # Hide schedule_sampling if user has no rights
     toggle_cols = self.get_toggle_cols()
     new_states = []
     for i, state in enumerate(self.review_states):
         if state and self.review_state and state[
                 'id'] == self.review_state.get('id', ''):
             if 'getSampler' not in toggle_cols \
                or 'DateSampled' not in toggle_cols:
                 if 'hide_transitions' in state:
                     state['hide_transitions'].append('sample')
                 else:
                     state['hide_transitions'] = [
                         'sample',
                     ]
             if 'getPreserver' not in toggle_cols \
                or 'getDatePreserved' not in toggle_cols:
                 if 'hide_transitions' in state:
                     state['hide_transitions'].append('preserve')
                 else:
                     state['hide_transitions'] = [
                         'preserve',
                     ]
             # Check if the user has the rights to schedule samplings and
             # the check-box 'ScheduleSamplingEnabled' in bikasetup is set
             if self._schedule_sampling_permissions():
                 # Show the workflow transition button 'schedule_sampling'
                 pass
             else:
                 # Hiddes the button
                 state['hide_transitions'] = [
                     'schedule_sampling',
                 ]
         new_states.append(state)
     self.review_states = new_states
     return items
예제 #33
0
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     outitems = []
     toshow = []
     for val in self.context.getDocuments():
         toshow.append(val.UID())
     for x in range(len(items)):
         if not items[x].has_key('obj'): continue
         obj = items[x]['obj']
         if obj.UID() in toshow:
             items[x]['replace']['DocumentID'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['DocumentID'])
             items[x]['FileDownload'] = obj.getFile().filename
             filename = obj.getFile(
             ).filename if obj.getFile().filename != '' else 'File'
             items[x]['replace']['FileDownload'] = "<a href='%s'>%s</a>" % \
                 (obj.getFile().absolute_url_path(), filename)
             items[x]['DocumentVersion'] = obj.getDocumentVersion()
             items[x]['DocumentLocation'] = obj.getDocumentLocation()
             items[x]['DocumentType'] = obj.getDocumentType()
             outitems.append(items[x])
     return outitems
예제 #34
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']

            itype = obj.getInstrumentType()
            items[x]['Type'] = itype.Title() if itype else ''
            ibrand = obj.getManufacturer()
            items[x]['Brand'] = ibrand.Title() if ibrand else ''
            items[x]['Model'] = obj.getModel()

            data = obj.getCertificateExpireDate()
            if data == '':
                items[x]['ExpiryDate'] = "No date avaliable"
            else:
                items[x]['ExpiryDate'] = data.asdatetime().strftime(
                    self.date_format_short)

            if obj.isOutOfDate():
                items[x]['WeeksToExpire'] = "Out of date"
            else:
                date = int(
                    str(obj.getWeeksToExpire()).split(',')[0].split(' ')[0])
                weeks, days = divmod(date, 7)
                items[x]['WeeksToExpire'] = str(weeks) + " weeks" + " " + str(
                    days) + " days"

            if obj.getMethod():
                items[x]['Method'] = obj.getMethod().Title()
                items[x]['replace']['Method'] = "<a href='%s'>%s</a>" % \
                    (obj.getMethod().absolute_url(), items[x]['Method'])
            else:
                items[x]['Method'] = ''
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                (items[x]['url'], items[x]['Title'])

        return items
예제 #35
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        outitems = []
        toshow = []
        for man in self.context.getMaintenanceTasks():
            toshow.append(man.UID())

        for item in items:
            if "obj" not in item:
                continue
            obj = item['obj']
            if obj.UID() in toshow:
                item['getType'] = safe_unicode(_(obj.getType()[0])).encode('utf-8')
                item['getDownFrom'] = obj.getDownFrom() and self.ulocalized_time(obj.getDownFrom(), long_format=1) or ''
                item['getDownTo'] = obj.getDownTo() and self.ulocalized_time(obj.getDownTo(), long_format=1) or ''
                item['getMaintainer'] = safe_unicode(_(obj.getMaintainer())).encode('utf-8')
                item['replace']['Title'] = "<a href='%s'>%s</a>" % \
                    (item['url'], safe_unicode(item['Title']).encode('utf-8'))

                status = obj.getCurrentState()
                statustext = obj.getCurrentStateI18n()
                statusimg = ""
                if status == mstatus.CLOSED:
                    statusimg = "instrumentmaintenance_closed.png"
                elif status == mstatus.CANCELLED:
                    statusimg = "instrumentmaintenance_cancelled.png"
                elif status == mstatus.INQUEUE:
                    statusimg = "instrumentmaintenance_inqueue.png"
                elif status == mstatus.OVERDUE:
                    statusimg = "instrumentmaintenance_overdue.png"
                elif status == mstatus.PENDING:
                    statusimg = "instrumentmaintenance_pending.png"

                item['replace']['getCurrentState'] = \
                    "<img title='%s' src='%s/++resource++bika.lims.images/%s'/>" % \
                    (statustext, self.portal_url, statusimg)
                outitems.append(item)
        return outitems
예제 #36
0
    def folderitems(self):
        self.contentsMethod = self.getClientList
        items = BikaListingView.folderitems(self)
        registry = getUtility(IRegistry)
        if 'bika.lims.client.default_landing_page' in registry:
            landing_page = registry['bika.lims.client.default_landing_page']
        else:
            landing_page = 'analysisrequests'
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']

            items[x]['replace']['title'] = "<a href='%s/%s'>%s</a>"%\
                 (items[x]['url'], landing_page.encode('ascii'), items[x]['title'])

            items[x]['EmailAddress'] = obj.getEmailAddress()
            items[x]['replace']['EmailAddress'] = "<a href='%s'>%s</a>"%\
                     ('mailto:%s' % obj.getEmailAddress(),
                      obj.getEmailAddress())
            items[x]['Phone'] = obj.getPhone()
            items[x]['Fax'] = obj.getFax()

        return items
예제 #37
0
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     for x in range(len(items)):
         if not items[x].has_key('obj'): continue
         obj = items[x]['obj']
         items[x]['orderId'] = obj.getOrderId()
         items[x]['labId'] = obj.getLabId()
         items[x]['batchId'] = obj.getBatchId()
         items[x]['product'] = obj.getProductTitle()
         items[x]['supplier'] = obj.getSupplierTitle()
         items[x]['productCategory'] = obj.getProductCategoryTitle()
         items[x]['location'] = obj.getLocation()
         items[x]['storageLevelId'] = obj.getStorageLevelID()
         items[x]['isStored'] = 'yes' if obj.getIsStored() else 'no'
         items[x]['dateReceived'] = self.ulocalized_time(
             obj.getDateReceived())
         items[x]['dateOpened'] = self.ulocalized_time(obj.getDateOpened())
         items[x]['expiryDate'] = self.ulocalized_time(obj.getExpiryDate())
         items[x]['disposalDate'] = self.ulocalized_time(
             obj.getDisposalDate())
         items[x]['replace']['stockitemID'] = "<a href='%s'>%s</a>" % \
             (items[x]['url'], obj.getStockItemId())
     return items
예제 #38
0
    def folderitems(self, full_objects=False):

        items = BikaListingView.folderitems(self)

        for x in range(len(items)):

            if not items[x].has_key('obj'):
                continue
            obj = items[x]['obj']

            items[x]['SampleDonorID'] = obj.getId()

            items[x]['replace']['SampleDonorID'] = "<a href='%s'>%s</a>" % \
                                                   (items[x]['url'],
                                                    items[x]['SampleDonorID'])
            project = obj.getSelectedProject()
            if project and hasattr(project, 'title'):
                items[x]['SelectedProject'] = project.title

            items[x]['Age'] = ('%f' % float(obj.getAge())).rstrip('0').rstrip(
                '.') + " " + obj.getAgeUnit()

        return items
예제 #39
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        props = self.context.portal_properties.site_properties
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']
            obj_url = obj.absolute_url()
            file = obj.getReportFile()
            icon = file.getBestIcon()

            items[x]['Client'] = ''
            client = obj.getClient()
            if client:
                items[x]['replace']['Client'] = "<a href='%s'>%s</a>" % \
                    (client.absolute_url(), client.Title())
            items[x]['FileSize'] = '%sKb' % (file.get_size() / 1024)
            items[x]['Created'] = self.ulocalized_time(obj.created())
            items[x]['By'] = self.user_fullname(obj.Creator())

            items[x]['replace']['Title'] = \
                 "<a href='%s/at_download/ReportFile'>%s</a>" % \
                 (obj_url, items[x]['Title'])
        return items
예제 #40
0
    def folderitems(self):
        mtool = getToolByName(self.context, 'portal_membership')
        member = mtool.getAuthenticatedMember()
        roles = member.getRoles()
        self.allow_edit = 'LabManager' in roles or 'Manager' in roles

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'):
                continue
            obj = items[x]['obj']

            suppliers = [a.UID() for a in self.field_value]
            items[x]['selected'] = items[x]['uid'] in suppliers

            items[x]['replace']['Name'] = "<a href='%s'>%s</a>" % \
                                          (items[x]['url'], items[x]['Name'])

            # items[x]['class']['Name'] = 'service_title'
            items[x]['Website'] = obj.getWebsite()
            items[x]['class']['Price'] = 'nowrap'

        return items
예제 #41
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']
            obj_url = obj.absolute_url()
            file = obj.getAttachmentFile()
            icon = file.getBestIcon()

            items[x]['AttachmentFile'] = file.filename()
            items[x]['AttachmentType'] = obj.getAttachmentType().Title()
            items[x]['AttachmentType'] = obj.getAttachmentType().Title()
            items[x]['ContentType'] = self.lookupMime(file.getContentType())
            items[x]['FileSize'] = '%sKb' % (file.get_size() / 1024)
            items[x]['DateLoaded'] = obj.getDateLoaded()

            items[x]['replace']['getTextTitle'] = "<a href='%s'>%s</a>" % \
                 (obj_url, items[x]['getTextTitle'])

            items[x]['replace']['AttachmentFile'] = \
                 "<a href='%s/at_download/AttachmentFile'>%s</a>" % \
                 (obj_url, items[x]['AttachmentFile'])
        return items
예제 #42
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']

            itype = obj.getInstrumentType()
            items[x]['Type'] = itype.Title() if itype else ''
            ibrand = obj.getManufacturer()
            items[x]['Brand'] = ibrand.Title() if ibrand else ''
            items[x]['Model'] = obj.getModel()

            data = obj.getCertificateExpireDate()
            if data is None:
                items[x]['ExpiryDate'] = _("No date set")
            else:
                items[x]['ExpiryDate'] = data.asdatetime().strftime(
                    self.date_format_short)

            if obj.isOutOfDate():
                items[x]['WeeksToExpire'] = _("Out of date")
            else:
                weeks, days = obj.getWeeksToExpire()
                weeks_to_expire = _("{} weeks and {} day(s)".format(
                    str(weeks), str(days)))
                items[x]['WeeksToExpire'] = weeks_to_expire

            if obj.getMethod():
                items[x]['Method'] = obj.getMethod().Title()
                items[x]['replace']['Method'] = "<a href='%s'>%s</a>" % \
                    (obj.getMethod().absolute_url(), items[x]['Method'])
            else:
                items[x]['Method'] = ''
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                (items[x]['url'], items[x]['Title'])

        return items
예제 #43
0
    def folderitems(self):

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Title'])
            
            if obj.getInstruments():
                if len(obj.getInstruments()) > 1:
                    InstrumentLine = str()
                    urlStr = str()
                    for token in obj.getInstruments():
                        InstrumentLine += token.Title() + ", "
                        urlStr += "<a href='%s'>%s</a>" % (token.absolute_url(),token.Title())
                    items[x]['replace']['Instrument'] = urlStr

                else:
                    items[x]['Instrument'] = obj.getInstruments()[0].Title()
                    items[x]['replace']['Instrument'] = "<a href='%s'>%s</a>" % \
                        (obj.getInstruments()[0].absolute_url(), items[x]['Instrument'])
            else:
                items[x]['Instrument'] = ''

            if obj.getCalculation():
                items[x]['Calculation'] = obj.getCalculation().Title()
                items[x]['replace']['Calculation'] = "<a href='%s'>%s</a>" % \
                    (obj.getCalculation().absolute_url(), items[x]['Calculation'])
            else:
                items[x]['Calculation'] = ''
            
            img_url = '<img src="'+self.portal_url+'/++resource++bika.lims.images/ok.png"/>'
            items[x]['ManualEntry'] = obj.isManualEntryOfResults()
            items[x]['replace']['ManualEntry'] = img_url if obj.isManualEntryOfResults() else ' '

        return items
예제 #44
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if 'obj' not in items[x]:
                continue
            obj = items[x]['obj']
            items[x]['getPatientID'] = obj.getPatientID()
            items[x]['getBirthDate'] = self.ulocalized_time(obj.getBirthDate())
            items[x]['replace']['getPatientID'] = "<a href='%s/analysisrequests'>%s</a>" % \
                (items[x]['url'], items[x]['getPatientID'])
            items[x]['replace']['getClientPatientID'] = "<a href='%s'>%s</a>" % \
                (items[x]['url'], items[x]['getClientPatientID'])
            items[x]['replace']['Title'] = "<a href='%s/analysisrequests'>%s</a>" % \
                (items[x]['url'], items[x]['Title'])

            pr = obj.getPrimaryReferrer()
            if pr:
                items[x]['getPrimaryReferrer'] = pr.Title()
                items[x]['replace']['getPrimaryReferrer'] = "<a href='%s/analysisrequests'>%s</a>" % \
                    (pr.absolute_url(), pr.Title())
            else:
                items[x]['getPrimaryReferrer'] = ''

        return items
예제 #45
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'):
                continue

            obj = items[x]['obj']
            items[x]['getFullname'] = obj.getFullname()
            items[x]['getEmailAddress'] = obj.getEmailAddress()
            items[x]['getBusinessPhone'] = obj.getBusinessPhone()
            items[x]['getMobilePhone'] = obj.getMobilePhone()
            username = obj.getUsername()
            items[x]['Username'] = username and username or ''

            items[x]['replace']['getFullname'] = \
                "<a href='%s'>%s</a>" % (
                    items[x]['url'], items[x]['getFullname'])

            if items[x]['getEmailAddress']:
                addr = items[x]['getEmailAddress']
                items[x]['replace']['getEmailAddress'] = \
                    "<a href='mailto:%s'>%s</a>" % (addr, addr)

        return items
예제 #46
0
    def folderitems(self):
        self.filter_indexes = None

        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if 'obj' not in items[x]:
                continue
            obj = items[x]['obj']

            bid = obj.getBatchID()
            items[x]['BatchID'] = bid
            items[x]['replace']['BatchID'] = "<a href='%s/%s'>%s</a>" % (items[x]['url'], 'analysisrequests', bid)

            title = obj.Title()
            items[x]['Title'] = title
            items[x]['replace']['Title'] = "<a href='%s/%s'>%s</a>" % (items[x]['url'], 'analysisrequests', title)

            date = obj.Schema().getField('BatchDate').get(obj)
            if callable(date):
                date = date()
            items[x]['BatchDate'] = date
            items[x]['replace']['BatchDate'] = self.ulocalized_time(date)

        return items
예제 #47
0
    def folderitems(self, full_objects=False):
        items = BikaListingView.folderitems(self)
        # print len(items)
        # print '----------'
        for x in range(len(items)):
            if not items[x].has_key('obj'):
                continue
            obj = items[x]['obj']
            items[x]['SampleShipmentID'] = obj.getId()

            items[x]['replace']['SampleShipmentID'] = "<a href='%s'>%s</a>" % \
                                                   (items[x]['url'], obj.getId())

            client = obj.getClient()
            if client:
                items[x]['Client'] = client.Title()

            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                                           (items[x]['url'], items[x]['Title'])

            #items[x]['Age'] = ('%f' % float(obj.getAge())).rstrip('0').rstrip('.') + " " + obj.getAgeUnit()
            items[x]['SamplesList'] = self.getStringified(obj.getSamplesList())

        return items
예제 #48
0
    def folderitems(self):
        wf = getToolByName(self, 'portal_workflow')
        rc = getToolByName(self, REFERENCE_CATALOG)
        pm = getToolByName(self.context, "portal_membership")

        member = pm.getAuthenticatedMember()

        items = BikaListingView.folderitems(self)
        new_items = []
        analyst_choices = []
        for a in self.analysts:
            analyst_choices.append({
                'ResultValue': a,
                'ResultText': self.analysts.getValue(a)
            })
        can_reassign = False

        for x in range(len(items)):
            if not items[x].has_key('obj'):
                new_items.append(items[x])
                continue

            obj = items[x]['obj']

            analyst = obj.getAnalyst().strip()
            creator = obj.Creator().strip()

            items[x]['Analyst'] = analyst

            items[x]['Title'] = obj.Title()
            wst = obj.getWorksheetTemplate()
            items[x]['Template'] = wst and wst.Title() or ''
            if wst:
                items[x]['replace']['Template'] = "<a href='%s'>%s</a>" % \
                    (wst.absolute_url(), wst.Title())

            # this cannot be setup in contentFilter, because AuthenticatedMember
            # is not available in __init__
            if self.request.get("%s_review_state" % self.form_id,
                                '') == 'mine':
                if member.getId() not in (analyst, creator):
                    continue

            nr_analyses = len(obj.getAnalyses())
            if nr_analyses == '0':
                # manager and labmanager see *all* worksheets
                # otherwise we must be Analyst or Creator to see empties.
                roles = member.getRoles()
                if not 'Manager' in roles \
                   and not 'LabManager' in roles \
                   and not member.getId() in (analyst, creator):
                    continue
                # give empties pretty classes.
                items[x]['table_row_class'] = 'state-empty-worksheet'

            items[x]['CreationDate'] = TimeOrDate(self.context,
                                                  obj.creation_date)

            layout = obj.getLayout()

            if len(layout) > 0:
                items[x]['replace']['Title'] = "<a href='%s/manage_results'>%s</a>" % \
                    (items[x]['url'], items[x]['Title'])
            else:
                items[x]['replace']['Title'] = "<a href='%s/add_analyses'>%s</a>" % \
                    (items[x]['url'], items[x]['Title'])

            # set Services
            ws_services = {}
            for slot in [s for s in layout if s['type'] == 'a']:
                analysis = rc.lookupObject(slot['analysis_uid'])
                service = analysis.getService()
                title = service.Title()
                if title not in ws_services:
                    ws_services[title] = "<a href='%s'>%s,</a>" % \
                        (service.absolute_url(), title)
            keys = list(ws_services.keys())
            keys.sort()
            services = []
            for key in keys:
                services.append(ws_services[key])
            if services:
                services[-1] = services[-1].replace(",", "")
            items[x]['Services'] = ""
            items[x]['replace']['Services'] = " ".join(services)

            # set Sample Types
            pos_parent = {}
            for slot in layout:
                if slot['position'] in pos_parent:
                    continue
                pos_parent[slot['position']] = rc.lookupObject(
                    slot['container_uid'])

            sampletypes = {}
            blanks = {}
            controls = {}
            for container in pos_parent.values():
                if container.portal_type == 'AnalysisRequest':
                    sampletypes["<a href='%s'>%s,</a>" % \
                               (container.getSample().getSampleType().absolute_url(),
                                container.getSample().getSampleType().Title())] = 1
                if container.portal_type == 'ReferenceSample' and container.getBlank(
                ):
                    blanks["<a href='%s'>%s,</a>" % \
                           (container.absolute_url(),
                            container.Title())] = 1
                if container.portal_type == 'ReferenceSample' and not container.getBlank(
                ):
                    controls["<a href='%s'>%s,</a>" % \
                           (container.absolute_url(),
                            container.Title())] = 1
            sampletypes = list(sampletypes.keys())
            sampletypes.sort()
            blanks = list(blanks.keys())
            blanks.sort()
            controls = list(controls.keys())
            controls.sort()

            # remove trailing commas
            if sampletypes:
                sampletypes[-1] = sampletypes[-1].replace(",", "")
            if controls:
                controls[-1] = controls[-1].replace(",", "")
            else:
                if blanks:
                    blanks[-1] = blanks[-1].replace(",", "")

            items[x]['SampleTypes'] = ""
            items[x]['replace']['SampleTypes'] = " ".join(sampletypes)
            items[x]['QC'] = ""
            items[x]['replace']['QC'] = " ".join(blanks + controls)

            if items[x]['review_state'] == 'open':
                items[x]['allow_edit'] = [
                    'Analyst',
                ]
                items[x]['required'] = [
                    'Analyst',
                ]
                can_reassign = True
                items[x]['choices'] = {'Analyst': analyst_choices}

            new_items.append(items[x])

        if can_reassign:
            for x in range(len(self.review_states)):
                if self.review_states[x]['id'] in ['all', 'mine', 'open']:
                    self.review_states[x]['custom_actions'] = [
                        {
                            'id': 'reassign',
                            'title': 'Reassign'
                        },
                    ]

        return new_items
    def folderitems(self):
        self.categories = []

        bsc = getToolByName(self.context, 'bika_setup_catalog')
        wf = getToolByName(self.context, 'portal_workflow')
        mtool = getToolByName(self.context, 'portal_membership')
        member = mtool.getAuthenticatedMember()
        roles = member.getRoles()
        self.allow_edit = 'LabManager' in roles or 'Manager' in roles

        items = BikaListingView.folderitems(self)

        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']

            cat = obj.getCategoryTitle()
            # Category (upper C) is for display column value
            items[x]['Category'] = cat
            if self.do_cats:
                # category is for bika_listing to groups entries
                items[x]['category'] = cat
                if cat not in self.categories:
                    self.categories.append(cat)

            analyses = [a.UID() for a in self.fieldvalue]

            items[x]['selected'] = items[x]['uid'] in analyses

            items[x]['class']['Title'] = 'service_title'

            calculation = obj.getCalculation()
            items[x]['Calculation'] = calculation and calculation.Title()

            locale = locales.getLocale('en')
            currency = self.context.bika_setup.getCurrency()
            symbol = locale.numbers.currencies[currency].symbol
            items[x]['Price'] = "%s %s" % (symbol, obj.getPrice())
            items[x]['class']['Price'] = 'nowrap'

            after_icons = ''
            if obj.getAccredited():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/accredited.png'\
                title='%s'>"%(self.context.absolute_url(),
                              _("Accredited"))
            if obj.getReportDryMatter():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/dry.png'\
                title='%s'>"%(self.context.absolute_url(),
                              _("Can be reported as dry matter"))
            if obj.getAttachmentOption() == 'r':
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/attach_reqd.png'\
                title='%s'>"%(self.context.absolute_url(),
                              _("Attachment required"))
            if obj.getAttachmentOption() == 'n':
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/attach_no.png'\
                title='%s'>"%(self.context.absolute_url(),
                              _('Attachment not permitted'))
            if after_icons:
                items[x]['after']['Title'] = after_icons

            if self.profile:
                # Display analyses for this Analysis Service in results?
                ser = self.profile.getAnalysisServiceSettings(obj.UID())
                items[x]['allow_edit'] = ['Hidden', ]
                items[x]['Hidden'] = ser.get('hidden', obj.getHidden())

        self.categories.sort()
        return items
    def folderitems(self):
        self.categories = []

        bsc = getToolByName(self.context, 'bika_setup_catalog')
        wf = getToolByName(self.context, 'portal_workflow')
        mtool = getToolByName(self.context, 'portal_membership')
        member = mtool.getAuthenticatedMember()
        roles = member.getRoles()
        self.allow_edit = 'LabManager' in roles or 'Manager' in roles

        items = BikaListingView.folderitems(self)

        part_ids = ['part-1']
        for s in self.fieldvalue:
            if s['partition'] not in part_ids:
                part_ids.append(s['partition'])
        partitions = [{'ResultValue': p, 'ResultText': p} for p in part_ids]

        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']

            cat = obj.getCategoryTitle()
            items[x]['category'] = cat
            if cat not in self.categories:
                self.categories.append(cat)

            analyses = dict([(a['service_uid'], a) for a in self.fieldvalue])

            items[x]['selected'] = items[x]['uid'] in analyses.keys()

            items[x]['class']['Title'] = 'service_title'

            calculation = obj.getCalculation()
            items[x]['Calculation'] = calculation and calculation.Title()

            locale = locales.getLocale('en')
            currency = self.context.bika_setup.getCurrency()
            symbol = locale.numbers.currencies[currency].symbol
            items[x]['Price'] = "%s %s" % (symbol, obj.getPrice())
            items[x]['class']['Price'] = 'nowrap'
            items[x]['allow_edit'] = ['Partition']
            if not items[x]['selected']:
                items[x]['edit_condition'] = {'Partition': False}

            items[x]['required'].append('Partition')
            items[x]['choices']['Partition'] = partitions

            if obj.UID() in self.selected:
                items[x]['Partition'] = analyses[obj.UID()]['partition']
            else:
                items[x]['Partition'] = ''

            after_icons = ''
            if obj.getAccredited():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/accredited.png'\
                title='%s'>" % (self.context.absolute_url(), _("Accredited"))
            if obj.getReportDryMatter():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/dry.png'\
                title='%s'>" % (self.context.absolute_url(),
                                _("Can be reported as dry matter"))
            if obj.getAttachmentOption() == 'r':
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/attach_reqd.png'\
                title='%s'>" % (self.context.absolute_url(),
                                _("Attachment required"))
            if obj.getAttachmentOption() == 'n':
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/attach_no.png'\
                title='%s'>" % (self.context.absolute_url(),
                                _('Attachment not permitted'))
            if after_icons:
                items[x]['after']['Title'] = after_icons
        self.categories.sort()
        return items
예제 #51
0
 def folderitems(self, full_objects=False, classic=False):
     return BikaListingView.folderitems(self, full_objects=False,
                                        classic=False)
예제 #52
0
    def folderitems(self):
        self.categories = []

        analyses = self.context.getAnalyses(full_objects=True)
        self.analyses = dict([(a.getServiceUID(), a) for a in analyses])
        self.selected = self.analyses.keys()
        self.show_categories = \
            self.context.bika_setup.getCategoriseAnalysisServices()
        self.expand_all_categories = False

        wf = getToolByName(self.context, 'portal_workflow')
        mtool = getToolByName(self.context, 'portal_membership')

        self.allow_edit = mtool.checkPermission('Modify portal content',
                                                self.context)

        items = BikaListingView.folderitems(self)
        analyses = self.context.getAnalyses(full_objects=True)

        parts = self.context.getSample().objectValues('SamplePartition')
        partitions = [{'ResultValue': o.Title(),
                       'ResultText': o.getId()}
                      for o in parts
                      if wf.getInfoFor(o, 'cancellation_state', '') == 'active']
        for x in range(len(items)):
            if not 'obj' in items[x]:
                continue
            obj = items[x]['obj']

            cat = obj.getCategoryTitle()
            items[x]['category'] = cat
            if cat not in self.categories:
                self.categories.append(cat)

            items[x]['selected'] = items[x]['uid'] in self.selected

            items[x]['class']['Title'] = 'service_title'

            # js checks in row_data if an analysis may be removed.
            row_data = {}
            # keyword = obj.getKeyword()
            # if keyword in review_states.keys() \
            #    and review_states[keyword] not in ['sample_due',
            #                                       'to_be_sampled',
            #                                       'to_be_preserved',
            #                                       'sample_received',
            #                                       ]:
            #     row_data['disabled'] = True
            items[x]['row_data'] = json.dumps(row_data)

            calculation = obj.getCalculation()
            items[x]['Calculation'] = calculation and calculation.Title()

            locale = locales.getLocale('en')
            currency = self.context.bika_setup.getCurrency()
            symbol = locale.numbers.currencies[currency].symbol
            items[x]['before']['Price'] = symbol
            items[x]['Price'] = obj.getPrice()
            items[x]['class']['Price'] = 'nowrap'
            items[x]['Priority'] = ''

            if items[x]['selected']:
                items[x]['allow_edit'] = ['Partition', 'min', 'max', 'error']
                if not logged_in_client(self.context):
                    items[x]['allow_edit'].append('Price')

            items[x]['required'].append('Partition')
            items[x]['choices']['Partition'] = partitions

            if obj.UID() in self.analyses:
                analysis = self.analyses[obj.UID()]
                part = analysis.getSamplePartition()
                part = part and part or obj
                items[x]['Partition'] = part.Title()
                spec = analysis.specification \
                    if hasattr(analysis, 'specification') \
                    else {"min": "", "max": "", "error": ""}
                items[x]["min"] = spec["min"]
                items[x]["max"] = spec["max"]
                items[x]["error"] = spec["error"]
                # Add priority premium
                items[x]['Price'] = analysis.getPrice()
                priority = analysis.getPriority()
                items[x]['Priority'] = priority and priority.Title() or ''
            else:
                items[x]['Partition'] = ''
                items[x]["min"] = ''
                items[x]["max"] = ''
                items[x]["error"] = ''
                items[x]["Priority"] = ''

            after_icons = ''
            if obj.getAccredited():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/accredited.png'\
                title='%s'>" % (
                    self.portal_url,
                    t(_("Accredited"))
                )
            if obj.getReportDryMatter():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/dry.png'\
                title='%s'>" % (
                    self.portal_url,
                    t(_("Can be reported as dry matter"))
                )
            if obj.getAttachmentOption() == 'r':
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/attach_reqd.png'\
                title='%s'>" % (
                    self.portal_url,
                    t(_("Attachment required"))
                )
            if obj.getAttachmentOption() == 'n':
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/attach_no.png'\
                title='%s'>" % (
                    self.portal_url,
                    t(_('Attachment not permitted'))
                )
            if after_icons:
                items[x]['after']['Title'] = after_icons

        self.categories.sort()
        return items
예제 #53
0
 def folderitems(self, full_objects=False, classic=False):
     # Force the folderitems to work with brains instead of objects
     return BikaListingView.folderitems(self, classic=classic)
예제 #54
0
    def folderitems(self, full_objects=False):
        # Show only ISharable samples for EMS.  Skip others.
        pm = getToolByName(self.context, 'portal_membership')
        roles = pm.getAuthenticatedMember().getRoles()

        #print roles
        if 'EMS' in roles:
            self.contentFilter[
                'object_provides'] = ISharableSample.__identifier__

        items = BikaListingView.folderitems(self)
        bsc = getToolByName(self.context, 'bika_setup_catalog')
        brains = bsc(portal_type='SampleType', inactive_state='active')
        biospecimen_types = [{
            'ResultValue': brain.UID,
            'ResultText': brain.title
        } for brain in brains]
        ret = []
        for x, item in enumerate(items):
            if not items[x].has_key('obj'):
                continue
            obj = items[x]['obj']

            if not ISample.providedBy(obj):
                continue
            items[x]['Type'] = obj.getSampleType() and obj.getSampleType(
            ).Title() or ''
            items[x]['Volume'] = obj.getField('Volume').get(obj)
            items[x]['Unit'] = VOLUME_UNITS[0]['ResultText']
            items[x]['SubjectID'] = obj.getField('SubjectID').get(obj)
            kit = obj.getField('Kit').get(obj)
            project = obj.getField('Project').get(obj)
            items[x]['Kit'] = kit
            items[x]['Project'] = project
            if project:
                items[x]['replace']['Project'] = \
                    '<a href="%s">%s</a>' % (project.absolute_url(),
                                             project.Title())
            if kit:
                items[x]['replace']['Kit'] = \
                    '<a href="%s">%s</a>' % (kit.absolute_url(), kit.Title())

                # TODO: IF STATUS IS RECEIVED EXECUTE THIS
                # items[x]['replace']['Type'] = \
                #     '<a href="%s">%s</a>' % (obj.getSampleType().absolute_url(),
                #                              obj.getSampleType().Title())
            items[x]['Barcode'] = obj.getField('Barcode').get(obj)
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                                           (items[x]['url'], items[x]['Title'])
            # TODO: SPECIFY OBJ STATES WHERE USER CAN EDIT BARCODE
            if self.allow_edit and isActive(self.context) and \
                    getSecurityManager().checkPermission(ModifyPortalContent, obj):
                if items[x]['review_state'] == "sample_registered":
                    items[x]['allow_edit'] = ['Type', 'Barcode']
                    items[x]['choices']['Type'] = biospecimen_types
                elif items[x]['review_state'] == "sample_due":
                    items[x]['allow_edit'] = ['SubjectID', 'Volume', 'Unit']

                    if not items[x]['Unit']:
                        items[x]['choices']['Unit'] = VOLUME_UNITS
            ret.append(item)
        return ret
예제 #55
0
    def folderitems(self, full_objects=False, classic=True):
        self.categories = []

        analyses = self.context.getAnalyses(full_objects=True)
        self.analyses = dict([(a.getServiceUID(), a) for a in analyses])
        self.selected = self.analyses.keys()
        self.show_categories = \
            self.context.bika_setup.getCategoriseAnalysisServices()
        self.expand_all_categories = False

        wf = getToolByName(self.context, 'portal_workflow')
        items = BikaListingView.folderitems(self)

        parts = self.context.getSample().objectValues('SamplePartition')
        partitions = [{
            'ResultValue': o.Title(),
            'ResultText': o.getId()
        } for o in parts
                      if wf.getInfoFor(o, 'cancellation_state', '') == 'active'
                      ]

        for item in items:
            if 'obj' not in item:
                continue
            obj = item['obj']

            cat = obj.getCategoryTitle()
            item['category'] = cat
            if cat not in self.categories:
                self.categories.append(cat)

            item['selected'] = item['uid'] in self.selected
            item['class']['Title'] = 'service_title'
            row_data = dict()
            calculation = obj.getCalculation()
            item['Calculation'] = calculation and calculation.Title()

            locale = locales.getLocale('en')
            currency = self.context.bika_setup.getCurrency()
            symbol = locale.numbers.currencies[currency].symbol
            item['before']['Price'] = symbol
            item['Price'] = obj.getPrice()
            item['class']['Price'] = 'nowrap'
            item['allow_edit'] = list()
            if item['selected']:
                item['allow_edit'] = [
                    'Partition', 'min', 'max', 'warn_min', 'warn_max'
                ]
                if not logged_in_client(self.context):
                    item['allow_edit'].append('Price')

            item['required'].append('Partition')
            item['choices']['Partition'] = partitions

            if obj.UID() in self.analyses:
                analysis = self.analyses[obj.UID()]

                row_data['disabled'] = wasTransitionPerformed(
                    analysis, 'submit')

                part = analysis.getSamplePartition()
                part = part and part or obj
                item['Partition'] = part.Title()
                spec = self.get_spec_from_ar(self.context,
                                             analysis.getKeyword())
                item["min"] = spec.get("min", '')
                item["max"] = spec.get("max", '')
                item["warn_min"] = spec.get("warn_min", "")
                item["warn_max"] = spec.get("warn_max", "")
                item['Price'] = analysis.getPrice()
            else:
                item['Partition'] = ''
                item["min"] = ''
                item["max"] = ''
                item["warn_min"] = ""
                item["warn_max"] = ""

            # js checks in row_data if an analysis may not be editable.
            item['row_data'] = json.dumps(row_data)
            after_icons = ''
            if obj.getAccredited():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/accredited.png'\
                title='%s'>" % (self.portal_url, t(_("Accredited")))
            if obj.getAttachmentOption() == 'r':
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/attach_reqd.png'\
                title='%s'>" % (self.portal_url, t(_("Attachment required")))
            if obj.getAttachmentOption() == 'n':
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/attach_no.png'\
                title='%s'>" % (self.portal_url,
                                t(_('Attachment not permitted')))
            if after_icons:
                item['after']['Title'] = after_icons

            # Display analyses for this Analysis Service in results?
            ser = self.context.getAnalysisServiceSettings(obj.UID())
            item['allow_edit'].append('Hidden')
            item['Hidden'] = ser.get('hidden', obj.getHidden())
            item['Unit'] = obj.getUnit()

        self.categories.sort()
        return items
예제 #56
0
    def folderitems(self, full_objects=False):
        workflow = getToolByName(self.context, "portal_workflow")
        items = BikaListingView.folderitems(self)
        mtool = getToolByName(self.context, 'portal_membership')
        member = mtool.getAuthenticatedMember()
        translate = self.context.translate
        roles = member.getRoles()
        hideclientlink = 'RegulatoryInspector' in roles \
            and 'Manager' not in roles \
            and 'LabManager' not in roles \
            and 'LabClerk' not in roles

        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']

            items[x]['replace']['getSampleID'] = "<a href='%s'>%s</a>" % \
                (items[x]['url'], obj.getSampleID())
            items[x]['replace']['Requests'] = ",".join([
                "<a href='%s'>%s</a>" % (o.absolute_url(), o.Title())
                for o in obj.getAnalysisRequests()
            ])
            items[x]['Client'] = obj.aq_parent.Title()
            if hideclientlink == False:
                items[x]['replace']['Client'] = "<a href='%s'>%s</a>" % \
                    (obj.aq_parent.absolute_url(), obj.aq_parent.Title())
            items[x]['Creator'] = self.user_fullname(obj.Creator())

            items[x]['DateReceived'] = self.ulocalized_time(
                obj.getDateReceived())

            deviation = obj.getSamplingDeviation()
            items[x]['SamplingDeviation'] = deviation and deviation.Title(
            ) or ''

            items[x]['getStorageLocation'] = obj.getStorageLocation(
            ) and obj.getStorageLocation().Title() or ''
            items[x]['AdHoc'] = obj.getAdHoc() and True or ''

            items[x]['Created'] = self.ulocalized_time(obj.created())

            samplingdate = obj.getSamplingDate()
            items[x]['getSamplingDate'] = self.ulocalized_time(samplingdate,
                                                               long_format=1)

            after_icons = ''
            if obj.getSampleType().getHazardous():
                after_icons += "<img title='%s' " \
                    "src='%s/++resource++bika.lims.images/hazardous.png'>" % \
                    (t(_("Hazardous")),
                     self.portal_url)
            if obj.getSamplingDate() > DateTime():
                after_icons += "<img title='%s' " \
                    "src='%s/++resource++bika.lims.images/calendar.png' >" % \
                    (t(_("Future dated sample")),
                     self.portal_url)
            if after_icons:
                items[x]['after']['getSampleID'] = after_icons

            SamplingWorkflowEnabled =\
                self.context.bika_setup.getSamplingWorkflowEnabled()

            if not samplingdate > DateTime() \
                    and SamplingWorkflowEnabled:
                datesampled = self.ulocalized_time(obj.getDateSampled())
                if not datesampled:
                    datesampled = self.ulocalized_time(DateTime())
                    items[x]['class']['getDateSampled'] = 'provisional'
                sampler = obj.getSampler().strip()
                if sampler:
                    items[x]['replace']['getSampler'] = self.user_fullname(
                        sampler)
                if 'Sampler' in member.getRoles() and not sampler:
                    sampler = member.id
                    items[x]['class']['getSampler'] = 'provisional'
            else:
                datesampled = ''
                sampler = ''
            items[x]['getDateSampled'] = datesampled
            items[x]['getSampler'] = sampler

            # sampling workflow - inline edits for Sampler and Date Sampled
            checkPermission = self.context.portal_membership.checkPermission
            state = workflow.getInfoFor(obj, 'review_state')
            if state == 'to_be_sampled' \
                    and checkPermission(SampleSample, obj) \
                    and not samplingdate > DateTime():
                items[x]['required'] = ['getSampler', 'getDateSampled']
                items[x]['allow_edit'] = ['getSampler', 'getDateSampled']
                samplers = getUsers(obj, ['Sampler', 'LabManager', 'Manager'])
                getAuthenticatedMember = self.context.portal_membership.getAuthenticatedMember
                username = getAuthenticatedMember().getUserName()
                users = [({
                    'ResultValue': u,
                    'ResultText': samplers.getValue(u)
                }) for u in samplers]
                items[x]['choices'] = {'getSampler': users}
                Sampler = sampler and sampler or \
                    (username in samplers.keys() and username) or ''
                items[x]['getSampler'] = Sampler

            # These don't exist on samples
            # the columns exist just to set "preserve" transition from lists.
            # XXX This should be a list of preservers...
            items[x]['getPreserver'] = ''
            items[x]['getDatePreserved'] = ''

            # inline edits for Preserver and Date Preserved
            checkPermission = self.context.portal_membership.checkPermission
            if checkPermission(PreserveSample, obj):
                items[x]['required'] = ['getPreserver', 'getDatePreserved']
                items[x]['allow_edit'] = ['getPreserver', 'getDatePreserved']
                preservers = getUsers(obj,
                                      ['Preserver', 'LabManager', 'Manager'])
                getAuthenticatedMember = self.context.portal_membership.getAuthenticatedMember
                username = getAuthenticatedMember().getUserName()
                users = [({
                    'ResultValue': u,
                    'ResultText': preservers.getValue(u)
                }) for u in preservers]
                items[x]['choices'] = {'getPreserver': users}
                preserver = username in preservers.keys() and username or ''
                items[x]['getPreserver'] = preserver
                items[x]['getDatePreserved'] = self.ulocalized_time(DateTime())
                items[x]['class']['getPreserver'] = 'provisional'
                items[x]['class']['getDatePreserved'] = 'provisional'

        # Hide Preservation/Sampling workflow actions if the edit columns
        # are not displayed.
        toggle_cols = self.get_toggle_cols()
        new_states = []
        for i, state in enumerate(self.review_states):
            if state['id'] == self.review_state:
                if 'getSampler' not in toggle_cols \
                   or 'getDateSampled' not in toggle_cols:
                    if 'hide_transitions' in state:
                        state['hide_transitions'].append('sample')
                    else:
                        state['hide_transitions'] = [
                            'sample',
                        ]
                if 'getPreserver' not in toggle_cols \
                   or 'getDatePreserved' not in toggle_cols:
                    if 'hide_transitions' in state:
                        state['hide_transitions'].append('preserve')
                    else:
                        state['hide_transitions'] = [
                            'preserve',
                        ]
            new_states.append(state)
        self.review_states = new_states

        return items
예제 #57
0
    def folderitems(self):

        items = BikaListingView.folderitems(self)

        for x in range(len(items)):
            if 'obj' not in items[x]:
                continue
            obj = items[x]['obj']
            items[x]['Keyword'] = obj.getKeyword()
            cat = obj.getCategoryTitle()
            items[x]['Category'] = cat  # Category is for display column value
            if self.do_cats:
                items[x][
                    'category'] = cat  # category is for bika_listing to groups entries
                if cat not in self.categories:
                    self.categories.append(cat)

            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                                           (items[x]['url'], items[x]['Title'])

            instrument = obj.getInstrument()
            items[x]['Instrument'] = instrument and instrument.Title() or ''
            items[x]['replace'][
                'Instrument'] = instrument and "<a href='%s'>%s</a>" % \
                                               (
                                                   instrument.absolute_url() + "/edit",
                                                   instrument.Title()) or ''

            items[x][
                'Department'] = obj.getDepartment() and obj.getDepartment().Title() or ''

            calculation = obj.getCalculation()
            items[x]['Calculation'] = calculation and calculation.Title()
            items[x]['replace'][
                'Calculation'] = calculation and "<a href='%s'>%s</a>" % \
                                                 (
                                                     calculation.absolute_url() + "/edit",
                                                     calculation.Title()) or ''

            items[x]['Unit'] = obj.getUnit() and obj.getUnit() or ''
            items[x]['Price'] = "%s.%02d" % (obj.Price)

            method = obj.getMethod()
            items[x]['Method'] = method and method.Title() or ''
            items[x]['replace']['Method'] = method and "<a href='%s'>%s</a>" % \
                                                       (method.absolute_url(),
                                                        method.Title()) or ''

            maxtime = obj.MaxTimeAllowed
            maxtime_string = ""
            for field in ('days', 'hours', 'minutes'):
                if field in maxtime:
                    try:
                        val = int(maxtime[field])
                        if val > 0:
                            maxtime_string += "%s%s " % (val, _(field[0]))
                    except:
                        pass
            items[x]['MaxTimeAllowed'] = maxtime_string

            if obj.DuplicateVariation is not None:
                items[x]['DuplicateVariation'] = "%s.%02d" % (
                    obj.DuplicateVariation)
            else:
                items[x]['DuplicateVariation'] = ""

            after_icons = ''
            if obj.getAccredited():
                after_icons += "<img src='++resource++bika.lims.images/accredited.png' title='%s'>" % (
                    _("Accredited"))
            if obj.getReportDryMatter():
                after_icons += "<img src='++resource++bika.lims.images/dry.png' title='%s'>" % (
                    _("Can be reported as dry matter"))
            if obj.getAttachmentOption() == 'r':
                after_icons += "<img src='++resource++bika.lims.images/attach_reqd.png' title='%s'>" % (
                    _("Attachment required"))
            if obj.getAttachmentOption() == 'n':
                after_icons += "<img src='++resource++bika.lims.images/attach_no.png' title='%s'>" % (
                    _('Attachment not permitted'))
            if after_icons:
                items[x]['after']['Title'] = after_icons

        self.categories.sort()
        return items
예제 #58
0
 def folderitems(self):
     return BikaListingView.folderitems(self, classic=False)
예제 #59
0
    def folderitems(self):

        items = BikaListingView.folderitems(self)

        bsc = getToolByName(self.context, "bika_setup_catalog")
        analysis_categories = bsc(portal_type="AnalysisCategory",
                                  sort_on="sortable_title")
        analysis_categories_order = dict([
            (b.Title, "{:04}".format(a))
            for a, b in enumerate(analysis_categories)
        ])

        for x in range(len(items)):
            if 'obj' not in items[x]:
                continue
            obj = items[x]['obj']

            # Although these should be automatically inserted when bika_listing
            # searches the schema for fields that match columns, it is still
            # not harmful to be explicit:
            items[x]['Keyword'] = obj.getKeyword()
            items[x]['CommercialID'] = obj.getCommercialID()
            items[x]['ProtocolID'] = obj.getProtocolID()
            items[x]['SortKey'] = obj.getSortKey()

            cat = obj.getCategoryTitle()

            cat_order = analysis_categories_order.get(cat)
            # Category (upper C) is for display column value
            items[x]['Category'] = cat
            if self.do_cats:
                # category is for bika_listing to groups entries
                items[x]['category'] = cat
                if (cat, cat_order) not in self.categories:
                    self.categories.append((cat, cat_order))

            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % (
                items[x]['url'], items[x]['Title'])

            instrument = obj.getInstrument()
            items[x]['Instrument'] = instrument and instrument.Title() or ''
            if instrument:
                items[x]['replace']['Instrument'] = "<a href='%s'>%s</a>" % (
                    instrument.absolute_url() + "/edit", instrument.Title())

            items[x]['Department'] = obj.getDepartment().Title() \
                if obj.getDepartment() else ''

            calculation = obj.getCalculation()
            items[x]['Calculation'] = calculation and calculation.Title()
            if calculation:
                items[x]['replace']['Calculation'] = "<a href='%s'>%s</a>" % (
                    calculation.absolute_url() + "/edit", calculation.Title())

            items[x]['Unit'] = obj.getUnit() and obj.getUnit() or ''
            items[x]['Price'] = "%s.%02d" % obj.Price

            method = obj.getMethod()
            items[x]['Method'] = method and method.Title() or ''
            if method:
                items[x]['replace']['Method'] = "<a href='%s'>%s</a>" % (
                    method.absolute_url(), method.Title())

            maxtime = obj.MaxTimeAllowed
            maxtime_string = ""
            for field in ('days', 'hours', 'minutes'):
                if field in maxtime:
                    try:
                        val = int(maxtime[field])
                        if val > 0:
                            maxtime_string += "%s%s " % (val, _(field[0]))
                    except:
                        pass
            items[x]['MaxTimeAllowed'] = maxtime_string

            if obj.DuplicateVariation is not None:
                items[x]['DuplicateVariation'] = "%s.%02d" % (
                    obj.DuplicateVariation)
            else:
                items[x]['DuplicateVariation'] = ""

            after_icons = ''
            ipath = "++resource++bika.lims.images"
            if obj.getAccredited():
                after_icons += "<img src='%s/accredited.png' title='%s'>" % (
                    ipath, _("Accredited"))
            if obj.getReportDryMatter():
                after_icons += "<img src='%s/dry.png' title='%s'>" % (
                    ipath, _("Can be reported as dry matter"))
            if obj.getAttachmentOption() == 'r':
                after_icons += "<img src='%s/attach_reqd.png' title='%s'>" % (
                    ipath, _("Attachment required"))
            if obj.getAttachmentOption() == 'n':
                after_icons += "<img src='%s/attach_no.png' title='%s'>" % (
                    ipath, _('Attachment not permitted'))
            if after_icons:
                items[x]['after']['Title'] = after_icons

        if self.do_cats:
            self.categories = map(lambda x: x[0],
                                  sorted(self.categories, key=lambda x: x[1]))
        else:
            self.categories.sort()
        return items
예제 #60
0
 def folderitems(self, full_objects=False, classic=False):
     # We need to get the portal catalog here in roder to save process
     # while iterating over folderitems
     self.portal_catalog = api.get_tool("portal_catalog")
     return BikaListingView.folderitems(self, full_objects, classic)