本文整理匯總了Python中coredata.models.Member.credits方法的典型用法代碼示例。如果您正苦於以下問題:Python Member.credits方法的具體用法?Python Member.credits怎麽用?Python Member.credits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類coredata.models.Member
的用法示例。
在下文中一共展示了Member.credits方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ensure_member
# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import credits [as 別名]
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
示例2: add_membership_for
# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import credits [as 別名]
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)