Exemplo n.º 1
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.º 2
0
 def __post_init__(self):
     self.item = Item.get_by_id(self.item_id)
     self.user = User.find_by_email(self.user_email)