本文整理汇总了Python中enroll.models.Student类的典型用法代码示例。如果您正苦于以下问题:Python Student类的具体用法?Python Student怎么用?Python Student使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Student类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm_pair
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: show_pair
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 }))
示例3: course_backup
def course_backup(request):
logging.info(request.POST)
course_id = request.POST['course_id']
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
logging.info('course=%s'%course)
student_list_to_enroll=Student.list_for_course_to_enroll(course.key())
student_list_enrolled=Student.list_for_course_enrolled(course.key())
if course.group_mode == 'Single':
student_list_to_enroll = sort_students_spare_single(student_list_to_enroll)
student_list_enrolled = sort_students_single(student_list_enrolled)
elif course.group_mode == 'School':
student_list_to_enroll = sort_students_spare_school(student_list_to_enroll)
student_list_enrolled = sort_students_school(student_list_enrolled)
elif course.group_mode == 'Pair':
student_list_to_enroll = sort_students_spare_pair(student_list_to_enroll)
student_list_enrolled = sort_students_pair(student_list_enrolled)
students = []
students.extend(student_list_enrolled)
students.extend(student_list_to_enroll)
data = [ ['#zaloha kurz',course.code,course.folder_name(),course.season_name()]]
for s in students:
if not s.x_pair_empty_slot:
data.append(s.as_csv_row())
out = cStringIO.StringIO()
dump_to_csv(data,out)
# logging.info(out)
cb = CourseBackup()
cb.init(out.getvalue(),course=course)
cb.save()
course.mark_as_backup()
course.save()
if cfg.getConfigBool('BACKUP_EMAIL_ON',False):
taskqueue.add(url='/task/send_backup/', params={'coursebackup_id':cb.key().id()})
logging.info('send task plan ok, cbid=%s'%(cb.key().id()))
else:
logging.info('BACKUP_EMAIL_ON is OFF!')
return HttpResponse('ok')
示例4: manual_confirm
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}),
)
示例5: _obs_send_enroll_no_email
def _obs_send_enroll_no_email(request):
logging.info(request.POST)
student_id = request.POST['student_id']
student = Student.get_by_id(int(student_id))
if student is None:
raise Http404
course = student.get_course()
(subject,body) = mail.prepare_enroll_no_email_text(student,course)
sender = cfg.getConfigString('ENROLL_EMAIL',None)
if sender is None:
logging.info('no sender, skip')
return HttpResponse('ok')
recipient = student.email.__str__()
logging.info('sending from "%s", to "%s", subject "%s", body "%s"'%(sender,recipient,subject,body))
gmail.send_mail(sender, recipient, subject,body)
logging.info('send ok')
return HttpResponse('ok')
示例6: show
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 }))
示例7: confirm
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 }))
示例8: hide_student
def hide_student(owner, student_id):
student = Student.get_by_id(int(student_id))
if student is None:
return
student.hidden = True
student.save()
cdbsync.plan_cdb_put(student)
示例9: mark_cardout
def mark_cardout(owner, student_id):
student = Student.get_by_id(int(student_id))
if student is None:
return
student.card_out=True
student.save()
cdbsync.plan_cdb_put(student)
示例10: prepare_card
def prepare_card(owner, student_id, season_name, course_code, info_line_1, info_line_2):
student = Student.get_by_id(int(student_id))
if student is None:
return
card = Card()
card.init(owner=owner,name=student.name, surname=student.surname, season_name=season_name, course_code=course_code, info_line_1=info_line_1, info_line_2=info_line_2)
card.save()
logging.info('card=%s'%card)
示例11: send_enroll_form_to_admin
def send_enroll_form_to_admin(request,test_id=None):
logging.info(request.POST)
if not cfg.getConfigBool('ENROLL_FORM_EMAIL_ON',False):
logging.info('ENROLL_FORM_EMAIL_ON is OFF!')
return HttpResponse('ok - disabled')
if test_id is None:
student_id = request.POST['student_id']
else:
student_id = test_id
student = Student.get_by_id(int(student_id))
if student is None:
raise Http404
logging.info('student=%s'%student)
course = student.get_course()
partner = student.get_partner()
logging.info('course=%s'%(course))
sender = cfg.getConfigString('ENROLL_FORM_EMAIL_SENDER',None)
to = cfg.getConfigString('ENROLL_FORM_EMAIL_TO',None)
if sender is None:
logging.info('no sender')
return HttpResponse('ok - no sender, ignore')
if to is None:
logging.info('no to')
return HttpResponse('ok - no to, ignore')
logging.info('prepare text')
(subject,body) = mail.prepare_email_text('ENROLL_FORM_REPORT', student,course,partner)
logging.info('prepare text done')
# subject = "online prihlaska" #cfg.getConfigString('ENROLL_FORM_EMAIL_SUBJECT',None)
# body = "online prihlaska je v priloze" #cfg.getConfigString('ENROLL_FORM_EMAIL_SUBJECT',None)
filename = "prihlaska.pdf"
out = cStringIO.StringIO()
from utils.pdf import students_enroll
students_enroll(out,[student],with_partner=True)
data=out.getvalue()
gmail.send_mail(sender=sender, to=to,subject=subject,body=body,attachments=[(filename,data)])
logging.info('send ok')
return HttpResponse('ok')
示例12: clean_expired_enrolls
def clean_expired_enrolls(request):
now = datetime.datetime.utcnow()
exp_min = cfg.getConfigInt('ENROLL_CHECK_TIMEOUT_MINUTES',60)
td = datetime.timedelta(minutes=exp_min)
lim = now-td
list = Student.list_for_cleanup(lim).fetch(20)
for s in list:
rd = s.reg_datetime
logging.info('id: %s, rd:%s, now:%s, lim:%s'%(s.key().id(),rd,now,lim))
s.delete()
return HttpResponse('ok')
示例13: update_all_students_do_one
def update_all_students_do_one(request):
logging.info("update_all_students_do_one")
logging.info(request.POST)
student_key = request.POST["student_key"]
s = Student.get(student_key)
if s is None:
raise Http404
logging.info("update student %s"%s)
cdbsync.plan_cdb_put(s)
return HttpResponse('ok')
示例14: makecopy_student
def makecopy_student(student_id, course):
logging.info('makecopy student %d'%student_id)
student = Student.get_by_id(student_id)
if student is None:
return
new = student.clone()
logging.info('clone ok')
new.set_course_key(str(course.key()))
new.save()
cdbsync.plan_cdb_put(new)
return (student.ref_key,new)
示例15: course_fullsync
def course_fullsync(request):
logging.info(request.POST)
course_id = request.POST['course_id']
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
cdbsync.plan_cdb_put(course)
logging.info('course=%s'%course)
students = Student.list_for_course(course.key())
for s in students:
logging.info("student %s" % s.key())
cdbsync.plan_cdb_put(s)
logging.info("all done")
return HttpResponse('ok')