Ejemplo n.º 1
0
def edit_alert(alert_id):
    if request.method == 'POST':
        price_limit = float(request.form['price_limit'])

        alert = Alert.find_by_id(alert_id)
        alert.price_limit = price_limit
        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/edit_alert.html", alert=Alert.find_by_id(alert_id))  # Send the user an error if their login was invalid
Ejemplo n.º 2
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")
Ejemplo n.º 3
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")
Ejemplo n.º 4
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
Ejemplo 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')
Ejemplo n.º 6
0
def edit_alert(alert_id):
    alert = Alert.find_by_id(alert_id)
    if request.method == "POST":
        price_limit = float(request.form['price_limit'])
        alert.price_limit = price_limit
        alert.save_to_mongo()
        return redirect(url_for("user.user_alerts"))
    return render_template("alerts/edit_alert.html", alert=alert)
Ejemplo n.º 7
0
def edit_alert(alert_id):
    alert = Alert.find_by_id(alert_id)
    if request.method == 'POST':
        price_limit = float(request.form['price_limit'])

        alert.price_limit = price_limit
        alert.save_to_mongo()
        return redirect(url_for('users.user_alerts'))
    return render_template('alerts/edit_alert.html', alert=alert)
Ejemplo n.º 8
0
def create_alert():
    if request.method == 'POST':
        name = request.form['name']
        url = request.form['url']
        price_limit = float(request.form['price_limit'])

        # print(name)
        # print(url)
        # print(price_limit)

        price_from_amazon = Alert.load_price(url)
        image_from_amazon = Alert.load_image(url)
        #graph_from_fakespot = Alert.crawl_fakespot(url)
        graph_from_fakespot = None
        # item = Item(name,url,price_limit)
        # item.save_to_mongo()
        # _id = item.get_id()
        #print(_id)
        alert = Alert(session['email'],
                      price_limit,
                      name,
                      url,
                      price_from_amazon,
                      image_from_amazon,
                      graph_from_fakespot,
                      active=True,
                      last_checked=None)
        alert.save_to_mongo()
        return redirect(url_for('users.user_alerts'))

    return render_template('alerts/new_alert.html')
Ejemplo n.º 9
0
 def get_alerts(self):
     return Alert.find_by_user_email(self.email)
Ejemplo n.º 10
0
def get_alert_page(alert_id):
    return render_template('alerts/alert.html',
                           alert=Alert.get_by_id(alert_id))
Ejemplo n.º 11
0
def activate_alert(alert_id):
    Alert.get_by_id(alert_id).activate()
    return redirect(url_for('users.user_alerts'))
Ejemplo n.º 12
0
def get_alert_page(alert_id):
    return render_template('alerts/alert.jinja2',
                           alert=Alert.find_by_id(alert_id))
Ejemplo n.º 13
0
def activate_alert(alert_id):
    Alert.find_by_id(alert_id).activate()
    return redirect(url_for('.activate_alert_success', alert_id=alert_id))
Ejemplo n.º 14
0
def delete_alert(alert_id):
    Alert.find_by_id(alert_id).delete()
    return redirect(url_for('.delete_alert_success', alert_id=alert_id))
Ejemplo n.º 15
0
def get_alert_page(alert_id):
    alert = Alert.find_by_id(alert_id)
    return render_template("alerts/alert.html", alert=alert)
Ejemplo n.º 16
0
def delete_alert(alert_id):
    Alert.find_by_id(alert_id).delete()
    return redirect(url_for('users.user_alerts'))
Ejemplo n.º 17
0
def activate_alert_success(alert_id):
    alert = Alert.find_by_id(alert_id)
    return render_template('alerts/activate_alert_success.html.j2', alert=alert)
Ejemplo n.º 18
0
from models.alerts.alert import Alert
from common.database import Database

Database.initialize()

alert_needing_update = Alert.find_needing_update()

for alert in alert_needing_update:
    alert.load_item_price()
    alert.send_email_if_price_reached()
Ejemplo n.º 19
0
 def get_alerts(self) -> List[Alert]:
     return Alert.find_by_user_email(self.email)
Ejemplo n.º 20
0
def delete_alert(alert_id):
    Alert.get_by_id(alert_id).remove_from_mongo()
    return redirect(url_for('users.user_alerts'))
Ejemplo n.º 21
0
def activate_alert(alert_id):
    alert = Alert.find_by_id(alert_id)
    alert.activate()
    return redirect(url_for('users.user_alerts'))
Ejemplo n.º 22
0
def check_alert_price(alert_id):
    Alert.get_by_id(alert_id).load_item_price()
    return redirect(url_for('.get_alert_page', alert_id=alert_id))
Ejemplo n.º 23
0
def check_alert_price(alert_id):
    alert = Alert.find_by_id(alert_id)
    alert.load_item_price()
    return redirect(url_for('users.user_alerts'))
Ejemplo n.º 24
0
from common.database import Database
from models.alerts.alert import Alert

Database.initialize()

alerts_needing_update = Alert.find_needing_update(10)

for alert in alerts_needing_update:
    alert.load_item_price()
    alert.send_email_if_price_reached()
Ejemplo n.º 25
0
def get_update_and_send_email():
    alerts_needing_update = Alert.find_needing_update()

    for alert in alerts_needing_update:
        alert.load_and_save_item_price()
        alert.send_email_if_price_reached()