本文整理匯總了Python中enroll.models.Student.get_by_confirm_key方法的典型用法代碼示例。如果您正苦於以下問題:Python Student.get_by_confirm_key方法的具體用法?Python Student.get_by_confirm_key怎麽用?Python Student.get_by_confirm_key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類enroll.models.Student
的用法示例。
在下文中一共展示了Student.get_by_confirm_key方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: confirm_pair
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_confirm_key [as 別名]
def confirm_pair(request,confirm_code1,confirm_code2):
student1 = Student.get_by_confirm_key(confirm_code1)
if student1:
course = Course.get(student1.course_key)
else:
course = None
student2 = Student.get_by_confirm_key(confirm_code2)
if (student1 is None) or (student2 is None) or (course is None):
status = False
else:
status = True
if status:
if student1.status == 'n':
if course.can_enroll():
student1.status = 'e'
student1.init_enroll()
student1.save()
plan_send_student_email('ENROLL_OK_PAY_REQUEST',student1)
else:
student1.status = 's'
student1.save()
plan_send_student_email('ENROLL_OK_SPARE',student1)
plan_send_enroll_form(student1)
status1 = True
elif not student1.status in ['e','s']:
status1 = False
else:
status1 = True
if student2.status == 'n':
if course.can_enroll():
student2.status = 'e'
student2.init_enroll()
student2.save()
plan_send_student_email('ENROLL_OK_PAY_REQUEST',student2)
else:
student2.status = 's'
student2.save()
plan_send_student_email('ENROLL_OK_SPARE',student2)
plan_send_enroll_form(student2)
status2 = True
elif not student2.status in ['e','s']:
status2 = False
else:
status2 = True
status = status1 or status2
if status:
plan_update_course(course)
return render_to_response('enroll/confirm_pair.html', RequestContext(request, { 'course': course, 'student1':student1, 'student2':student2, 'confirm_code1':confirm_code1, 'confirm_code2':confirm_code2 , 'status':status }))
示例2: confirm
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_confirm_key [as 別名]
def confirm(request,confirm_code):
student = Student.get_by_confirm_key(confirm_code)
if student:
course = Course.get(student.course_key)
else:
course = None
if (student is None) or (course is None):
status = False
else:
status = True
if status:
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)
else:
student.status = 's'
student.save()
plan_send_student_email('ENROLL_OK_SPARE',student)
plan_send_enroll_form(student)
plan_update_course(course)
elif not student.status in ['e','s']:
status = False
return render_to_response('enroll/confirm.html', RequestContext(request, { 'course': course, 'student':student, 'confirm_code':confirm_code, 'status':status }))
示例3: manual_confirm
# 需要導入模塊: from enroll.models import Student [as 別名]
# 或者: from enroll.models.Student import get_by_confirm_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}),
)