Example #1
0
def add_person(first_name, last_name, phone, type_, opt_in="N"):
    try:
        type_ = type_.upper()
        if type_ == "FELLOW":
            fellow = Fellow(first_name, last_name, phone, opt_in)
            fellow.register()
            first_name = fellow.first_name
            last_name = fellow.last_name
            type_ = fellow.type_
            available_offices = Office.available()
            if available_offices is False:
                print_pretty(" There are currently no available offices.")
            else:
                selection = random.choice(list(available_offices))
                office = Office(selection)
                office.allocate_to(fellow)
                print_pretty(
                    " The fellow: %s has been allocated to the office: %s." %
                    (fellow.last_name, office.name))
            if fellow.opt_in == "Y":
                available_livingspaces = LivingSpace.available()
                if available_livingspaces is False:
                    print_pretty(
                        " There are currently no available living spaces.")
                else:
                    selection = random.choice(list(available_livingspaces))
                    livingspace = LivingSpace(selection)
                    livingspace.allocate_to(fellow)
                    print_pretty(
                        " The fellow: %s has been allocated to the living space: %s."
                        % (fellow.last_name, livingspace.name))
            print_pretty(" A %s: %s %s has been successfully created." %
                         (type_, first_name, last_name))
        elif type_ == "STAFF":
            staff = Staff(first_name, last_name, phone, opt_in)
            staff.register()
            first_name = staff.first_name
            last_name = staff.last_name
            type_ = staff.type_
            available_offices = Office.available()
            if available_offices is False:
                print_pretty(" There are currently no available offices.")
            else:
                selection = random.choice(list(available_offices))
                office = Office(selection)
                office.allocate_to(staff)
                print_pretty(
                    " The staff: %s has been allocated to the office: %s." %
                    (staff.last_name, office.name))
            print_pretty(" A %s: %s %s has been successfully created." %
                         (type_, first_name, last_name))
        else:
            print_pretty(" %s is currently not a supported role." % type_)
        #print(persons_detail)
    except Exception as e:
        print_pretty(str(e))
Example #2
0
 def test_available_office(self):
     result = Office.available()
     office = Office('MyO55e89')
     Office.add(office)
     staff = Staff("staff" + "Njsiritus", "staff" + "Otsdeno", "0700000537")
     office.allocate_to(staff)
     staff = Staff("staff" + "Njsiritus", "staff" + "Otsdeno", "0700001537")
     office.allocate_to(staff)
     result_2 = Office.available()
     staff = Staff("staff" + "Njsiritus", "staff" + "Otsdeno", "0700002537")
     office.allocate_to(staff)
     staff = Staff("staff" + "Njsiritus", "staff" + "Otsdeno", "0700003537")
     office.allocate_to(staff)
     result_3 = Office.available()
     self.assertTrue([result, result_3, type(result_2)],
                     [False, False, "set"])