本文整理匯總了Python中enroll.models.Student.get_by_ref_key方法的典型用法代碼示例。如果您正苦於以下問題:Python Student.get_by_ref_key方法的具體用法?Python Student.get_by_ref_key怎麽用?Python Student.get_by_ref_key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類enroll.models.Student
的用法示例。
在下文中一共展示了Student.get_by_ref_key方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: show_pair
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_ref_key [as 別名]
def show_pair(request,ref_code1, ref_code2):
student1 = Student.get_by_ref_key(ref_code1)
if student1:
course = Course.get(student1.course_key)
else:
course = None
student2 = Student.get_by_ref_key(ref_code2)
return render_to_response('enroll/show_pair.html', RequestContext(request, { 'course': course, 'student1':student1, 'ref_code1':ref_code1, 'student2':student2, 'ref_code2':ref_code2 }))
示例2: show
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_ref_key [as 別名]
def show(request,ref_code):
student = Student.get_by_ref_key(ref_code)
if student:
course = Course.get(student.course_key)
else:
course = None
return render_to_response('enroll/show.html', RequestContext(request, { 'course': course, 'student':student, 'ref_code':ref_code }))
示例3: manual_confirm
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_ref_key [as 別名]
def manual_confirm(request, ref_code=None):
info = ""
student = None
course = None
status = False
if request.method == "POST":
form = ConfirmForm(request.POST)
if form.is_valid():
ref_code = form.cleaned_data["ref_code"]
confirm_code = form.cleaned_data["confirm_code"]
student = Student.get_by_ref_key(ref_code)
if student is None:
student = Student.get_by_confirm_key(confirm_code)
if student is None:
info = "Přihláška nenalezena"
else:
course = Course.get(student.course_key)
if course is None:
info = "Přihláška obsahuje neplatný kurz"
else:
if student.status == "n":
if course.can_enroll():
student.status = "e"
student.init_enroll()
student.save()
plan_send_student_email("ENROLL_OK_PAY_REQUEST", student)
info = "Přihláška byla potvrzena a zařazena do kurzu"
else:
student.status = "s"
student.save()
plan_send_student_email("ENROLL_OK_SPARE", student)
info = "Přihláška byla potvrzena a zařazena do kurzu mezi náhradníky"
plan_send_enroll_form(student)
plan_update_course(course)
status = True
elif student.status in ["e", "s"]:
info = "Přihláška již byla potrzena"
else:
info = "Přihlášku již nelze potvrdit"
else:
if ref_code is None:
form = ConfirmForm()
else:
form = ConfirmForm({"ref_code": ref_code})
return render_to_response(
"admin/enroll_manual_confirm.html",
RequestContext(request, {"form": form, "student": student, "course": course, "status": status, "info": info}),
)