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 Sessioncancele(sessionId): session = Session.query.filter_by(session_id=int(sessionId)).one() seminar = Eventsystem.getSeminar(session) Eventsystem.remove_session_user(session, seminar) Eventsystem.remove_all_user(session) session.status = 'CANCELED' Eventsystem.add_session(session) return redirect(url_for('index'))