Example #1
0
 def __init__(self, context, request):
     SE.__init__(self, context, request)
     if IAliquot.providedBy(context):
         self.icon = self.portal_url + \
                     "/++resource++bika.sanbi.images/aliquot_big.png"
     elif IBiospecimen.providedBy(context):
         self.icon = self.portal_url + \
                     "/++resource++bika.sanbi.images/biospecimen_big.png"
     self.allow_edit = True
Example #2
0
    def __init__(self, context):
        self.context = context
        self.sort = 10
        self.random = 4
        if IAliquot.providedBy(context):
            self.hidden_fields = ['Kit', 'SubjectID',
                                  'Barcode', 'Sampling Date',
                                  'ScheduledSamplingSampler',
                                  'PreparationWorkflow',
                                  'SamplePoint', 'Sampler']

        if IBiospecimen.providedBy(context):
            self.hidden_fields = ['Sampling Date',
                                  'LinkedSample',
                                  'ScheduledSamplingSampler',
                                  'PreparationWorkflow',
                                  'SamplePoint', 'Sampler']
Example #3
0
    def folderitems(self, full_objects=False):
        items = BikaListingView.folderitems(self)
        bsc = getToolByName(self.context, 'bika_setup_catalog')
        brains = bsc(portal_type='SampleType', inactive_state='active')
        aliquot_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 IAliquot.providedBy(obj):
                continue
            items[x]['replace']['Biospecimen'] = \
                "<a href='%s'>%s</a>" % (obj.getField('LinkedSample').get(obj).absolute_url(),
                                        obj.getField('LinkedSample').get(obj).Title())
            items[x]['AliquotType'] = obj.getSampleType() and obj.getSampleType().Title() or ''
            items[x]['Volume'] = items[x]['Volume'] = obj.getField('Volume').get(obj)
            items[x]['Unit'] = VOLUME_UNITS[0]['ResultText']
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                                           (items[x]['url'], items[x]['Title'])
            if self.context.portal_type == 'Aliquots':
                items[x]['replace']['Project'] = \
                    '<a href="%s">%s</a>' % (obj.aq_parent.absolute_url(),
                                             obj.aq_parent.Title())

            if self.allow_edit and isActive(self.context) and \
                    getSecurityManager().checkPermission("Modify portal content", obj) and \
                    items[x]['review_state'] == "sample_due":
                items[x]['allow_edit'] = ['AliquotType', 'Volume', 'Unit']
                items[x]['choices']['AliquotType'] = aliquot_types
                items[x]['choices']['Unit'] = VOLUME_UNITS
            ret.append(item)

        return ret
Example #4
0
    def folderitems(self, full_objects=False):
        items = BikaListingView.folderitems(self)
        bsc = getToolByName(self.context, 'bika_setup_catalog')
        brains = bsc(portal_type='SampleType', inactive_state='active')
        aliquot_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 IAliquot.providedBy(obj):
                continue
            items[x]['replace']['Biospecimen'] = \
                "<a href='%s'>%s</a>" % (obj.getField('LinkedSample').get(obj).absolute_url(),
                                        obj.getField('LinkedSample').get(obj).Title())
            items[x]['AliquotType'] = obj.getSampleType(
            ) and obj.getSampleType().Title() or ''
            items[x]['Volume'] = items[x]['Volume'] = obj.getField(
                'Volume').get(obj)
            items[x]['Unit'] = VOLUME_UNITS[0]['ResultText']
            items[x]['replace']['Title'] = "<a href='%s'>%s</a>" % \
                                           (items[x]['url'], items[x]['Title'])
            if self.context.portal_type == 'Aliquots':
                items[x]['replace']['Project'] = \
                    '<a href="%s">%s</a>' % (obj.aq_parent.absolute_url(),
                                             obj.aq_parent.Title())

            if self.allow_edit and isActive(self.context) and \
                    getSecurityManager().checkPermission("Modify portal content", obj) and \
                    items[x]['review_state'] == "sample_due":
                items[x]['allow_edit'] = ['AliquotType', 'Volume', 'Unit']
                items[x]['choices']['AliquotType'] = aliquot_types
                items[x]['choices']['Unit'] = VOLUME_UNITS
            ret.append(item)

        return ret