Exemple #1
0
def ObjectInitializedEventHandler(instance, event):
    """called an object is created
    """
    if instance.portal_type in ['Sample', 'VirusSample']:

        if instance.getField('AllowSharing').get(instance):
            alsoProvides(instance, ISharableSample)
            instance.reindexObject()

        if not instance.getField('Barcode').get(instance):
            instance.getField('Barcode').set(instance, instance.getId())

        create_samplepartition(instance, {
            'services': [],
            'part_id': instance.getId() + "-P"
        })

        location = instance.getStorageLocation()
        if hasattr(instance, 'api_source'):
            if instance.api_source == "odk":  #special case for field collecdted odk samples
                doActionFor(instance, 'sample_due')
                if location:
                    doActionFor(location, 'reserve')
                    instance.update_box_status(location)
            delattr(instance, 'api_source')
        else:
            if float(instance.getField('Volume').get(instance)) > 0:
                doActionFor(instance, 'sample_due')
                doActionFor(instance, 'receive')

            if location:
                doActionFor(location, 'occupy')
                instance.update_box_status(location)
Exemple #2
0
    def __call__(self):
        if "viewlet_submitted" in self.request.form:
            data = {}
            try:
                data = self.validate_form_inputs()
            except ValidationError as e:
                self.form_error(e.message)

            # Validation is complete, now set local variables from form inputs.
            biospecimens = []
            j = 0
            if data:
                workflow_enabled = self.context.bika_setup.getSamplingWorkflowEnabled()
                for x in range(data['seq_start'], data['seq_start'] + data['biospecimen_count']):
                    sample = create_sample(self.context, self.request, data, j, x)
                    partition = create_samplepartition(sample, {'services':[], 'part_id': sample.getId() + "-P"})
                    if not workflow_enabled:
                        doActionFor(sample, 'sample_due')
                        doActionFor(partition, 'sample_due')
                    sample.reindexObject()
                    if (x-data['seq_start']+1) % data['biospecimen_per_kit'] == 0 and (x-data['seq_start']+1) != 0:
                        j += 1
                    biospecimens.append(sample)

                #store the created biospecimens
                self.assign_biospecimens_to_storages(biospecimens, data['storages'])

                msg = u'%s Biospecimens created.' % len(biospecimens)
                self.context.plone_utils.addPortalMessage(msg)
            self.request.response.redirect(self.context.absolute_url() + '/biospecimens')
Exemple #3
0
    def at_post_create_script(self):
        """Execute once the object is created
        """

        if self.aq_parent.Title() == 'Biospecimens':
            self.container = self.getField('Project').get(self)
            doActionFor(self, 'sample_due')
            doActionFor(self, 'receive')

        create_samplepartition(self, {
            'services': [],
            'part_id': self.getId() + "-P"
        })

        location = self.getStorageLocation()
        if location:
            doActionFor(location, 'occupy')