def event_confirmed():
"""Confirmation page after creating an event."""
# instantiating event and single attendees into our tables
date = request.form['date']
start_time = request.form['start_time']
end_time = request.form['end_time']
date_start_time = date + " " + start_time
date_end_time = date + " " + end_time
start_datetime = datetime.strptime(date_start_time, "%m/%d/%Y %H:%M")
end_datetime = datetime.strptime(date_end_time, "%m/%d/%Y %H:%M")
business_url = request.form['business_url']
business = get_specific_business(business_url)
# getting category id and business id to instantiate event
category_id = request.form['category_id']
business_id = business.id
# grabbing the current user info to instantiate our event.
user = User.query.filter_by(user_id=session['id']).first()
event = Event(start_time=start_datetime, end_time=end_datetime, category_id=category_id, business_id=business_id, user_id=user.user_id)
db.session.add(event)
db.session.commit()
event = get_specific_event(business_id)
event_id = event.id
# instantiating an attendee row so that it shows the creater is the owner/is attending. If there is a match, we can query through it later and two rows will show up by filtering the specific event_id. If not, only one attendee will appear and show the event is not matched.
attendee = Attendee(user_id=user.user_id, event_id=event_id, is_owner=True)
db.session.add(attendee)
db.session.commit()
return render_template("confirmation.html", event=event)
评论列表
文章目录