def post(self): form = CreateEventForm(data_to_multidict(request.json)) if form.validate(): admin = Admin.get_by_email(form.admin_email.data) if not admin: admin = form.create_admin() event = Event(name=form.name.data, admin=admin) event.save() return json_response(event.get_json_data(url_for)) else: return json_response(form.errors)
def index(): event_form = CreateEventForm(request.form) events = Event.query.all() if request.method == 'POST' and event_form.validate(): admin = Admin.get_by_email(event_form.admin_email.data) if not admin: admin = event_form.create_admin() event = Event(name=event_form.name.data, admin=admin) event.save() return redirect(url_for('event_details', slug=event.slug)) return render_template('index.html', **locals())
def post(self): form = CreateEventForm(data_to_multidict(request.json)) if form.validate(): admin = Admin.get_by_email(form.admin_email.data) if not admin: admin = form.create_admin() event = Event( name=form.name.data, admin=admin ) event.save() return json_response(event.get_json_data(url_for)) else: return json_response(form.errors)