Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route('/newevent', methods=['GET', 'POST']) #TAGGED
- @login_required
- def newevent():
- form = NewEvent()
- msgs = ''
- if request.method=='POST' and form.validate_on_submit():
- check = Event.query.filter_by(eventid=form.eventid.data).first()
- if check is None:
- db.session.add(Event(eventid=form.eventid.data, eventName=form.eventName.data, eventDate=form.eventDate.data, allocation=form.allocation.data, Event_orgCode=current_user.orgCode))
- db.session.commit()
- return redirect(url_for('adminevents'))
- elif check.eventid == form.eventid.data:
- msgs = 'Event already exists!'
- return render_template('events_new.html', form=form, msgs=msgs)
- return render_template('events_new.html', form=form, msgs=msgs)
- {% block content %}
- {% with msg = get_flashed_messages() %}
- <h1>Create New Event</h1>
- <h3> {{ msgs }} </h3>
- <div class="input-event">
- <form class="form form-horizontal" action="{{ url_for('newevent') }}" method="POST" role="form">
- <dl>
- {{ form.hidden_tag() }}
- {{ form.csrf_token }}
- {{ wtf.form_field(form.eventid, placeholder="Pick a 4-digit ID e.g., 0042") }}
- {{ wtf.form_field(form.eventName, placeholder="Name your event") }}
- {{ wtf.form_field(form.eventDate) }}
- {{ wtf.form_field(form.allocation, placeholder="Enter budget allocation") }}
- </dl>
- <input class="btn btn-success" type="submit" value="Add">
- <input class="btn btn-primary" type="button" value="Back" onclick="window.location.href='/adminevents'">
- </form>
- </div>
- {% endwith %}
- {% endblock %}
Add Comment
Please, Sign In to add comment