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'))
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'))
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)
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)
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
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'))
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)
def get_alert_page(alert_id): return render_template('alerts/alert.jinja2', alert=Alert.get_by_id(alert_id))
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))
def activate_alert(alert_id): Alert.get_by_id(alert_id).activate() return redirect(url_for('.get_alert_page', alert_id=alert_id))
def delete_alert(alert_id): Alert.get_by_id(alert_id).delete() return redirect(url_for('user.user_alerts'))
def get_alert_page(alert_id): alert = Alert.get_by_id(uuid.UUID(alert_id)) return render_template('alerts/alert.jinja2', alert=alert)
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))
def delete_alert(alert_id): Alert.get_by_id(uuid.UUID(alert_id)).delete_from_db() 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'))
def get_alert_page(alert_id): alert = Alert.get_by_id(alert_id) return render_template('alerts/alert.html', alert=alert)
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'))
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))
def activate_alert(alert_id): Alert.get_by_id(alert_id).activate() return redirect(url_for('users.user_monitors'))
def activate_alert(alert_id): Alert.get_by_id(uuid.UUID(alert_id)).activate() return redirect(url_for('users.user_alerts'))