예제 #1
0
def all_alerts():
    if 'email' in session:
        alerts = Alert.find_many_by('user_id', session['user_id'])
        for alert in alerts:
            alert.item.load_price()
        return render_template('alerts/all_alerts.html', alerts=alerts)
    return "Please sign in."
예제 #2
0
def index():
    """
    This endpoint shows all of a user's alerts from database
    :return: Alert index for the application
    """
    alerts = Alert.find_many_by('user_email', session['email'])

    return render_template('alerts/alert_index.html', alerts=alerts)
예제 #3
0
def index():
    print(session['email'])
    alerts = Alert.find_many_by('user_email', session['email'])
    for i in alerts:
        i.__post__init__()
    return render_template('alerts/index.html',
                           alerts=alerts,
                           current=session['email'])
예제 #4
0
def index():
    """
    show us a list of alerts and present a template with that data
    """
    # print(session['email']) # need restart app, or will get keyerror:email
    alerts = Alert.find_many_by('user_email', session['email'])  # go to database find all alerts that have a property
    return render_template('alerts/index.html',
                           alerts=alerts)  # alerts come from the endpoint which are loaded in database
예제 #5
0
def delete_alert(alert_id):
    alert = Alert.get_by_id(alert_id)
    alert.remove_from_mongo()
    alerts = Alert.find_many_by('user_email', session['email'])
    for i in alerts:
        i.__post__init__()
    return render_template("alerts/index.html",
                           alerts=alerts,
                           current=session['email'])
예제 #6
0
def index() -> Union[str, Response]:
    """
        Handles the RESTful INDEX route.

        Returns
        -------
        str
            The INDEX template.
        """
    alerts = Alert.find_many_by('user_email', session['email'])
    logger.debug(f"alerts: {alerts}")
    return render_template('alerts/index.html', alerts=alerts)
예제 #7
0
def edit_alert(alert_id):
    alert = Alert.find_many_by('user_email', session['email'])

    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'))

    # What happens if it's a GET request
    return render_template("alerts/edit_alert.html", alert=alert)
예제 #8
0
def new_alert():
    if request.method == 'POST':
        item_url = request.form['item_url']
        price_limit = float(request.form['price_limit'].strip())
        name = request.form['name']

        store = Store.find_by_url(item_url)

        item = Item(item_url, store.tag_name, store.query)
        item.load_price()
        item.save_to_mongo()

        Alert(item._id, name, price_limit, session['email']).save_to_mongo()
        alerts = Alert.find_many_by('user_email', session['email'])
        for i in alerts:
            i.__post__init__()
        return render_template("alerts/index.html",
                               alerts=alerts,
                               current=session['email'])
    return render_template("alerts/new_alert.html")
예제 #9
0
def index():
    alerts = Alert.find_many_by('user_email', session['email'])
    return render_template('alerts/index.html', alerts=alerts)
예제 #10
0
def index():
    print(session['email'])
    alerts = Alert.find_many_by('user_email', session['email'])
    return render_template("alerts/index.html", alerts=alerts)
예제 #11
0
def index():
    alerts = Alert.find_many_by("user_email", session["email"])
    return render_template("alerts/index.html", alerts=alerts)
예제 #12
0
def index():
    alerts = Alert.find_many_by(
        'user_email',
        session['email'])  # loading all items from mongodb to display on page
    return render_template('alerts/index.html', alerts=alerts)
예제 #13
0
def index():
    print(f"ALERT BP {session['rks_email']}")
    # alerts_present = Alert.all()
    alerts_present = Alert.find_many_by('user_email', session['rks_email'])
    return render_template('alerts/alert_index.html', alerts=alerts_present)
예제 #14
0
def index():
    # TODO remove the following line
    print(f"{session['email']}")
    alerts = Alert.find_many_by('user_email', session['email'])
    return render_template('alerts/index.html', alerts=alerts)
예제 #15
0
def index():
    alerts = Alert.find_many_by('user_email', session['email'])
    if len(alerts) == 0:
        flash("Click the 'Create new' button to make your first alert.",
              'info')
    return render_template('/alerts/index.html', alerts=alerts)
예제 #16
0
def show_all_alerts():
    print(session['email'])
    alerts = Alert.find_many_by('user_email', session['email'])
    for alert in alerts:
        print(alert)
    return render_template('alerts/index.html', alerts=alerts)