Exemplo n.º 1
0
def create_alert():
    if request.method == "POST":
        name = request.form['name']
        url = request.form['url']
        price_limit = float(request.form['price_limit'])

        item = Item(name, url)
        item.save_to_mongo()
        alert = Alert(session['email'], price_limit, item._id)
        alert.load_item_price()
    return render_template("alerts/new_alert.html")
Exemplo n.º 2
0
def create_alert():
    if request.method == "POST":
        item_name = request.form['item_name']
        item_url = request.form['item_url']
        price_limit = request.form['price_limit']
        item = Item(str(item_name), str(item_url))
        item.save_to_mongo()
        alert = Alert(session['email'], price_limit, item._id)
        alert.load_item_price()  # this is already saving to mongodb
        return redirect(url_for('user.user_alerts'))
    return render_template("alerts/create_alert.html")
Exemplo n.º 3
0
def create_alert():
    if request.method == 'POST':
        name = request.form['name']
        url = request.form['url']
        price_limit = float(request.form['price_limit'])

        item = Item(name, url)
        item.save_to_mongo()

        alert = Alert(session['email'], price_limit, item._id)
        alert.load_item_price()  # This already saves to MongoDB
        return redirect(url_for("users.user_alerts"))

    # What happens if it's a GET request
    return render_template("alerts/new_alert.html")  # Send the user an error if their login was invalid
Exemplo n.º 4
0
 def __init__(self, user_email, price_limit, item_id, active=True, last_checked=None, _id=None):
     self.user_email = user_email
     self.price_limit = price_limit
     self.active = active
     self.item = Item.get_by_id(item_id)
     self.last_checked = datetime.datetime.utcnow() if last_checked is None else last_checked
     self._id = uuid.uuid4().hex if _id is None else _id
Exemplo n.º 5
0
def new_alert():
    if request.method == 'POST':
        name = request.form['name']
        url = request.form['url']
        price_limit = float(request.form['price_limit'])

        item = Item(name, url)

        item.save_to_mongo()

        alert = Alert(session['email'], price_limit, item._id)
        alert.load_and_save_item_price()

        return redirect(url_for('.new_alert_success'))

    return render_template('alerts/new_alert.html.j2')
Exemplo n.º 6
0
 def __post_init__(self):
     self.item = Item.get_by_id(self.item_id)