Пример #1
0
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()
Пример #2
0
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()
Пример #3
0
def add_correct():
    for account_number, title in correct_accounts:
        try:
            Account.objects.get(unit=cmpt, account_number=account_number)
        except Account.DoesNotExist:
            a=Account(unit=cmpt, account_number=account_number, position_number=1, title=title)
            a.save()
Пример #4
0
def add_correct():
    for account_number, title in correct_accounts:
        try:
            Account.objects.get(unit=cmpt, account_number=account_number)
        except Account.DoesNotExist:
            a = Account(unit=cmpt,
                        account_number=account_number,
                        position_number=1,
                        title=title)
            a.save()
Пример #5
0
def create_more_data():
    """
    More data for the unit tests and general usabilty of a test system
    """
    templates = [
        {
            "field":
            "contact_email_text",
            "label":
            "generic",
            "text":
            "DESCRIPTION OF INCIDENT. This does not usually occur unless there is a violation of SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n  http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"
        },
        {
            "field":
            "contact_email_text",
            "label":
            "not your work",
            "text":
            "Your submission for {{ACTIVITIES}} contains work that does not appear to be your own. This indicates that there is a violation of SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n  http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"
        },
        {
            "field": "facts",
            "label": "attachment",
            "text": "See details in attached file facts.pdf."
        },
        {
            "field":
            "contact_email_text",
            "label":
            "simiar work (group)",
            "text":
            "You and other students submitted very similar work on {{ACTIVITIES}}. This level of similarity does not usually occur unless collaboration exceeds the limits allowed by SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n  http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"
        },
        {
            "field":
            "facts",
            "label":
            "copied (other knew)",
            "text":
            "{{FNAME}} was given a solution to {{ACTIVITIES}} by another student. The other student seems to have completed the work independently. Both students submitted the work as their own."
        },
        {
            "field":
            "facts",
            "label":
            "copied (without knowledge)",
            "text":
            "{{FNAME}} copied the work of another student on {{ACTIVITIES}} without his/her knowledge.  Both students submitted the work as their own."
        },
        {
            "field":
            "meeting_summary",
            "label":
            "admitted",
            "text":
            u"The student admitted academic dishonesty as described below in \u201cfacts of the case\u201d."
        },
        {
            "field":
            "meeting_summary",
            "label":
            "quote email",
            "text":
            "The student explained the situation in his/her email:\r\n\r\nbq. PASTE QUOTE HERE"
        },
        {
            "field": "meeting_summary",
            "label": "explained",
            "text": "{{FNAME}} explained that..."
        },
    ]
    for data in templates:
        t = DisciplineTemplate(**data)
        t.save()

    cmpt = Unit.objects.get(slug='cmpt')
    a = Account(account_number=12345,
                position_number=12345,
                title='MSc TA',
                unit=cmpt)
    a.save()
    a = Account(account_number=12346,
                position_number=12346,
                title='PhD TA',
                unit=cmpt)
    a.save()
    a = Account(account_number=12347,
                position_number=12347,
                title='External TA',
                unit=cmpt)
    a.save()
    a = Account(account_number=12348,
                position_number=12348,
                title='Undergrad TA',
                unit=cmpt)
    a.save()

    uc = UserConfig(user=Person.objects.get(userid='dzhao'),
                    key='advisor-token',
                    value={'token': '30378700c0091f34412ec9a082dca267'})
    uc.save()
    uc = UserConfig(user=Person.objects.get(userid='ggbaker'),
                    key='advisor-token',
                    value={'token': '082dca26730378700c0091f34412ec9a'})
    uc.save()
    p = Person(userid='probadmn',
               emplid='200002387',
               first_name='Problem',
               last_name='Admin')
    p.save()
    uc = UserConfig(user=p,
                    key='problems-token',
                    value={'token': '30378700c0091f34412ec9a082dca268'})
    uc.save()

    p = Person(userid='teachadm',
               emplid='200002388',
               first_name='Teaching',
               last_name='Admin')
    p.save()
    r = Role(person=p, role="TADM", unit=Unit.objects.get(slug='cmpt'))
    r.save()
    #sp = SemesterPlan(semester=Semester.objects.get(name=TEST_SEMESTER), name='Test Plan', unit=Unit.objects.get(slug='cmpt'), slug='test-plan')
    #sp.save()
    #o = PlannedOffering(plan=sp, course=Course.objects.get(slug='cmpt-102'), section='D100', campus='BRNBY', enrl_cap=100)
    #o.save()
    #PlanningCourse.create_for_unit(Unit.objects.get(slug='cmpt'))
    #te = TeachingEquivalent(pk=1, instructor=Person.objects.get(userid='ggbaker'), semester=Semester.objects.get(name=TEST_SEMESTER), credits_numerator=1, credits_denominator=1, summary="Foo", status='UNCO')
    #te.save()
    #ti = TeachingIntention(instructor=Person.objects.get(userid='ggbaker'), semester=Semester.objects.get(name=TEST_SEMESTER), count=2)
    #ti.save()
    #tc = TeachingCapability(instructor=Person.objects.get(userid='ggbaker'), course=Course.objects.get(slug='cmpt-102'), note='foo')
    #tc.save()

    p = Person(userid='classam',
               emplid='200002389',
               first_name='Curtis',
               last_name='Lassam')
    p.save()
    r = Role(person=p, role="TECH", unit=Unit.objects.get(slug='cmpt'))
    r.save()
    r = Role(person=p, role="SYSA", unit=Unit.objects.get(slug='cmpt'))
    r.save()

    # create some faculty roles
    members = Member.objects.filter(role='INST', offering__owner__slug='cmpt')
    instr = set(m.person for m in members)
    faculty = random.sample(instr, 10)
    for p in faculty:
        Role.objects.get_or_create(person=p, role='FAC', unit=cmpt)
Пример #6
0
 def setUp(self):
     """
         Build a TACategory, TAContract, and two TACourses
     """
     unit = Unit(label="TEST", name="A Fake Unit for Testing") 
     unit.save()
     person = Person(emplid="300000000",
                     userid="testy",
                     first_name="Testy",
                     last_name="Testerson")
     person.save()
     semester = Semester(name="1147",
                         start=datetime.date.today(),
                         end=datetime.date.today())
     semester.save()
     course1 = Course(subject="TEST", 
                     number="100",
                     title="Intro to Testing")
     course1.save()
     course2 = Course(subject="TEST", 
                     number="200",
                     title="Advanced Testing")
     course2.save()
     courseoffering1 = CourseOffering(subject="TEST",
                                      number="100",
                                      section="D100",
                                      semester=semester,
                                      component="LEC",
                                      owner=unit,
                                      title="Intro to Testing",
                                      campus="BRNBY",
                                      enrl_cap=100,
                                      enrl_tot=100,
                                      wait_tot=50,
                                      course=course1)
     courseoffering1.save()
     courseoffering2 = CourseOffering(subject="TEST",
                                      number="200",
                                      section="D200",
                                      semester=semester,
                                      component="LEC",
                                      owner=unit,
                                      title="Advanced Testing",
                                      campus="BRNBY",
                                      enrl_cap=100,
                                      enrl_tot=100,
                                      wait_tot=50,
                                      course=course2)
     courseoffering2.save()
     account = Account(unit=unit, 
                       account_number=1337, 
                       position_number=5,
                       title="A Fake Account for Testing")
     account.save()
     four_weeks_later = datetime.date.today() + datetime.timedelta(days=28)
     hiring_semester = HiringSemester(semester=semester,
                               unit=unit,
                               deadline_for_acceptance=datetime.date.today(),
                               pay_start=datetime.date.today(),
                               pay_end=four_weeks_later,
                               payperiods=2.5)
     hiring_semester.save()
     category = TACategory(account=account,
                           hiring_semester=hiring_semester,
                           code="TST",
                           title="Test Contract Category",
                           hours_per_bu=decimal.Decimal("42"),
                           holiday_hours_per_bu=decimal.Decimal("1.1"),
                           pay_per_bu=decimal.Decimal("125.00"),
                           scholarship_per_bu=decimal.Decimal("25.00"),
                           bu_lab_bonus=decimal.Decimal("0.17"))
     category.save()
     contract = TAContract(category=category,
                           person=person,
                           status="NEW",
                           sin="123456789",
                           deadline_for_acceptance=datetime.date.today(),
                           pay_start=datetime.date.today(),
                           pay_end=datetime.date.today() + datetime.timedelta(days=10),
                           payperiods=2.5,
                           appointment="INIT",
                           conditional_appointment=True,
                           created_by="classam",
                           tssu_appointment=True)
     contract.save()
     tacourse = TACourse(course=courseoffering1,
                         contract=contract,
                         bu=decimal.Decimal('3.0'),
                         labtut=True)
     tacourse.save()
     tacourse2 = TACourse(course=courseoffering2,
                          contract=contract,
                          bu=decimal.Decimal('2.0'),
                          labtut=False)
     tacourse2.save()
Пример #7
0
def create_more_data():
    """
    More data for the unit tests and general usabilty of a test system
    """
    templates = [
                 {"field": "contact_email_text",
                  "label": "generic",
                  "text": "DESCRIPTION OF INCIDENT. This does not usually occur unless there is a violation of SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n  http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"},
                 {"field": "contact_email_text",
                  "label": "not your work",
                  "text": "Your submission for {{ACTIVITIES}} contains work that does not appear to be your own. This indicates that there is a violation of SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n  http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"},
                 {"field": "facts",
                  "label": "attachment",
                  "text": "See details in attached file facts.pdf."},
                 {"field": "contact_email_text",
                  "label": "simiar work (group)",
                  "text": "You and other students submitted very similar work on {{ACTIVITIES}}. This level of similarity does not usually occur unless collaboration exceeds the limits allowed by SFU's Code of Academic Integrity and Good Conduct, Policy S10.01. I take academic honesty very seriously and intend to pursue this apparent violation of SFU's standards for academic honesty.\r\n\r\nAs required by SFU Policy S10.02, Principles and Procedures for Academic Discipline, I am offering you the opportunity to meet with me to discuss this incident. You are not required to accept this offer. If you would like to meet, please contact me to make an appointment outside of my regular office hours.\r\n\r\nYou may wish to refer to SFU's policies and procedures on academic integrity,\r\n  http://www.sfu.ca/policies/Students/index.html .\r\nYou can also contact the Office of the Ombudsperson for assistance in navigating University procedures.\r\n"},
                 {"field": "facts",
                  "label": "copied (other knew)",
                  "text": "{{FNAME}} was given a solution to {{ACTIVITIES}} by another student. The other student seems to have completed the work independently. Both students submitted the work as their own."},
                 {"field": "facts",
                  "label": "copied (without knowledge)",
                  "text": "{{FNAME}} copied the work of another student on {{ACTIVITIES}} without his/her knowledge.  Both students submitted the work as their own."},
                 {"field": "meeting_summary",
                  "label": "admitted",
                  "text": "The student admitted academic dishonesty as described below in \u201cfacts of the case\u201d."},
                 {"field": "meeting_summary",
                  "label": "quote email",
                  "text": "The student explained the situation in his/her email:\r\n\r\nbq. PASTE QUOTE HERE"},
                 {"field": "meeting_summary",
                  "label": "explained",
                  "text": "{{FNAME}} explained that..."},
                 ]
    for data in templates:
        t = DisciplineTemplate(**data)
        t.save()

    cmpt = Unit.objects.get(slug='cmpt')
    a = Account(account_number=12345, position_number=12345, title='MSc TA', unit=cmpt)
    a.save()
    a = Account(account_number=12346, position_number=12346, title='PhD TA', unit=cmpt)
    a.save()
    a = Account(account_number=12347, position_number=12347, title='External TA', unit=cmpt)
    a.save()
    a = Account(account_number=12348, position_number=12348, title='Undergrad TA', unit=cmpt)
    a.save()

    uc = UserConfig(user=Person.objects.get(userid='dzhao'), key='advisor-token', value={'token': '30378700c0091f34412ec9a082dca267'})
    uc.save()
    uc = UserConfig(user=Person.objects.get(userid='ggbaker'), key='advisor-token', value={'token': '082dca26730378700c0091f34412ec9a'})
    uc.save()
    p = Person(userid='probadmn', emplid='200002387', first_name='Problem', last_name='Admin')
    p.save()
    uc = UserConfig(user=p, key='problems-token', value={'token': '30378700c0091f34412ec9a082dca268'})
    uc.save()

    p = Person(userid='teachadm', emplid='200002388', first_name='Teaching', last_name='Admin')
    p.save()
    r = Role(person=p, role="TADM", unit=Unit.objects.get(slug='cmpt'))
    r.save()
    #sp = SemesterPlan(semester=Semester.objects.get(name=TEST_SEMESTER), name='Test Plan', unit=Unit.objects.get(slug='cmpt'), slug='test-plan')
    #sp.save()
    #o = PlannedOffering(plan=sp, course=Course.objects.get(slug='cmpt-102'), section='D100', campus='BRNBY', enrl_cap=100)
    #o.save()
    #PlanningCourse.create_for_unit(Unit.objects.get(slug='cmpt'))
    #te = TeachingEquivalent(pk=1, instructor=Person.objects.get(userid='ggbaker'), semester=Semester.objects.get(name=TEST_SEMESTER), credits_numerator=1, credits_denominator=1, summary="Foo", status='UNCO')
    #te.save()
    #ti = TeachingIntention(instructor=Person.objects.get(userid='ggbaker'), semester=Semester.objects.get(name=TEST_SEMESTER), count=2)
    #ti.save()
    #tc = TeachingCapability(instructor=Person.objects.get(userid='ggbaker'), course=Course.objects.get(slug='cmpt-102'), note='foo')
    #tc.save()

    p = Person(userid='classam', emplid='200002389', first_name='Curtis', last_name='Lassam')
    p.save()
    r = Role(person=p, role="TECH", unit=Unit.objects.get(slug='cmpt'))
    r.save()
    r = Role(person=p, role="SYSA", unit=Unit.objects.get(slug='cmpt'))
    r.save()

    # create some faculty roles
    members = Member.objects.filter(role='INST', offering__owner__slug='cmpt')
    instr = set(m.person for m in members)
    faculty = random.sample(instr, 10)
    for p in faculty:
        Role.objects.get_or_create(person=p, role='FAC', unit=cmpt)
Пример #8
0
def create_ta_ra():
    """
    Build test data for the ta and ra modules.
    """
    from ta.models import CourseDescription, TAPosting, TAApplication, CoursePreference, TAContract, TACourse
    from ta.models import TAKEN_CHOICES, EXPER_CHOICES
    from ra.models import Account, Project, SemesterConfig, RAAppointment
    from ra.models import HIRING_CATEGORY_CHOICES, HIRING_CATEGORY_DISABLED

    # TAs
    d = Person.objects.get(userid='dzhao')
    unit = Unit.objects.get(slug='cmpt')
    r1 = Role(person=d, role='TAAD', unit=unit, expiry=role_expiry)
    r1.save()
    r2 = Role(person=d, role='FUND', unit=unit, expiry=role_expiry)
    r2.save()

    s = Semester.current().next_semester()
    admin = Person.objects.get(userid='dixon')
    CourseDescription(unit=unit, description="Office/Marking",
                      labtut=False).save()
    CourseDescription(unit=unit, description="Office/Marking/Lab",
                      labtut=True).save()

    a = Account(account_number=12345,
                position_number=12345,
                title='MSc TA',
                unit=unit)
    a.save()
    a = Account(account_number=12346,
                position_number=12346,
                title='PhD TA',
                unit=unit)
    a.save()
    a = Account(account_number=12347,
                position_number=12347,
                title='External TA',
                unit=unit)
    a.save()
    a = Account(account_number=12348,
                position_number=12348,
                title='Undergrad TA',
                unit=unit)
    a.save()

    post = TAPosting(semester=s, unit=unit)
    post.opens = s.start - datetime.timedelta(100)
    post.closes = s.start - datetime.timedelta(20)
    post.set_salary([972, 972, 972, 972])
    post.set_scholarship([135, 340, 0, 0])
    post.set_accounts([
        Account.objects.get(account_number=12345).id,
        Account.objects.get(account_number=12346).id,
        Account.objects.get(account_number=12347).id,
        Account.objects.get(account_number=12348).id
    ])
    post.set_start(s.start)
    post.set_end(s.end)
    post.set_deadline(s.start - datetime.timedelta(10))
    post.set_payperiods(7.5)
    post.set_contact(admin.id)
    post.set_offer_text(
        "This is **your** TA öffer.\n\nThere are various conditions that are töö numerous to list here."
    )
    post.save()
    offerings = list(post.selectable_offerings())

    for p in Person.objects.filter(last_name='Grad'):
        app = TAApplication(posting=post,
                            person=p,
                            category=random.choice(['GTA1', 'GTA2']),
                            current_program='CMPT',
                            sin='123456789',
                            base_units=random.choice([3, 4, 5]))
        app.save()
        will_ta = []
        for i, o in enumerate(random.sample(offerings, 5)):
            t = random.choice(TAKEN_CHOICES)[0]
            e = random.choice(EXPER_CHOICES)[0]
            cp = CoursePreference(app=app,
                                  course=o.course,
                                  rank=i + 1,
                                  taken=t,
                                  exper=e)
            cp.save()

            if random.random() < 0.07 * (5 - i):
                will_ta.append(o)

        if will_ta and random.random() < 0.75:
            c = TAContract(status=random.choice(['NEW', 'OPN', 'ACC']))
            c.first_assign(app, post)
            c.save()
            for o in will_ta:
                tac = TACourse(course=o, contract=c, bu=app.base_units)
                tac.description = tac.default_description()
                tac.save()

    # RAs
    s = Semester.current()
    superv = list(
        m.person
        for m in Member.objects.filter(role='INST').select_related('person'))
    empl = list(
        itertools.chain(
            Person.objects.filter(last_name='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()

    return itertools.chain(
        [r1, r2],
        Account.objects.all(),
        Project.objects.all(),
        SemesterConfig.objects.all(),
        RAAppointment.objects.all(),
        TAPosting.objects.all(),
        CourseDescription.objects.all(),
        TAApplication.objects.all(),
        CoursePreference.objects.all(),
        TAContract.objects.all(),
        TACourse.objects.all(),
    )
Пример #9
0
def create_ta_ra():
    """
    Build test data for the ta and ra modules.
    """
    from ta.models import CourseDescription, TAPosting, TAApplication, CoursePreference, TAContract, TACourse
    from ta.models import TAKEN_CHOICES, EXPER_CHOICES
    from ra.models import Account, Project, SemesterConfig, RAAppointment
    from ra.models import HIRING_CATEGORY_CHOICES, HIRING_CATEGORY_DISABLED

    # TAs
    d = Person.objects.get(userid='dzhao')
    unit = Unit.objects.get(slug='cmpt')
    r1 = Role(person=d, role='TAAD', unit=unit)
    r1.save()
    r2 = Role(person=d, role='FUND', unit=unit)
    r2.save()

    s = Semester.current().next_semester()
    admin = Person.objects.get(userid='dixon')
    CourseDescription(unit=unit, description="Office/Marking", labtut=False).save()
    CourseDescription(unit=unit, description="Office/Marking/Lab", labtut=True).save()

    a = Account(account_number=12345, position_number=12345, title='MSc TA', unit=unit)
    a.save()
    a = Account(account_number=12346, position_number=12346, title='PhD TA', unit=unit)
    a.save()
    a = Account(account_number=12347, position_number=12347, title='External TA', unit=unit)
    a.save()
    a = Account(account_number=12348, position_number=12348, title='Undergrad TA', unit=unit)
    a.save()

    post = TAPosting(semester=s, unit=unit)
    post.opens = s.start - datetime.timedelta(100)
    post.closes = s.start - datetime.timedelta(20)
    post.set_salary([972,972,972,972])
    post.set_scholarship([135,340,0,0])
    post.set_accounts([Account.objects.get(account_number=12345).id, Account.objects.get(account_number=12346).id, Account.objects.get(account_number=12347).id, Account.objects.get(account_number=12348).id])
    post.set_start(s.start)
    post.set_end(s.end)
    post.set_deadline(s.start - datetime.timedelta(10))
    post.set_payperiods(7.5)
    post.set_contact(admin.id)
    post.set_offer_text("This is **your** TA offer.\n\nThere are various conditions that are too numerous to list here.")
    post.save()
    offerings = list(post.selectable_offerings())

    for p in Person.objects.filter(last_name='Grad'):
        app = TAApplication(posting=post, person=p, category=random.choice(['GTA1','GTA2']), current_program='CMPT', sin='123456789',
                            base_units=random.choice([3,4,5]))
        app.save()
        will_ta = []
        for i,o in enumerate(random.sample(offerings, 5)):
            t = random.choice(TAKEN_CHOICES)[0]
            e = random.choice(EXPER_CHOICES)[0]
            cp = CoursePreference(app=app, course=o.course, rank=i+1, taken=t, exper=e)
            cp.save()

            if random.random() < 0.07*(5-i):
                will_ta.append(o)

        if will_ta and random.random() < 0.75:
            c = TAContract(status=random.choice(['NEW','OPN','ACC']))
            c.first_assign(app, post)
            c.save()
            for o in will_ta:
                tac = TACourse(course=o, contract=c, bu=app.base_units)
                tac.description = tac.default_description()
                tac.save()


    # RAs
    s = Semester.current()
    superv = list(m.person for m in Member.objects.filter(role='INST').select_related('person'))
    empl = list(itertools.chain(Person.objects.filter(last_name='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()



    return itertools.chain(
        [r1, r2],
        Account.objects.all(),
        Project.objects.all(),
        SemesterConfig.objects.all(),
        RAAppointment.objects.all(),
        TAPosting.objects.all(),
        CourseDescription.objects.all(),
        TAApplication.objects.all(),
        CoursePreference.objects.all(),
        TAContract.objects.all(),
        TACourse.objects.all(),
    )
Пример #10
0
 def setUp(self):
     """
         Build a TACategory, TAContract, and two TACourses
     """
     unit = Unit(label="TEST", name="A Fake Unit for Testing") 
     unit.save()
     person = Person(emplid="300000000",
                     userid="testy",
                     first_name="Testy",
                     last_name="Testerson")
     person.save()
     semester = Semester(name="1147",
                         start=datetime.date.today(),
                         end=datetime.date.today())
     semester.save()
     course1 = Course(subject="TEST", 
                     number="100",
                     title="Intro to Testing")
     course1.save()
     course2 = Course(subject="TEST", 
                     number="200",
                     title="Advanced Testing")
     course2.save()
     courseoffering1 = CourseOffering(subject="TEST",
                                      number="100",
                                      section="D100",
                                      semester=semester,
                                      component="LEC",
                                      owner=unit,
                                      title="Intro to Testing",
                                      campus="BRNBY",
                                      enrl_cap=100,
                                      enrl_tot=100,
                                      wait_tot=50,
                                      course=course1)
     courseoffering1.save()
     courseoffering2 = CourseOffering(subject="TEST",
                                      number="200",
                                      section="D200",
                                      semester=semester,
                                      component="LEC",
                                      owner=unit,
                                      title="Advanced Testing",
                                      campus="BRNBY",
                                      enrl_cap=100,
                                      enrl_tot=100,
                                      wait_tot=50,
                                      course=course2)
     courseoffering2.save()
     account = Account(unit=unit, 
                       account_number=1337, 
                       position_number=5,
                       title="A Fake Account for Testing")
     account.save()
     four_weeks_later = datetime.date.today() + datetime.timedelta(days=28)
     hiring_semester = HiringSemester(semester=semester,
                               unit=unit,
                               deadline_for_acceptance=datetime.date.today(),
                               pay_start=datetime.date.today(),
                               pay_end=four_weeks_later,
                               payperiods=2.5)
     hiring_semester.save()
     category = TACategory(account=account,
                           hiring_semester=hiring_semester,
                           code="TST",
                           title="Test Contract Category",
                           hours_per_bu=decimal.Decimal("42"),
                           holiday_hours_per_bu=decimal.Decimal("1.1"),
                           pay_per_bu=decimal.Decimal("100.00"),
                           scholarship_per_bu=decimal.Decimal("25.00"),
                           bu_lab_bonus=decimal.Decimal("0.17"))
     category.save()
     contract = TAContract(category=category,
                           person=person,
                           status="NEW",
                           sin="123456789",
                           deadline_for_acceptance=datetime.date.today(),
                           pay_start=datetime.date.today(),
                           pay_end=datetime.date.today() + datetime.timedelta(days=10),
                           payperiods=2.5,
                           appointment="INIT",
                           conditional_appointment=True,
                           created_by="classam",
                           tssu_appointment=True)
     contract.save()
     tacourse = TACourse(course=courseoffering1,
                         contract=contract,
                         bu=decimal.Decimal('3.0'),
                         labtut=True)
     tacourse.save()
     tacourse2 = TACourse(course=courseoffering2,
                          contract=contract,
                          bu=decimal.Decimal('2.0'),
                          labtut=False)
     tacourse2.save()