コード例 #1
0
def activate_alert(alert_id):
    alert = Alert.get_by_id(alert_id)
    status_update = alert.activate()
    # if it is reactivated - need to update also the price
    if status_update:
        alert.load_item_price()
    #redirect to the next entry point
    return redirect(url_for('users.user_alerts'))
コード例 #2
0
def delete_alert(alert_id):
    alert = Alert.get_by_id(alert_id)
    if alert.user_email == session['email']:
        alert.remove_from_mongo()
        flash(
            f"Alert for {alert.report.state_name} with threshold of {alert.case_limit} cases removed.",
            "danger")
    return redirect(url_for('.index'))
コード例 #3
0
def edit_alert(alert_id):
    alert = Alert.get_by_id(alert_id)
    if request.method == 'POST':
        alert.price_limit = float(request.form['price'])
        alert.save_to_db()
        return redirect(url_for('.get_alert_page', alert_id=alert_id))

    return render_template('alerts/edit_alert.jinja2', alert=alert)
コード例 #4
0
def plot_report(alert_id):
    alert = Alert.get_by_id(alert_id)
    report = alert.report
    fig = report.plot_historic()
    img = io.BytesIO()
    fig.savefig(img, format='png')
    img.seek(0)
    fig_url = base64.b64encode(img.getvalue()).decode()

    return render_template('image.html', image=fig_url, report=report)
コード例 #5
0
def edit_alert(alert_id):
    alert = Alert.get_by_id(uuid.UUID(alert_id))
    if request.method == 'POST':
        alert.price_limit = float(request.form['price_limit'])
        alert.do_price_check()  # saves to mongodb.
        return redirect(url_for('users.user_alerts'))

    return render_template(
        'alerts/edit_alert.jinja2',
        alert=alert)  # Send the user an error if invalid login
コード例 #6
0
def update_alert(alert_id):
    alert = Alert.get_by_id(alert_id)
    item = Item.get_by_id(alert.item._id)
    # in case we receive GET - this is the first time the page is opened
    # in case we receive  POST - we have the details
    if request.method == 'GET':
        return render_template('alerts/edit_alert.html', alert=alert)
    else:
        # get from the request the newly created alert details
        price_limit = float(request.form['price_limit'])

        alert.price_limit = price_limit
        alert.save_to_mongo()

        return redirect(url_for('users.user_alerts'))
コード例 #7
0
def edit_alert(alert_id):
    alert = Alert.get_by_id(alert_id)

    if request.method == 'POST':
        try:
            case_limit = int(request.form['case_limit'])
        except ValueError:
            flash(f"Case threshold must be an integer.", "warning")
            return render_template('edit_alert.html', alert=alert)

        alert.case_limit = case_limit
        if alert.user_email == session['email']:
            alert.save_to_mongo()
            alert.report.load_data()
            flash(
                f"Case threshold for {alert.report.state_name} updated to {case_limit}.",
                "success")
        return redirect(url_for('.index'))

    return render_template('edit_alert.html', alert=alert)
コード例 #8
0
def get_alert_page(alert_id):
    return render_template('alerts/alert.jinja2',
                           alert=Alert.get_by_id(alert_id))
コード例 #9
0
def check_price(alert_id):
    Alert.get_by_id(alert_id).load_item_price()
    return redirect(url_for('.get_alert_page', alert_id=alert_id))
コード例 #10
0
def activate_alert(alert_id):
    Alert.get_by_id(alert_id).activate()
    return redirect(url_for('.get_alert_page', alert_id=alert_id))
コード例 #11
0
def delete_alert(alert_id):
    Alert.get_by_id(alert_id).delete()
    return redirect(url_for('user.user_alerts'))
コード例 #12
0
def get_alert_page(alert_id):
    alert = Alert.get_by_id(uuid.UUID(alert_id))
    return render_template('alerts/alert.jinja2', alert=alert)
コード例 #13
0
def check_price(alert_id):
    Alert.get_by_id(uuid.UUID(alert_id)).do_price_check()
    return redirect(url_for('.get_alert_page', alert_id=alert_id))
コード例 #14
0
def delete_alert(alert_id):
    Alert.get_by_id(uuid.UUID(alert_id)).delete_from_db()
    return redirect(url_for('users.user_alerts'))
コード例 #15
0
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'))
コード例 #16
0
def get_alert_page(alert_id):
    alert = Alert.get_by_id(alert_id)
    return render_template('alerts/alert.html', alert=alert)
コード例 #17
0
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'))
コード例 #18
0
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))
コード例 #19
0
ファイル: views.py プロジェクト: dpw1/price-monitor
def activate_alert(alert_id):
    Alert.get_by_id(alert_id).activate()
    return redirect(url_for('users.user_monitors'))
コード例 #20
0
def activate_alert(alert_id):
    Alert.get_by_id(uuid.UUID(alert_id)).activate()
    return redirect(url_for('users.user_alerts'))