def attraction_report(attraction_id): if not auth.is_logged_in(session): return redirect_to_login(STRINGS['SIGNED_OUT']) if not auth.is_admin(session): return redirect_to_home(STRINGS['NOT_AUTHORIZED']) show_date = request.args.get('date', str(dt.datetime.now())[:10]) try: time_slots = attraction.get_time_slots(attraction_id) show_time_slot = int( request.args.get('ts', time_slots[0]['time_slot_id'])) app.logger.debug(time_slots[0]['time_slot_id']) return render_template( "attractions/attraction_report.html", session=session, attraction=attraction.get_attraction(attraction_id), requires_reservation=attraction.requires_reservation( attraction_id), reservations=attraction.get_bookings(attraction_id, show_date, show_time_slot), date=show_date, time_slots=time_slots, selected_ts=attraction.get_time_slot(show_time_slot)) except IndexError: return render_template( "attractions/attraction_report.html", session=session, attraction=attraction.get_attraction(attraction_id), requires_reservation=attraction.requires_reservation( attraction_id))
def review_attraction(attraction_id): if not auth.is_logged_in(session): return redirect_to_login(STRINGS['SIGNED_OUT']) if request.method == 'POST': review = request.form['review'] title = request.form['title'] review_created = dt.datetime.now() user_id = session['user_id'] attraction_id = attraction_id attraction.create_review(title, review, review_created, user_id, attraction_id) flash("Review created successfully", category="success") return redirect(url_for('home')) return render_template("attractions/review.html", session=session, attr=attraction.get_attraction(attraction_id))
def edit_attraction(attraction_id): if not auth.is_logged_in(session): return redirect_to_login(STRINGS['SIGNED_OUT']) if not auth.is_admin(session): return redirect_to_home(STRINGS['NOT_AUTHORIZED']) if request.method == 'POST': name = request.form["name"] description = request.form["description"] price = request.form["price"] if request.form["street_num"] == "": street_num = None else: street_num = request.form["street_num"] street = request.form["street"] city = request.form["city"] if request.form["state"] == "": state = None else: state = request.form["state"] zip = request.form["zip"] country = request.form["country"] if request.form["transit"] == "": transit = None else: transit = request.form["transit"] attraction.edit_attraction(attraction_id, name, description, price, street_num, street, city, state, zip, country, transit) flash("Attraction edited successfully", category="success") return redirect(url_for('admin')) return render_template("attractions/attraction.html", session=session, attraction=attraction.get_attraction(attraction_id))
def attraction_reviews(attr_id): return render_template("attractions/attr_reviews.html", attr=attraction.get_attraction(attr_id), reviews=attraction.get_reviews(attr_id))