コード例 #1
0
    def execute_creation_batch(self, account_creation_data_list):
        result = self.validate_batch(account_creation_data_list)
        if (result.has_issue()):
            return result

        account_results = []

        # Create all employee accounts
        for account_info in account_creation_data_list:
            account_result = self.execute_creation(account_info, False)
            account_results.append(account_result)

        # Now that all accounts are created, start the organization
        # setup for all employees in batch mode using the corresponding
        # service
        org_data_list = []
        for account_result in account_results:
            account_info = account_result.output_data
            person_id = Person.objects.get(user=account_info.user_id,
                                           relationship=SELF).id
            org_data = EmployeeOrganizationSetupData(
                employee_person_id=person_id,
                company_id=account_info.company_id,
                manager_profile_id=account_info.manager_id,
                manager_first_name=account_info.manager_first_name,
                manager_last_name=account_info.manager_last_name)
            org_data_list.append(org_data)

        manager_service = EmployeeOrganizationService()
        manager_service.batch_execute_employee_organization_setup(
            org_data_list)

        result.set_output_data(account_results)
        return result
コード例 #2
0
    def test_employee_organization_setup_manager_full_name_succeed(self):
        service = EmployeeOrganizationService()

        manager_person_id = 3
        manager_person = Person.objects.get(pk=manager_person_id)

        person_id = 4
        company_id = 1
        manager_profile_id = None
        manager_first_name = manager_person.first_name
        manager_last_name = manager_person.last_name

        data = EmployeeOrganizationSetupData(
            employee_person_id=person_id,
            company_id=company_id,
            manager_profile_id=manager_profile_id,
            manager_first_name=manager_first_name,
            manager_last_name=manager_last_name)

        service.execute_employee_organization_setup(data)

        employee_profile = EmployeeProfile.objects.get(person=person_id,
                                                       company=company_id)

        self.assertEqual(employee_profile.manager.id,
                         manager_person.employee_profile_person.first().id)
コード例 #3
0
    def test_employee_organization_setup_non_exist_manager_by_profile_id_fail_with_validation_issue(
            self):
        service = EmployeeOrganizationService()

        person_id = 4
        company_id = 1
        manager_profile_id = 9999
        manager_first_name = None
        manager_last_name = None

        data = EmployeeOrganizationSetupData(
            employee_person_id=person_id,
            company_id=company_id,
            manager_profile_id=manager_profile_id,
            manager_first_name=manager_first_name,
            manager_last_name=manager_last_name)

        result = service.validate_employee_organization_setup_data(data)

        self.assertTrue(result.has_issue())
コード例 #4
0
 def restore_object(self, attrs, instance=None):
     return EmployeeOrganizationSetupData(**attrs)