def event_details(event_id): event = ems.event_manager.get_event(event_id) if event is None: return redirect(url_for('page_not_found')) #no event found user = ems.check_email(current_user.email) if request.method == 'POST': try: if 'Cancel' in request.form: ems.cancel_event(user, event) except StatusChangingError as sce: return render_template('event_details.html', event=event, errors=sce.errors, form='POST') try: if 'Close' in request.form: ems.close_event(user, event) except StatusChangingError as sce: return render_template('event_details.html', event=event, errors=sce.errors, form='POST') try: if 'Purchase' in request.form: ems.purchase_event(user, event) fee = ems.event_price(event, user) purchase_msg = "This is free.".format(fee) return render_template('event_details.html', event=event, form='POST', purchase_msg=purchase_msg) except PurchasingError as pe: return render_template('event_details.html', event=event, errors=pe.errors, form='POST') try: if 'Register' in request.form: ems.register_course(user, event) except RegisterError as re: return render_template('event_details.html', event=event, errors=re.errors, form='POST') try: if 'Unregister' in request.form: ems.unregister_course(user, event) except RegisterError as re: return render_template('event_details.html', event=event, errors=re.errors, form='POST') if 'Cancel_creating' in request.form: return render_template('event_details.html', event=event, form='POST') if 'Add_session' in request.form: return render_template('event_details.html', event=event, creating=True, form='POST') #if 'Close_session' in request.form: # return render_template('event_details.html', event=event, form='POST') try: if 'Creating_confirm' in request.form: name = request.form['name'] detail = request.form['detail'] speaker = ems.check_email(request.form['email']) attendee_capacity = request.form['attendee_capacity'] ems.create_session(event, name, detail, speaker, attendee_capacity) return redirect(url_for('event_details', event_id=event_id)) except EventCreatingError as ece: return render_template('event_details.html', event=event, creating=True, form='POST', errors = ece.errors) return render_template('event_details.html', event=event, form='POST')
def create_event(): if request.method == 'POST': if 'create_seminar' in request.form: return render_template('create_event.html', type='Seminar', form='POST') if 'create_course' in request.form: return render_template('create_event.html', type='Course', form='POST') event_type = request.form['type'] name = request.form['name'] convener = ems.check_email(current_user.email) details = request.form['description'] loc = request.form['venue'] start_date = request.form['start_date'] end_date = request.form['end_date'] due_date = request.form['register_due_date'] early_bird = request.form['early_bird_date'] fee = request.form['registration_fee'] end_date = request.form['end_date'] due_date = request.form['register_due_date'] if event_type == 'Seminar': event_id = ems.create_seminar(name, convener, details, loc, start_date, end_date, register_due_date, early_bird, fee) if event_type == 'Course': attendee_capacity = request.form['attendee_capacity'] event_id = ems.create_course(name, convener, details, loc, start_date, end_date, due_date, early_bird, attendee_capacity, fee) return redirect(url_for('event_details', event_id=event_id)) return render_template('create_event.html', type='', form='POST')
def session_unregister_index(event_id, session_id): event = ems.event_manager.get_event(event_id) if event is None: return redirect(url_for('page_not_found')) user = ems.check_email(current_user.email) try: ems.unregister_s(user, event, session_id) except RegisterError as re: render_template('index.html', ems=ems, method='POST', errors=re.errors) return redirect(url_for('index', ems=ems))