Пример #1
0
    def setUpPloneSite(self, portal):
        login(portal.aq_parent, SITE_OWNER_NAME)

        wf = getToolByName(portal, 'portal_workflow')
        wf.setDefaultChain('plone_workflow')
        setupPortalContent(portal)

        # make sure we have folder_listing as a template
        portal.getTypeInfo().manage_changeProperties(
            view_methods=['folder_listing'],
            default_view='folder_listing')

        applyProfile(portal, 'bika.lims:default')
        applyProfile(portal, 'bika.health:default')

        # Add some test users
        for role in ('LabManager',
                     'LabClerk',
                     'Analyst',
                     'Verifier',
                     'Sampler',
                     'Preserver',
                     'Publisher',
                     'Member',
                     'Reviewer',
                     'RegulatoryInspector'):
            for user_nr in range(2):
                if user_nr == 0:
                    username = "******" % (role.lower())
                else:
                    username = "******" % (role.lower(), user_nr)
                member = portal.portal_registration.addMember(
                    username,
                    username,
                    properties={
                        'username': username,
                        'email': username + "@example.com",
                        'fullname': username}
                )
                # Add user to all specified groups
                group_id = role + "s"
                group = portal.portal_groups.getGroupById(group_id)
                if group:
                    group.addMember(username)
                # Add user to all specified roles
                member._addRole(role)
                # If user is in LabManagers, add Owner local role on clients folder
                if role == 'LabManager':
                    portal.clients.manage_setLocalRoles(username, ['Owner', ])

        # load test data
        self.request = makerequest(portal.aq_parent).REQUEST
        self.request.form['setupexisting'] = 1
        self.request.form['existing'] = "bika.health:test"
        lsd = LoadSetupData(portal, self.request)
        lsd()

        logout()
Пример #2
0
    def setup_data_load(self, portal, request):
        login(portal.aq_parent, SITE_OWNER_NAME)  # again

        # load test data
        request.form['setupexisting'] = 1
        request.form['existing'] = "bika.lims:test"
        lsd = LoadSetupData(portal, request)
        lsd()
        logout()
Пример #3
0
 def __call__(self):
     if 'submitted' in self.request:
         if 'setupfile' in self.request.form or \
            'setupexisting' in self.request.form:
             lsd = LoadSetupData(self.context, self.request)
             return lsd()
         else:
             exim = getattr(instruments, self.request['exim'])
             return exim.Import(self.context, self.request)
     else:
         return self.template()
Пример #4
0
    def setup_data_load(self):
        transaction.commit()
        login(self.portal.aq_parent, SITE_OWNER_NAME)  # again

        # load test data
        self.request.form['setupexisting'] = 1
        self.request.form['existing'] = "bika.lims:test"
        lsd = LoadSetupData(self.portal, self.request)
        logger.info('Loading datas...')
        lsd()
        logger.info('Loading data finished...')
        logout()
Пример #5
0
    def setUpPloneSite(self, portal):
        super(BikaTestLayer, self).setUpPloneSite(portal)

        login(portal.aq_parent, SITE_OWNER_NAME)  # again

        # load test data
        self.request = makerequest(portal.aq_parent).REQUEST
        self.request.form['setupexisting'] = 1
        self.request.form['existing'] = "bika.lims:test"
        lsd = LoadSetupData(portal, self.request)
        lsd()

        logout()
Пример #6
0
 def __call__(self):
     if 'submitted' in self.request:
         if 'setupfile' in self.request.form or \
            'setupexisting' in self.request.form:
             lsd = LoadSetupData(self.context, self.request)
             return lsd()
         else:
             exim = instruments.getExim(self.request['exim'])
             if not exim:
                 er_mes = "Importer not found for: %s" % self.request['exim']
                 results = {'errors': [er_mes], 'log': '', 'warns': ''}
                 return json.dumps(results)
             else:
                 return exim.Import(self.context, self.request)
     else:
         return self.template()