def create_ra_data(): unit = Unit.objects.get(slug='cmpt') s = Semester.objects.get(name=TEST_SEMESTER) superv = list(possible_supervisor_people([unit])) empl = list(itertools.chain(Person.objects.filter(userid__endswith='grad'), random.sample(Person.objects.filter(last_name='Student'), 10))) cats = [c for c,d in HIRING_CATEGORY_CHOICES if c not in HIRING_CATEGORY_DISABLED] config = SemesterConfig.get_config([unit], s) acct = Account(account_number=12349, position_number=12349, title='NSERC RA', unit=unit) acct.save() proj1 = Project(project_number=987654, fund_number=31, unit=unit) proj1.save() proj2 = Project(project_number=876543, fund_number=13, unit=unit) proj2.save() for i in range(30): p = random.choice(empl) s = random.choice(superv) c = random.choice(cats) freq = random.choice(['B', 'L']) if freq == 'B': payargs = {'lump_sum_pay': 10000, 'biweekly_pay': 1250, 'pay_periods': 8, 'hourly_pay': 31, 'hours': 40} else: payargs = {'lump_sum_pay': 4000, 'biweekly_pay': 0, 'pay_periods': 8, 'hourly_pay': 0, 'hours': 0} ra = RAAppointment(person=p, sin=123456789, hiring_faculty=s, unit=unit, hiring_category=c, project=random.choice([proj1,proj2]), account=acct, pay_frequency=freq, start_date=config.start_date(), end_date=config.end_date(), **payargs) ra.set_use_hourly(random.choice([True, False])) ra.save()