Example #1
0
def ensure_member(person,
                  offering,
                  role,
                  cred,
                  added_reason,
                  career,
                  labtut_section=None,
                  grade=None,
                  sched_print_instr=None):
    """
    Make sure this member exists with the right properties.
    """
    if person.emplid in [200133427, 200133425, 200133426]:
        # these are: ["Faculty", "Tba", "Sessional"]. Ignore them: they're ugly.
        return

    m_old = Member.objects.filter(person=person, offering=offering)

    if len(m_old) > 1:
        # may be other manually-created dropped entries: that's okay.
        m_old = Member.objects.filter(person=person,
                                      offering=offering).exclude(role="DROP")
        if len(m_old) > 1:
            raise KeyError("Already duplicate entries: %r" % (m_old))
        elif len(m_old) == 0:
            m_old = Member.objects.filter(person=person, offering=offering)

    if len(m_old) >= 1:
        m = m_old[0]
    else:
        m = Member(person=person, offering=offering)

    m.role = role
    m.labtut_section = labtut_section
    m.credits = cred
    m.added_reason = added_reason
    m.career = career

    # record official grade if we have it (and might need it)
    if has_letter_activities(m.offering):
        m.official_grade = grade or None
    else:
        m.official_grade = None

    # record sched_print_instr status for instructors
    if role == 'INST' and sched_print_instr:
        m.config['sched_print_instr'] = sched_print_instr == 'Y'

    # if offering is being given lab/tutorial sections, flag it as having them
    # there must be some way to detect this in ps_class_tbl, but I can't see it.
    if labtut_section and not offering.labtut():
        offering.set_labtut(True)
        offering.save_if_dirty()

    m.save_if_dirty()
    return m
Example #2
0
def ensure_member(person, offering, role, cred, added_reason, career, labtut_section=None, grade=None, sched_print_instr=None):
    """
    Make sure this member exists with the right properties.
    """
    if person.emplid in [200133427, 200133425, 200133426]:
        # these are: ["Faculty", "Tba", "Sessional"]. Ignore them: they're ugly.
        return
    
    m_old = Member.objects.filter(person=person, offering=offering)

    if len(m_old)>1:
        # may be other manually-created dropped entries: that's okay.
        m_old = Member.objects.filter(person=person, offering=offering).exclude(role="DROP")
        if len(m_old)>1:
            raise KeyError("Already duplicate entries: %r" % (m_old))
        elif len(m_old)==0:
            m_old = Member.objects.filter(person=person, offering=offering)
        
    if len(m_old)>=1:
        m = m_old[0]
    else:
        m = Member(person=person, offering=offering)

    m.role = role
    m.labtut_section = labtut_section
    m.credits = cred
    m.added_reason = added_reason
    m.career = career

    # record official grade if we have it (and might need it)
    if has_letter_activities(m.offering):
        m.official_grade = grade or None
    else:
        m.official_grade = None

    # record sched_print_instr status for instructors
    if role=='INST' and sched_print_instr:
        m.config['sched_print_instr'] = sched_print_instr == 'Y'

    # if offering is being given lab/tutorial sections, flag it as having them
    # there must be some way to detect this in ps_class_tbl, but I can't see it.
    if labtut_section and not offering.labtut():
        offering.set_labtut(True)
        offering.save_if_dirty()
    
    m.save_if_dirty()
    return m
Example #3
0
        def add_membership_for(tacrs, reason, memberships):
            if not tacrs.contract.should_be_added_to_the_course or tacrs.total_bu <= 0:
                return

            # Find existing membership for this person+offering if it exists
            # (Behaviour here implies you can't be both TA and other role in one offering: I'm okay with that.)
            for m in memberships:
                if m.person == person and m.offering == tacrs.course:
                    break
            else:
                # there was no membership: create
                m = Member(person=person, offering=tacrs.course)
                memberships.append(m)

            m.role = 'TA'
            m.credits = 0
            m.career = 'NONS'
            m.added_reason = reason
            m.config['bu'] = str(tacrs.total_bu)
Example #4
0
        def add_membership_for(tacrs, reason, memberships):
            if not tacrs.contract.should_be_added_to_the_course or tacrs.total_bu <= 0:
                return

            # Find existing membership for this person+offering if it exists
            # (Behaviour here implies you can't be both TA and other role in one offering: I'm okay with that.)
            for m in memberships:
                if m.person == person and m.offering == tacrs.course:
                    break
            else:
                # there was no membership: create
                m = Member(person=person, offering=tacrs.course)
                memberships.append(m)

            m.role = 'TA'
            m.credits = 0
            m.career = 'NONS'
            m.added_reason = reason
            m.config['bu'] = str(tacrs.total_bu)