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 }))
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 }))
def attend_single(request,course): captcha_error = None if request.method == 'POST': form = EnrollForm(request.POST) if form.is_valid(): check_ok = False if config.getConfigBool('CAPTCHA_ON',False): if captcha.check(request.POST['recaptcha_challenge_field'], request.POST['recaptcha_response_field'], os.environ['REMOTE_ADDR'], config.getConfigString('CAPTCHA_PRIVATE_KEY','')): check_ok = True else: captcha_error = True logging.info('captcha wrong') else: check_ok = True if check_ok: logging.info('creating new student record') st = form2student(form,course) ref_code = st.ref_key plan_send_student_email('ENROLL_CHECK',st) plan_update_course(course) return HttpResponseRedirect('/zapis/prihlaska/%s/'%ref_code) else: form = EnrollForm() if (config.getConfigBool('CAPTCHA_ON',False)): html_captcha = captcha.displayhtml(config.getConfigString('CAPTCHA_PUBLIC_KEY','')) else: html_captcha = None return render_to_response('enroll/attend.html', RequestContext(request, { 'course': course, 'form':form , 'html_captcha': html_captcha, 'captcha_error':captcha_error}))
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}), )
def attend_pair(request,course): captcha_error = None if request.method == 'POST': form1 = EnrollForm(request.POST,prefix='p1') form2 = EnrollForm(request.POST,prefix='p2') if form1.is_valid() and form2.is_valid(): check_ok = False if config.getConfigBool('CAPTCHA_ON',False): if captcha.check(request.POST['recaptcha_challenge_field'], request.POST['recaptcha_response_field'], os.environ['REMOTE_ADDR'], config.getConfigString('CAPTCHA_PRIVATE_KEY','')): check_ok = True else: captcha_error = True logging.info('captcha wrong') else: check_ok = True if check_ok: logging.info('creating new student record') st1 = form2student(form1,course) st2 = form2student(form2,course) st1.partner_ref_code = st2.ref_key st2.partner_ref_code = st1.ref_key st1.save() st2.save() ref_code1 = st1.ref_key ref_code2 = st2.ref_key plan_send_student_email('ENROLL_CHECK',st1) plan_send_student_email('ENROLL_CHECK',st2) plan_update_course(course) return HttpResponseRedirect('/zapis/prihlasky/%s/%s/'%(ref_code1,ref_code2)) else: form1 = EnrollForm(prefix='p1') form2 = EnrollForm(prefix='p2') if (config.getConfigBool('CAPTCHA_ON',False)): html_captcha = captcha.displayhtml(config.getConfigString('CAPTCHA_PUBLIC_KEY','')) else: html_captcha = None return render_to_response('enroll/attend_pair.html', RequestContext(request, { 'course': course, 'form1':form1, 'form2':form2 , 'html_captcha': html_captcha, 'captcha_error':captcha_error}))