Exemple #1
0
 def add_person(self, person_name, person_position, wants_accommodation=False):
     """A method that defines how a new occupant of the dojo is created and assigned space"""
     if person_name not in list(self.list_of_people.keys()):
         if person_position.lower().strip() == 'fellow':
             new_fellow = Fellow(person_name)
             self.list_of_people[person_name] = new_fellow
             self.list_of_fellows[person_name] = new_fellow
             self.total_number_of_fellows += 1
             self.total_number_of_people += 1
             office_allocation_msg = self.allocate_office_space(person_name)
             living_space_allocation_message = ''
             if not len(self.list_of_people[person_name].office_assigned):
                 self.unallocated_people.append(person_name)
             if wants_accommodation:
                 living_space_allocation_message = self.allocate_living_space(person_name)
             return ' Fellow ' + person_name + ' has been successfully added.\n' + office_allocation_msg + living_space_allocation_message + '\n'
         elif person_position.lower().strip() == 'staff':
             new_staff = Staff(person_name)
             self.list_of_people[person_name] = new_staff
             self.list_of_staff[person_name] = new_staff
             self.total_number_of_staff += 1
             self.total_number_of_people += 1
             office_allocation_msg = self.allocate_office_space(person_name)
             if not len(self.list_of_people[person_name].office_assigned):
                 self.unallocated_people.append(person_name)
             return ' Staff ' + person_name + ' has been successfully added.' + '\n' + office_allocation_msg + '\n'
         else:
             return ' Enter a valid position e.g. Fellow, Staff'
     else:
         return ' A person with this name already exists'
Exemple #2
0
    def add_person(self, name, position, wants_accomodation):
        '''A method that checks whether the person is staff or a fellow. It then calls
        the method 'allocate_random' to allocate the person a living space or office or both'''
        office = 'office'
        livingspace = 'Living space'

        if (position == 'STAFF'):
            new_staff = Staff(name)
            name = new_staff

            self.allocate_random(name, office, self.dojo_offices, Office,
                                 position)

            if (wants_accomodation == 'Y'):
                print('\n\n')
                print(
                    colored(
                        'Sorry there are no living spaces available for staff',
                        'red'))
                print('\n\n')
                return 'Sorry there are no living spaces available for staff'
            return new_staff
        else:
            new_fellow = Fellow(name)
            name = new_fellow

            self.allocate_random(name, office, self.dojo_offices, Office,
                                 position)
            if (wants_accomodation == 'Y'):
                self.allocate_random(name, livingspace, self.dojo_livingspaces,
                                     LivingSpace, position)
            return new_fellow
    def __init__(self,
                 name="",
                 jobType="",
                 wantsRoom="NO",
                 choice=1,
                 new_id_no=0):
        self.name = name
        self.jobType = jobType
        self.wantsRoom = wantsRoom
        self.choice = choice
        self.id_no = 0
        self.new_id_no = new_id_no

        if self.choice == 0:
            self.id_no = self.generate_ID(self.name)
        else:
            self.id_no = self.new_id_no

        #Create a variable that holds the instance of person created
        if self.jobType == "FELLOW":
            self.andelan = Fellow(self.id_no)

        elif self.jobType == "STAFF":
            self.andelan = Staff(self.id_no)

        else:
            #If job type is not indicated, person created is fellow by default.
            self.wantsRoom = "NO"
            self.andelan = Fellow(self.id_no)
Exemple #4
0
    def test_reallocate_person_successful_message(self):
        new_person = Staff('STEVE JOBS')
        self.the_dojo.dojo_offices['BLUE'] = [new_person]
        self.the_dojo.dojo_offices['RED'] = []

        person_id = id(new_person)
        self.the_dojo.reallocate_person(person_id, 'RED', 'OFFICE')
Exemple #5
0
    def test_reallocate_person_from_office_to_office(self):
        new_person = Staff('CHARLES ODUK')
        self.the_dojo.dojo_offices['BLUE'] = [new_person]
        self.the_dojo.dojo_offices['RED'] = []

        person_id = id(new_person)
        self.the_dojo.reallocate_person(person_id, 'RED', 'OFFICE')
        self.assertIn(new_person,self.the_dojo.dojo_offices['RED'])
Exemple #6
0
 def load_unallocated_people():
     for person in session.query(Unallocated).order_by(Unallocated.id):
         name = person.name
         position = person.position
         need1 = person.need_one
         need2 = person.need_two
         if need2 == 'No need':
             if position == 'STAFF':
                 name = Staff(name)
                 self.unallocated[name] = [position, need1]
             else:
                 name = Fellow(name)
                 self.unallocated[name] = [position, need1]
         else:
             if position == 'STAFF':
                 name = Staff(name)
                 self.unallocated[name] = [position, need1, need2]
             else:
                 name = Fellow(name)
                 self.unallocated[name] = [position, need1, need2]
    def create(role, name, age, gender, **kwargs):
        if role.lower() == "fellow":
            wants_residence = kwargs.get("wants_residence")
            level = kwargs.get("level")
            person = Fellow(name, age, gender, wants_residence, level)

        if role.lower() == "staff":
            job_title = kwargs.get("job_title")
            department = kwargs.get("department")
            person = Staff(name, age, gender, job_title, department)

        return person
Exemple #8
0
 def load_rooms_and_people_in_them():
     for room in session.query(Rooms).order_by(Rooms.id):
         if room.roomtype == 'OFFICE':
             rooms = self.dojo_offices
         else:
             rooms = self.dojo_livingspaces
         rooms[room.roomname] = []
         for person in session.query(People).order_by(People.id):
             if person.room == room.roomname:
                 if person.position == 'STAFF':
                     person = Staff(person.name)
                     rooms[room.roomname].append(person)
                 else:
                     person = Fellow(person.name)
                     rooms[room.roomname].append(person)
Exemple #9
0
    def test_office_can_fill_up(self):
        self.office.add_person(Staff('Atukwase Sylvestre'))
        self.office.add_person(Staff('Murungi Patricia'))
        self.office.add_person(Fellow('Patience Mukami', True))
        self.office.add_person(Staff('Irene Mulyagonja'))
        self.office.add_person(Staff('Annie Myles'))
        self.office.add_person(Staff('John Katureebe'))
        self.office.add_person(Staff('George Williams'))

        self.assertEqual(len(self.office.members), 6)
        self.assertTrue(self.office.is_full())
Exemple #10
0
    def add_person(self, name, person_type, wants_accommodation):
        """
        adds a newly *inducted* person into the room allocation system.
        It can go ahead and grant them rooms depending on their person type.
        """
        person = None
        # what do we do for existing fellows and staff, do we re-add them
        if person_type == 'Fellow':
            person = Fellow(name, wants_accommodation)
        elif person_type == 'Staff':
            person = Staff(name)
        else:
            print("unknown person type: expecting <Fellow> or <Staff> type")
            return False

        if person is not None:
            self.employees.append(person)
            self._allocate_person_room(person)
        return True
Exemple #11
0
 def setUp(self):
     self.office = Office('Blue')
     self.staff1 = Staff('Will')
Exemple #12
0
 def test_staff_not_added_to_livingspaces(self):
     self.assertEqual(len(self.livingspace.members), 0)
     resp = self.livingspace.add_person(Staff('Kadongo Moses'))
     self.assertEqual(len(self.livingspace.members), 0)
     self.assertFalse(resp)
     self.assertTrue(self.livingspace.is_empty())
 def __init__(self):
     self.engine = ''
     self.fellow = Fellow()
     self.staff = Staff()
     self.living_space = LivingSpace()
     self.office = Office()
Exemple #14
0
 def setUp(self):
     self.staff = Staff()