Exemple #1
0
class EmployeeDatabase:
    def __init__(self):
        # employees = session.query(DB_Employee).all()
        # _employees = []
        # for emp in employees:
        #     emp_data = {
        #         'id': emp.id,
        #         'name': emp.name,
        #         'role': emp.role,
        #     }
        #     _employees.append(emp_data)
        #
        # self._employees = _employees
        self._employees = [
            {
                'id': 1,
                'name': 'Mary Poppins',
                'role': 'manager'
            },
            {
                'id': 2,
                'name': 'John Smith',
                'role': 'secretary'
            },
            {
                'id': 3,
                'name': 'Kevin Bacon',
                'role': 'sales'
            },
            {
                'id': 4,
                'name': 'Jane Doe',
                'role': 'factory'
            },
            {
                'id': 5,
                'name': 'Robin Williams',
                'role': 'secretary'
            },
        ]
        self.productivity = ProductivitySystem()
        self.payroll = PayrollSystem()
        self.employee_addresses = AddressBook()

    @property
    def employees(self):
        return [self._create_employee(**data) for data in self._employees]

    def _create_employee(self, id, name, role):
        address = self.employee_addresses.get_employee_address(id)
        employee_role = self.productivity.get_role(role)
        payroll_policy = self.payroll.get_policy(id)
        return Employee(id, name, address, employee_role, payroll_policy)
Exemple #2
0
class EmployeeDatabase(object):
    def __init__(self):
        self._employees = [{
            'id': 1,
            'name': 'm',
            'role': 'manager'
        }, {
            'id': 2,
            'name': 's',
            'role': 'secretary'
        }, {
            'id': 3,
            'name': 's',
            'role': 'sales'
        }, {
            'id': 4,
            'name': 'f',
            'role': 'factory'
        }, {
            'id': 5,
            'name': 'ts',
            'role': 'secretary'
        }]

        # link components
        self.productivity = ProductivitySystem(
        )  # should I be calling this somewhere?
        self.payroll = PayrollSystem()
        self.addresses = AddressBook()

    @property  # getter for employees list
    def employees(self):
        return [self._create_employee(i + 1) for i in range(5)]

    def _create_employee(self, id):
        self.id = id
        self.name = self._employees[id - 1].get('name')
        self.role = self.productivity.get_role(self._employees[id -
                                                               2].get('role'))
        self.policy = self.payroll.get_policy(id)
        self.address = self.addresses.get_employee_address(id)

        return Employee(self.id, self.name, self.role, self.policy,
                        self.address)
class EmployeeDatabase:
    def __init__(self):
        self._employees = [
            {
                'id': 1,
                'name': 'Mary Poppins',
                'role': 'manager'
            },
            {
                'id': 2,
                'name': 'John Smith',
                'role': 'secretary'
            },
            {
                'id': 3,
                'name': 'Kevin Bacon',
                'role': 'sales'
            },
            {
                'id': 4,
                'name': 'Jane Doe',
                'role': 'factory'
            },
            {
                'id': 5,
                'name': 'Robin Williams',
                'role': 'secretary'
            }
        ]

        self.productivity = ProductivitySystem()
        self.payroll = PayrollSystem()
        self.employee_addresses = AddressBook()

    def employees(self):
        return [self._create_employee(**data) for data in self._employees]

    def _create_employee(self, id, name, role):
        address = self.employee_addresses.get_employee_address(id)
        employee_role = self.productivity.get_role(role)
        payroll_policy = self.payroll.get_policy(id)
        return Employee(id, name, address, employee_role, payroll_policy)
Exemple #4
0
class EmployeeDatabase:
    def __init__(self):
        self._employees = [
            {
                "id": 1,
                "name": "Mary Poppins",
                "role": "manager"
            },
            {
                "id": 2,
                "name": "John Smith",
                "role": "secretary"
            },
            {
                "id": 3,
                "name": "Kevin Bacon",
                "role": "sales"
            },
            {
                "id": 4,
                "name": "Jane Doe",
                "role": "factory"
            },
            {
                "id": 5,
                "name": "Robin Williams",
                "role": "secretary"
            },
        ]
        self.productivity = ProductivitySystem()
        self.payroll = PayrollSystem()
        self.employee_addresses = AddressBook()

    @property
    def employees(self):
        return [self._create_employee(**data) for data in self._employees]

    def _create_employee(self, id, name, role):
        address = self.employee_addresses.get_employee_address(id)
        employee_role = self.productivity.get_role(role)
        payroll_policy = self.payroll.get_policy(id)
        return Employee(id, name, address, employee_role, payroll_policy)