def addsession(SeminarId): seminar = Seminar.query.filter_by(seminar_id=int(SeminarId)).one() if request.method == 'POST': title = request.form['title'] start = request.form['start'] end = request.form['end'] fee = request.form['fee'] capacity = request.form['capacity'] detail = request.form['detail'] speaker = request.form['speaker'] early_period = request.form['early_period'] status = 'OPEN' try: Eventsystem.check_start(start) Eventsystem.check_data(start, end) Eventsystem.validate_capacity(seminar, capacity) Eventsystem.validate_period(start, end, early_period) Eventsystem.chcek_speaker(speaker) session = Session(title, detail, start, end, capacity, status, current_user.name, speaker, fee, early_period) Eventsystem.add_session(session) seminar.sessions.append(session) db.session.commit() return redirect(url_for('index')) except ErrorMessage as error: return render_template('postsession.html', val_post=True, post_info=error.msg) return render_template('postsession.html')
def post(): if request.method == 'POST': title = request.form['title'] start = request.form['start'] end = request.form['end'] fee = request.form['fee'] capacity = request.form['capacity'] detail = request.form['detail'] status = 'OPEN' early_period = request.form['early_period'] try: Eventsystem.check_start(start) Eventsystem.check_data(start, end) Eventsystem.valida_seminar_capa(capacity) Eventsystem.validate_period(start, end, early_period) event = Eventsystem.make_course(title, detail, start, end, capacity, status, current_user.name, fee, early_period) Eventsystem.add_course(event) return redirect(url_for('index')) except ErrorMessage as error: return render_template('post.html', val_post=True, post_info=error.msg) return render_template('post.html')
def postSeminar(): if request.method == 'POST': title = request.form['title'] start = request.form['start'] end = request.form['end'] capacity = request.form['capacity'] detail = request.form['detail'] status = 'OPEN' try: Eventsystem.check_start(start) Eventsystem.check_data(start, end) Eventsystem.valida_seminar_capa(capacity) seminar = Eventsystem.make_seminar(title, detail, start, end, capacity, status, current_user.name) Eventsystem.add_seminar(seminar) return redirect(url_for('index')) except ErrorMessage as error: return render_template('postseminar.html', val_post=True, post_info=error.msg) return render_template('postseminar.html')
def test_validate_start(self): print('test_validate_start') try: Eventsystem.check_start('01-01-2018') except ErrorMessage as error: assert error.msg == 'Please enter start date before today'