Esempio n. 1
0
def enroll():
    form = EnrollmentForm()
    if form.validate_on_submit():
        submission = form.data
        course = getattr(trainings, submission['course_name'])
        submission['course'] = {
            'name': course['name'],
            'title': course['title']
        }

        receipt = render_template('invoice.html', submission=submission)
        submission['receipt'] = receipt
        del submission['trainer_keyfile']
        timestamp = int(time.time())

        submission_path = os.path.join(get_submissions_path(app.root_path),
                                       str(timestamp) + '.pkl')
        with open(submission_path, 'wb') as pickleFile:
            cPickle.dump(submission, pickleFile, -1)
        return receipt

    return render_template('enroll.html',
                           courses=allcourses,
                           workshops=allworkshops,
                           form=form)
Esempio n. 2
0
File: app.py Progetto: miku/evreg
def enroll(event_id):
	user = logged_in_user_or_404()
	event = Event.query.get(event_id)
	form = EnrollmentForm()
	form.audit.query = Audit.query.filter(Audit.event==event)
	if form.validate_on_submit():
		enrollment = Enrollment()
		enrollment.user = user
		enrollment.user_id = user.id
		enrollment.audit = form.audit.data
		enrollment.audit_id = enrollment.audit.id
		enrollment.enrollment_date = datetime.datetime.now()
		
		subjects = []
		if form.subject_de.data:
			subjects.append('de')
		if form.subject_en.data:
			subjects.append('en')
		if form.subject_ru.data:
			subjects.append('ru')
		if form.subject_fr.data:
			subjects.append('fr')
		if form.subject_es.data:
			subjects.append('es')

		enrollment.subjects = json.dumps(subjects)
		
		if enrollment.audit.available_seats() <= 1:
			flash(u"Sie können sich für diese Prüfung nicht mehr anmelden, da das Maximum der Teilnehmeranzahl erreicht ist. Bitte wählen Sie einen anderen Termin.")
			enrollment = None
		else:
			db_session.add(enrollment)
			db_session.commit()
		return redirect(url_for('profile'))
	return render_template("enroll.html", **locals())
Esempio n. 3
0
def enroll():
    form = EnrollmentForm()
    if form.validate_on_submit():
        submission = form.data
        course = getattr(trainings, submission['course_name'])
        submission['course'] = {
            'name' : course['name'],
            'title': course['title']
        }

        receipt = render_template('invoice.html', submission=submission)
        submission['receipt'] = receipt
        del submission['trainer_keyfile']
        timestamp = int(time.time())

        submission_path = os.path.join (get_submissions_path(app.root_path),
                                        str(timestamp) + '.pkl')
        with open(submission_path , 'wb') as pickleFile:
            cPickle.dump (submission, pickleFile, -1)
        return receipt

    return render_template('enroll.html',
                           courses=allcourses,
                           workshops=allworkshops,
                           form=form)
Esempio n. 4
0
def studentEnrollment():
    form = EnrollmentForm()
    with sql.connect('courseSystem.db') as db:
        c = db.cursor()
    all_courses = """SELECT DISTINCT S.course_id, S.sec_no FROM Sections S"""
    c.execute(all_courses)
    courses = c.fetchall()
    form.course.choices = list(
        dict.fromkeys([(course[0], course[0]) for course in courses]))
    form.section.choices = list(
        dict.fromkeys([(course[1], course[1]) for course in courses]))
    if form.validate_on_submit():
        print('valid')
        enroll = """INSERT INTO Enrolls VALUES (?,?,?)"""
        c.execute(enroll,
                  (form.email.data, form.course.data, form.section.data))
        db.commit()
        c.close()

    return render_template('studentEnrollment.html',
                           form=form,
                           title='Enroll a student in a class')