Exemplo n.º 1
0
def delete_alert(alert_id):

    # Remove alert from database
    Alert.get_by_id(alert_id).remove_from_mongo()

    # Redirect to alerts home page
    return redirect(url_for('.index'))
Exemplo n.º 2
0
def edit_alert(alert_id):
    if request.method == 'POST':
        price_limit = float(request.form['price_limit'])

        alert = Alert.get_by_id(alert_id)
        alert.price_limit = price_limit
        alert.save_to_mongo()

        return redirect(url_for('.index'))

    return render_template("alerts/edit_alert.html",
                           alert=Alert.get_by_id(alert_id))
Exemplo n.º 3
0
def edit_alert(alert_id):

    # Get the alert information from the database (alert_id part of GET request)
    alert = Alert.get_by_id(alert_id)
    item = Item.get_by_id(alert.item_id)

    # POST method is used once changes have been made on the edit alert form
    # After saving the updated alert, the user is forwarded back to alerts home '/'
    if request.method == 'POST':
        price_limit = float(request.form['price_limit'])
        alert.price_limit = price_limit
        alert.save_to_mongo()
        return redirect(url_for('.index'))

    # Where GET request only, user is directed to the edit alert page
    return render_template('alerts/edit_alert.html', alert=alert)
Exemplo n.º 4
0
def delete_alert(alert_id):
    alert = Alert.get_by_id(alert_id)
    if alert.user_email == session["email"]:
        alert.remove_from_mongo()
    return redirect(url_for('.index'))