本文整理汇总了Python中enroll.models.Course.get方法的典型用法代码示例。如果您正苦于以下问题:Python Course.get方法的具体用法?Python Course.get怎么用?Python Course.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enroll.models.Course
的用法示例。
在下文中一共展示了Course.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get [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 }))
示例2: confirm_pair
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get [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 }))
示例3: show
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get [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 }))
示例4: show_pair
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get [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 }))
示例5: import_school
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get [as 别名]
def import_school(request,file_id):
f = FileBlob.get_by_id(int(file_id))
if f is None:
raise Http404
d = cStringIO.StringIO(f.data)
r = UnicodeReader(d,encoding='utf8', delimiter=',', quotechar='"')
form = None
course = None
season = None
cskey = request.session.get('course_season_key',None)
if not cskey is None:
season = Season.get(str(cskey))
folder = None
cfkey = request.session.get('course_folder_key',None)
if not cfkey is None:
folder = Folder.get(str(cfkey))
logging.info('cfkey %s cskey %s'%(cskey,cfkey))
logging.info('folder: %s'%folder)
logging.info('season: %s'%season)
if folder and season:
cc = Course.get_COURSE_FILTER_CHOICES(str(season.key()),str(folder.key()))
else:
cc = Course.get_COURSE_CHOICES()
logging.info('cc:%s'%cc)
if request.method == 'POST':
logging.info('meth post, filling form')
form = TargetPickForm2(request.POST,courses = cc)
if form.is_valid():
course = Course.get(form.cleaned_data['course_key'])
if course is None:
raise Http404
else:
logging.info('meth get, blank form')
form = TargetPickForm2(courses = cc)
selected = None
info = []
return render_to_response('admin/import_school.html', RequestContext(request, { 'info': info, 'form':form, 'course':course, 'season':season, 'folder':folder}))
示例6: manual_confirm
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get [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}),
)
示例7: import_students
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get [as 别名]
def import_students(request,file_id, seq_id=None):
f = FileBlob.get_by_id(int(file_id))
if f is None:
raise Http404
d = cStringIO.StringIO(f.data)
r = UnicodeReader(d)
form = None
course = None
season = None
cskey = request.session.get('course_season_key',None)
if not cskey is None:
season = Season.get(str(cskey))
folder = None
cfkey = request.session.get('course_folder_key',None)
if not cfkey is None:
folder = Folder.get(str(cfkey))
logging.info('cfkey %s cskey %s'%(cskey,cfkey))
logging.info('folder: %s'%folder)
logging.info('season: %s'%season)
if folder and season:
cc = Course.get_COURSE_FILTER_CHOICES(str(season.key()),str(folder.key()))
else:
cc = Course.get_COURSE_CHOICES()
logging.info('cc:%s'%cc)
if request.method == 'POST':
form = TargetPickForm(request.POST,courses = cc)
info = []
seq = 0
curr = None
line = 0
for row in r:
if len(row)>6 and (row[0].startswith('#export kurz') or row[0].startswith('#zaloha kurz')):
logging.info(row)
if not curr is None:
curr["end_line"]=line
info.append(curr)
curr = dict()
curr["seq"]=seq
seq+=1
curr["start_line"]=line+1
curr["code"]=row[1]
curr["folder"]=row[2]
curr["season"]=row[3]
curr["students"]=0
curr["info"]=row[6]
elif len(row)>19 and not row[0].startswith('#'):
curr["students"]+=1
line+=1
if not curr is None:
curr["end_line"]=line
info.append(curr)
else:
### no header detected.
curr = dict()
curr["seq"]=0
curr["start_line"]=0
curr["end_line"]=line
info.append(curr)
selected = None
if not seq_id is None:
for c in info:
if c["seq"]==int(seq_id):
selected = c
break
if selected is None:
raise Http404
if form is None:
form = TargetPickForm(courses = cc, initial={'start_line':selected['start_line'], 'end_line':selected['end_line']})
else:
if form.is_valid():
course = Course.get(form.cleaned_data['course_key'])
if course is None:
raise Http404
return render_to_response('admin/import_students.html', RequestContext(request, { 'info': info, 'form':form, 'selected':selected, 'course':course, 'season':season, 'folder':folder}))