예제 #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
파일: __init__.py 프로젝트: pureboy8/OLiMS
    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.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
예제 #3
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
예제 #4
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
예제 #5
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'])

        return items
예제 #6
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'])

        return items
예제 #7
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
예제 #8
0
파일: supplier.py 프로젝트: nafwa03/olims
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            items[x]['replace']['getFullname'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['obj'].getFullname())

        return items
예제 #9
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
예제 #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']
         items[x]['Description'] = obj.Description()
         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']
         items[x]['Description'] = obj.Description()
         items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
              (items[x]['url'], items[x]['Title'])
     return items
예제 #12
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        valid = [c.UID() for c in self.context.getValidCertifications()]
        latest = self.context.getLatestValidCertification()
        latest = latest.UID() if latest else ''
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']
            # items[x]['getAgency'] = obj.getAgency()
            items[x]['getDate'] = self.ulocalized_time(obj.getDate(),
                                                       long_format=0)
            items[x]['getValidFrom'] = self.ulocalized_time(obj.getValidFrom(),
                                                            long_format=0)
            items[x]['getValidTo'] = self.ulocalized_time(obj.getValidTo(),
                                                          long_format=0)
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Title'])
            if obj.getInternal() == True:
                items[x]['replace']['getAgency'] = ""
                items[x]['state_class'] = '%s %s' % (items[x]['state_class'],
                                                     'internalcertificate')

            items[x]['getDocument'] = ""
            items[x]['replace']['getDocument'] = ""
            try:
                doc = obj.getDocument()
                if doc and doc.get_size() > 0:
                    anchor = "<a href='%s/at_download/Document'>%s</a>" % \
                            (obj.absolute_url(), doc.filename)
                    items[x]['getDocument'] = doc.filename
                    items[x]['replace']['getDocument'] = anchor
            except:
                # POSKeyError: 'No blob file'
                # Show the record, but not the link
                title = _('Not available')
                items[x]['getDocument'] = _('Not available')
                items[x]['replace']['getDocument'] = _('Not available')

            uid = obj.UID()
            if uid in valid:
                # Valid calibration.
                items[x]['state_class'] = '%s %s' % (items[x]['state_class'],
                                                     'active')
            elif uid == latest:
                # Latest valid certificate
                img = "<img title='%s' src='%s/++resource++bika.lims.images/exclamation.png'/>&nbsp;" \
                % (t(_('Out of date')), self.portal_url)
                items[x]['replace']['getValidTo'] = '%s %s' % (
                    items[x]['getValidTo'], img)
                items[x]['state_class'] = '%s %s' % (items[x]['state_class'],
                                                     'inactive outofdate')
            else:
                # Old and further calibrations
                items[x]['state_class'] = '%s %s' % (items[x]['state_class'],
                                                     'inactive')

        return items
예제 #13
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
예제 #14
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
예제 #15
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'])

        return items
예제 #16
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]['Description'] = obj.Description()
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Title'])

            if obj.getRetentionPeriod():
                items[x]['RetentionPeriod'] = "hours: " + str(
                    obj.getRetentionPeriod()['hours']) + " minutes: " + str(
                        obj.getRetentionPeriod()['minutes']) + " days: " + str(
                            obj.getRetentionPeriod()['days'])

            else:
                items[x]['RetentionPeriod'] = ''

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

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

            else:
                items[x]['ContainerType'] = ''

            if obj.getSamplePoints():
                if len(obj.getSamplePoints()) > 1:
                    SPLine = str()
                    urlStr = str()
                    for token in obj.getSamplePoints():
                        SPLine += token.Title() + ", "
                        urlStr += "<a href='%s'>%s</a>" % (
                            token.absolute_url(), token.Title())
                    items[x]['replace']['getSamplePoints'] = urlStr

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

            else:
                items[x]['getSamplePoints'] = ''

        return items
예제 #17
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]['SampleType'] = obj.getSampleType().Title() \
             if obj.getSampleType() else ""
     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
         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
예제 #19
0
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     items.sort(key=itemgetter('OrderDate'), reverse=True)
     for x in range(len(items)):
         if not items[x].has_key('obj'): continue
         obj = items[x]['obj']
         items[x]['OrderNumber'] = obj.getOrderNumber()
         items[x]['OrderDate'] = self.ulocalized_time(obj.getOrderDate())
         items[x]['DateDispatched'] = self.ulocalized_time(obj.getDateDispatched())
         items[x]['replace']['OrderNumber'] = "<a href='%s'>%s</a>" % \
              (items[x]['url'], items[x]['OrderNumber'])
     return items
예제 #20
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
예제 #21
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]['Name'] = obj.getName()
            items[x]['Email'] = obj.getEmailAddress()
            items[x]['Phone'] = obj.getPhone()
            items[x]['Fax'] = obj.getFax()
            items[x]['replace']['Name'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Name'])

        return items
예제 #22
0
파일: arimports.py 프로젝트: pureboy8/OLiMS
    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'])
            items[x]['replace']['getClientTitle'] = \
                "<a href='%s'>%s</a>" % (
                        obj.aq_parent.absolute_url(), obj.aq_parent.Title())

        return items
예제 #23
0
    def folderitems(self):
        self.contentsMethod = self.getInvoiceBatches
        items = BikaListingView.folderitems(self)
        for x, item in enumerate(items):
            if 'obj' not in item:
                continue
            obj = item['obj']
            title_link = "<a href='%s'>%s</a>" % (item['url'], item['title'])
            items[x]['replace']['title'] = title_link
            items[x]['start'] = self.ulocalized_time(obj.getBatchStartDate())
            items[x]['end'] = self.ulocalized_time(obj.getBatchEndDate())

        return items
예제 #24
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'])
         items[x]['Description'] = obj.Description()
         if obj.aq_parent.portal_type == 'Client':
             items[x]['Owner'] = obj.aq_parent.Title()
         else:
             items[x]['Owner'] = self.context.bika_setup.laboratory.Title()
     return items
예제 #25
0
    def folderitems(self):
        self.contentsMethod = self.getInvoiceBatches
        items = BikaListingView.folderitems(self)
        for x, item in enumerate(items):
            if 'obj' not in item:
                continue
            obj = item['obj']
            title_link = "<a href='%s'>%s</a>" % (item['url'], item['title'])
            items[x]['replace']['title'] = title_link
            items[x]['start'] = self.ulocalized_time(obj.getBatchStartDate())
            items[x]['end'] = self.ulocalized_time(obj.getBatchEndDate())

        return items
예제 #26
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]['Name'] = obj.getName()
            items[x]['Email'] = obj.getEmailAddress()
            items[x]['Phone'] = obj.getPhone()
            items[x]['Fax'] = obj.getFax()
            items[x]['replace']['Name'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Name'])

        return items
예제 #27
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]['Volume'] = obj.getVolume()
            items[x]['Unit'] = obj.getUnit()
            items[x]['Price'] = obj.getPrice()
            items[x]['VATAmount'] = obj.getVATAmount()
            items[x]['TotalPrice'] = obj.getTotalPrice()
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Title'])

        return items
예제 #28
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]['Volume'] = obj.getVolume()
            items[x]['Unit'] = obj.getUnit()
            items[x]['Price'] = obj.getPrice()
            items[x]['VATAmount'] = obj.getVATAmount()
            items[x]['TotalPrice'] = obj.getTotalPrice()
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Title'])

        return items
예제 #29
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
         item['client'] = obj.getClient().Title()
         item['invoicedate'] = self.ulocalized_time(obj.getInvoiceDate())
         item['subtotal'] = currency(obj.getSubtotal())
         item['vatamount'] = currency(obj.getVATAmount())
         item['total'] = currency(obj.getTotal())
     return items
예제 #30
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]['Fullname'] = obj.getFullname()
            items[x]['Department'] = obj.getDepartmentTitle()
            items[x]['BusinessPhone'] = obj.getBusinessPhone()
            items[x]['Fax'] = obj.getBusinessFax()
            items[x]['MobilePhone'] = obj.getMobilePhone()
            items[x]['EmailAddress'] = obj.getEmailAddress()
            items[x]['replace']['Fullname'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Fullname'])

        return items
예제 #31
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]['Fullname'] = obj.getFullname()
            items[x]['Department'] = obj.getDepartmentTitle()
            items[x]['BusinessPhone'] = obj.getBusinessPhone()
            items[x]['Fax'] = obj.getBusinessFax()
            items[x]['MobilePhone'] = obj.getMobilePhone()
            items[x]['EmailAddress'] = obj.getEmailAddress()
            items[x]['replace']['Fullname'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Fullname'])

        return items
예제 #32
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]['Description'] = obj.Description()
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Title'])

            if obj.getRetentionPeriod():
                items[x]['RetentionPeriod'] = "hours: " + str(obj.getRetentionPeriod()['hours']) + " minutes: " + str(obj.getRetentionPeriod()['minutes']) + " days: " + str(obj.getRetentionPeriod()['days'])
                
            else:
                items[x]['RetentionPeriod'] = ''

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

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

            else:
                items[x]['ContainerType'] = ''

            if obj.getSamplePoints():
                if len(obj.getSamplePoints()) > 1:
                    SPLine = str()
                    urlStr = str()
                    for token in obj.getSamplePoints():
                        SPLine += token.Title() + ", "
                        urlStr += "<a href='%s'>%s</a>" % (token.absolute_url(),token.Title())
                    items[x]['replace']['getSamplePoints'] = urlStr
                    
                else:
                    items[x]['getSamplePoints'] = obj.getSamplePoints()[0].Title()
                    items[x]['replace']['getSamplePoints'] = "<a href='%s'>%s</a>" % \
                        (obj.getSamplePoints()[0].absolute_url(), items[x]['getSamplePoints'])

            else:
                items[x]['getSamplePoints'] = ''

        return items
예제 #33
0
 def folderitems(self):
     items = BikaListingView.folderitems(self)
     outitems = []
     toshow = []
     for val in self.context.getValidations():
         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]['getDownFrom'] = obj.getDownFrom()
             items[x]['getDownTo'] = obj.getDownTo()
             items[x]['getValidator'] = obj.getValidator()
             items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                  (items[x]['url'], items[x]['Title'])
             outitems.append(items[x])
     return outitems
예제 #34
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
         item['client'] = obj.getClient().Title()
         item['invoicedate'] = self.ulocalized_time(obj.getInvoiceDate())
         item['subtotal'] = currency(obj.getSubtotal())
         item['vatamount'] = currency(obj.getVATAmount())
         item['total'] = currency(obj.getTotal())
     return items
예제 #35
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]['Description'] = obj.Description()
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                 (items[x]['url'], items[x]['Title'])

            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']['Title'] = "<a href='%s'>%s</a>&nbsp;%s" % \
                 (items[x]['url'], items[x]['Title'], after_icons)

        return items
예제 #36
0
파일: supplier.py 프로젝트: pureboy8/OLiMS
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        outitems = []
        workflow = getToolByName(self.context, 'portal_workflow')
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']
            if workflow.getInfoFor(obj, 'review_state') == 'current':
                # Check expiry date
                from dependencies.dependency import DT2dt
                from dependencies.dependency import datetime
                expirydate = DT2dt(obj.getExpiryDate()).replace(tzinfo=None)
                if (datetime.today() > expirydate):
                    workflow.doActionFor(obj, 'expire')
                    items[x]['review_state'] = 'expired'
                    items[x]['obj'] = obj
                    if 'review_state' in self.contentFilter \
                        and self.contentFilter['review_state'] == 'current':
                        continue
            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'] = self.ulocalized_time(
                obj.getDateSampled())
            items[x]['DateReceived'] = self.ulocalized_time(
                obj.getDateReceived())
            items[x]['DateOpened'] = self.ulocalized_time(obj.getDateOpened())
            items[x]['ExpiryDate'] = self.ulocalized_time(obj.getExpiryDate())

            after_icons = ''
            if obj.getBlank():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/blank.png' \
                title='%s'>" % (self.portal_url, t(_('Blank')))
            if obj.getHazardous():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/hazardous.png' \
                title='%s'>" % (self.portal_url, t(_('Hazardous')))
            items[x]['replace']['ID'] = "<a href='%s/base_view'>%s</a>&nbsp;%s" % \
                 (items[x]['url'], items[x]['ID'], after_icons)
            outitems.append(items[x])
        return outitems
예제 #37
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        outitems = []
        toshow = []
        for sch in self.context.getSchedule():
            toshow.append(sch.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]['created'] = self.ulocalized_time(obj.created())
                items[x]['creator'] = obj.Creator()
                items[x]['getType'] = safe_unicode(_(
                    obj.getType()[0])).encode('utf-8')
                items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                     (items[x]['url'], items[x]['Title'])
                outitems.append(items[x])
        return outitems
예제 #38
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]['Description'] = obj.Description()
            items[x]['Manager'] = obj.getManagerName()
            items[x]['ManagerPhone'] = obj.getManagerPhone()
            items[x]['ManagerEmail'] = obj.getManagerEmail()

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

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

        return items
예제 #39
0
파일: supplier.py 프로젝트: nafwa03/olims
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        outitems = []
        workflow = getToolByName(self.context, 'portal_workflow')
        for x in range(len(items)):
            if not items[x].has_key('obj'): continue
            obj = items[x]['obj']
            if workflow.getInfoFor(obj, 'review_state') == 'current':
                # Check expiry date
                from dependencies.dependency import DT2dt
                from dependencies.dependency import datetime
                expirydate = DT2dt(obj.getExpiryDate()).replace(tzinfo=None)
                if (datetime.today() > expirydate):
                    workflow.doActionFor(obj, 'expire')
                    items[x]['review_state'] = 'expired'
                    items[x]['obj'] = obj
                    if 'review_state' in self.contentFilter \
                        and self.contentFilter['review_state'] == 'current':
                        continue
            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'] = self.ulocalized_time(obj.getDateSampled())
            items[x]['DateReceived'] = self.ulocalized_time(obj.getDateReceived())
            items[x]['DateOpened'] = self.ulocalized_time(obj.getDateOpened())
            items[x]['ExpiryDate'] = self.ulocalized_time(obj.getExpiryDate())

            after_icons = ''
            if obj.getBlank():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/blank.png' \
                title='%s'>" % (self.portal_url, t(_('Blank')))
            if obj.getHazardous():
                after_icons += "<img\
                src='%s/++resource++bika.lims.images/hazardous.png' \
                title='%s'>" % (self.portal_url, t(_('Hazardous')))
            items[x]['replace']['ID'] = "<a href='%s/base_view'>%s</a>&nbsp;%s" % \
                 (items[x]['url'], items[x]['ID'], after_icons)
            outitems.append(items[x])
        return outitems
예제 #40
0
    def folderitems(self):
        items = BikaListingView.folderitems(self)
        outitems = []
        toshow = []
        for man in self.context.getMaintenanceTasks():
            toshow.append(man.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]['getType'] = safe_unicode(_(
                    obj.getType()[0])).encode('utf-8')
                items[x]['getDownFrom'] = obj.getDownFrom(
                ) and self.ulocalized_time(obj.getDownFrom(),
                                           long_format=1) or ''
                items[x]['getDownTo'] = obj.getDownTo(
                ) and self.ulocalized_time(obj.getDownTo(),
                                           long_format=1) or ''
                items[x]['getMaintainer'] = safe_unicode(_(
                    obj.getMaintainer())).encode('utf-8')
                items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                     (items[x]['url'], safe_unicode(items[x]['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"

                items[x]['replace']['getCurrentState'] = \
                    "<img title='%s' src='%s/++resource++bika.lims.images/%s'/>" % \
                    (statustext, self.portal_url, statusimg)
                outitems.append(items[x])
        return outitems
예제 #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']
            items[x]['Description'] = obj.Description()
            items[x]['Manager'] = obj.getManagerName()
            items[x]['ManagerPhone'] = obj.getManagerPhone()
            items[x]['ManagerEmail'] = obj.getManagerEmail()

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

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


        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']
            items[x]['Description'] = obj.Description()
            items[x]['ContainerType'] = obj.getContainerType() and obj.getContainerType().Title() or ''
            items[x]['Capacity'] = obj.getCapacity() and "%s" % \
                (obj.getCapacity()) or ''
            pre = obj.getPrePreserved()
            pres = obj.getPreservation()
            items[x]['Pre-preserved'] = ''
            items[x]['after']['Pre-preserved'] = pre \
                and "<a href='%s'>%s</a>" % (pres.absolute_url(), pres.Title()) \
                or ''

            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]['Description'] = obj.Description()
            items[x]['ContainerType'] = obj.getContainerType(
            ) and obj.getContainerType().Title() or ''
            items[x]['Capacity'] = obj.getCapacity() and "%s" % \
                (obj.getCapacity()) or ''
            pre = obj.getPrePreserved()
            pres = obj.getPreservation()
            items[x]['Pre-preserved'] = ''
            items[x]['after']['Pre-preserved'] = pre \
                and "<a href='%s'>%s</a>" % (pres.absolute_url(), pres.Title()) \
                or ''

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

        return items
예제 #44
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']:
                items[x]['replace']['getEmailAddress'] = "<a href='mailto:%s'>%s</a>" % \
                     (items[x]['getEmailAddress'], items[x]['getEmailAddress'])

        return items
예제 #45
0
파일: multifile.py 프로젝트: nafwa03/olims
 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
예제 #46
0
파일: methods.py 프로젝트: pureboy8/OLiMS
    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
예제 #47
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
예제 #48
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
예제 #49
0
파일: methods.py 프로젝트: nafwa03/olims
    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
예제 #50
0
    def folderitems(self):
        self.filter_indexes = None
        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
예제 #51
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
예제 #52
0
    def folderitems(self):
        wf = getToolByName(self, 'portal_workflow')
        rc = getToolByName(self, REFERENCE_CATALOG)
        pm = getToolByName(self.context, "portal_membership")

        self.member = pm.getAuthenticatedMember()
        roles = self.member.getRoles()
        self.restrict_results = 'Manager' not in roles \
                and 'LabManager' not in roles \
                and 'LabClerk' not in roles \
                and 'RegulatoryInspector' not in roles \
                and self.context.bika_setup.getRestrictWorksheetUsersAccess()

        if self.restrict_results == True:
            # Remove 'Mine' button and hide 'Analyst' column
            del self.review_states[1] # Mine
            self.columns['Analyst']['toggle'] = False

        can_manage = pm.checkPermission(ManageWorksheets, self.context)

        self.selected_state = self.request.get("%s_review_state"%self.form_id,
                                                'default')

        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
        self.allow_edit = self.isEditionAllowed()

        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

            priority = obj.getPriority()
            items[x]['Priority'] = ''
            
            instrument = obj.getInstrument()
            items[x]['Instrument'] = instrument and instrument.Title() or ''

            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())

            items[x]['getPriority'] = ''
            items[x]['CreationDate'] = self.ulocalized_time(obj.creation_date)

            nr_analyses = len(obj.getAnalyses())
            if nr_analyses == '0':
                # give empties pretty classes.
                items[x]['table_row_class'] = 'state-empty-worksheet'

            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:
                # compensate for bad data caused by a stupid bug.
                if type(slot['position']) in (list, tuple):
                    slot['position'] = slot['position'][0]
                if slot['position'] == 'new':
                    continue
                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)
            items[x]['QCTotals'] = ''

            # Get all Worksheet QC Analyses
            totalQCAnalyses = [a for a in obj.getAnalyses()
                                   if a.portal_type == 'ReferenceAnalysis'
                                   or a.portal_type == 'DuplicateAnalysis']
            totalQCSamples = []
            # Get all Worksheet QC samples
            for analysis in totalQCAnalyses:
                if analysis.getSample().UID() not in totalQCSamples:
                    totalQCSamples.append(analysis.getSample().UID())
            # Total QC Samples (Total Routine Analyses)
            items[x]['QCTotals'] = str(len(totalQCSamples)) + '(' + str(len(totalQCAnalyses)) + ')'

            totalRoutineAnalyses = [a for a in obj.getAnalyses()
                                   if a not in totalQCAnalyses]
            totalRoutineSamples = []
            for analysis in totalRoutineAnalyses:
                if analysis.getSample().UID() not in totalRoutineSamples:
                    totalRoutineSamples.append(analysis.getSample().UID())

            # Total Routine Samples (Total Routine Analyses)
            items[x]['RoutineTotals'] = str(len(totalRoutineSamples)) + '(' + str(len(totalRoutineAnalyses)) + ')'

            if items[x]['review_state'] == 'open' \
                and self.allow_edit \
                and self.restrict_results == False \
                and can_manage == True:
                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 ['default', 'mine', 'open']:
                    self.review_states[x]['custom_actions'] = [{'id': 'reassign', 'title': _('Reassign')}, ]

        self.show_select_column = can_reassign
        self.show_workflow_action_buttons = can_reassign

        return new_items
예제 #53
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 = self.get_spec_from_ar(self.context,
                                             analysis.getService().getKeyword())
                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


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

        self.categories.sort()
        return items