Example #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

    # What happens if it's a GET request
    return render_template("alerts/edit_alert.jinja2", alert=Alert.find_by_id(alert_id))  # Send the user an error if their login was invalid
Example #2
0
def create_alert():
    if request.method == 'POST':
        name = request.form['name']
        url = request.form['url']
        price_limit = float(request.form['price'])
        item = Item(name, url)
        item.save_to_mongo()
        alert = Alert(session['email'], price_limit, item._id)
        alert.load_item_price()

    return render_template('alerts/create_alert.html')
Example #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

    # What happens if it's a GET request
    return render_template("alerts/new_alert.jinja2")  # Send the user an error if their login was invalid
Example #4
0
def create_alert():
    if request.method == 'POST':
        name = request.form['name']
        url = request.form['url']
        price_limit = float(request.form['price_limit'])

        # el constructor de Alert busca el item por id asi que el item tiene que existir antes de ccrear la alert

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

        alert = Alert(session['email'], price_limit, item._id)
        alert.load_item_price() #ya salva la alert a mongo

    return render_template('alerts/new_alert.html')
Example #5
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)
Example #6
0
def create_alert():
    if request.method == 'POST':
        name = request.form['name']
        url = request.form['url']
        price_limit = float(request.form['price-limit'])

        # create an item first
        item = Item(name, url)
        item.save_to_mongo()

        # now create an alert to this item
        alert = Alert(session['email'], price_limit, item._id)
        alert.load_item_price() # this already saves to MongoDB

        # return redirect(url_for('user_alerts'))

    # What happens if it's a GET request
    return render_template('/alerts/new_alert.html')
Example #7
0
def index():
    alerts = Alert.find_many_by('user_email', session['email'])
    for alert in alerts:
        alert.report.load_data()
    return render_template('alerts_index.html', alerts=alerts)
Example #8
0
 def get_alerts(self):
     return Alert.find_by_user_email(self.email)
Example #9
0
from src.common.database import Database
from src.models.alerts.alert import Alert

Database.initialize()
alerts_needing_update = Alert.find_last_upadate()
for alert in alerts_needing_update:
    alert.load_item_price()
    alert.send_email_price_reached()
Example #10
0
 def run(self):
     Database.initialize()
     while Alert.find_by_id(self.alert_id).active == True:
         Alert.turn_email_notification_on(self.alert_id)
Example #11
0
def get_alert_page(alert_id):
    alert = Alert.find_by_id(alert_id)
    return render_template('alerts/alert.html', alert=alert)
Example #12
0
def get_alert_page(alert_id):
    alert = Alert.find_by_id(alert_id)
    store = Store.find_by_url(alert.item.url)
    return render_template('alerts/alert.html', alert=alert, store=store)
Example #13
0
 def get_alerts(self):
     return Alert.find_by_user_email(self.email)
Example #14
0
from src.common.database import Database
from src.models.alerts.alert import Alert

Database.initialize()

alert_needing_update = Alert.find_needing_updates()

for alert in alert_needing_update:
    alert.load_item_price()
    alert.send_email_if_price_reached()
Example #15
0
def delete_alert(alert_id):
    Alert.find_by_id(alert_id).delete()
    return redirect(url_for('users.user_alerts'))
def deactivate_alert(alert_id):
    alert = Alert.get_by_id(alert_id)
    alert.deactivate()
    #redirect to the next entry point
    return redirect(url_for('users.user_alerts'))
Example #17
0
from src.common.database import Database
from src.models.alerts.alert import Alert


Database.initialize()

finding_need_alert = Alert.find_update_alert()

for alert in finding_need_alert:
    alert.load_item_price()
    alert.send_email_if_price_reached()
def index():
    alerts = Alert.get_alerts()
    return render_template('alerts/alert_index.html', alerts=alerts)
Example #19
0
def activate_alert(alert_id):
    Alert.find_by_id(alert_id).activate()
    return redirect(url_for('users.user_alerts'))
Example #20
0
def index():
    alerts = Alert.find_many_by('user_email', session['email'])
    return render_template('alerts_index.html', alerts=alerts)
Example #21
0
def get_alert_page(alert_id):
    return render_template('alerts/alert.jinja2', alert=Alert.find_by_id(alert_id))
Example #22
0
def get_alert_page(alert_id):
    alert = Alert.find_by_id(alert_id)
    return render_template('/alerts/alert.html', alert=alert)
def check_alert_price(alert_id):
    alert = Alert.get_by_id(alert_id)
    alert.load_item_price()
    # we have end entry point that present the item and we need to redirect to it
    # pay attentuion that this method is in current view - therefore it start with '.'
    return redirect(url_for('.get_alert_page', alert_id=alert._id))
Example #24
0
def deactivate_alert(alert_id):
    Alert.find_by_id(alert_id).deactivate()
    return redirect(url_for('users.user_alerts', alert_id=alert_id))
Example #25
0
 def  get_alerts(self):
     return Alert.find_by_user_email(self.email) # llamo desde aca porque si no la view de user tiene que tratar con dos modelos distintos (user y alert) y no esta bien
def delete_alert(alert_id):
    alert = Alert.get_by_id(alert_id)
    alert.remove_from_mongo()
    #redirect to the next entry point
    return redirect(url_for('users.user_alerts'))
from src.common.database import Database
from src.models.alerts.alert import Alert

Database.initialize()

alerts_needing_update = Alert.find_needing_update()

# loop through the list of alerts that need update
for alert in alerts_needing_update:
    alert.load_item_price()
    alert.send_email_if_price_reached()

Example #28
0
def edit_alert(alert_id):
    alert = Alert.find_by_id(alert_id)
    price_limit = float(request.form['price_limit'])
    alert.price_limit = price_limit
    alert.save_to_mongo()
    return redirect(url_for('.get_alert_page', alert_id=alert_id))
Example #29
0
def activate_alert(alert_id):
    Alert.find_by_id(alert_id).activate()
    return redirect(url_for('users.user_alerts'))
Example #30
0
def delete_alert(alert_id):
    alert = Alert.find_by_id(alert_id).delete()
    return redirect(url_for('users.user_alerts'))
Example #31
0
def check_alert_price(alert_id):
    Alert.find_by_id(alert_id).load_item_price()
    return redirect((url_for('.get_alert_page', alert_id=alert_id)))
Example #32
0
def check_alert_price(alert_id):
    Alert.find_by_id(alert_id).load_item_price()
    return redirect(url_for('.get_alert_page', alert_id=alert_id))
from src.common.database import Database
from src.models.alerts.alert import Alert

__author__ = "Nupur Baghel"
Database.initialize()

alerts_needing_update=Alert.find_needing_update()

print(alerts_needing_update)

for alert in alerts_needing_update:
    alert.load_item_price()
    alert.send_email_if_price_is_reached()
Example #34
0
def get_alert_page(alert_id):
    return render_template('alerts/alert.jinja2',
                           alert=Alert.find_by_id(alert_id))