def crypto_form_consumer(): form_data = request.form.to_dict() Alert.save_alert_to_db(form_data) print('***** NEW ALERT CREATED: ', form_data, "******") return json.dumps({ 'status': 'OK', 'coin': form_data['coin'], 'Alert Price': form_data['alert_price'], 'Alert Currency': form_data['alert_currency'] })
def home(check_now=None): geodata = GeoData.get_user_location() if geodata['status'] == 'success': Database.insert('user_locations', geodata) print("***** NEW USER FROM:", geodata['city'], 'in', geodata['country'], "*****") else: print('***** NEW USER: ADDRESS UNKOWN *****') if check_now: # For testing purposes. Manually checks for and send active alerts print(check_now) print('checking alerts manually') Alert.send_alerts() return render_template('layout.html')
def edit_alert(alert_id): alert = Alert.get_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('.index')) return render_template("alerts/edit_alert.html", alert=alert)
def new_alert(): if request.method == 'POST': alert_name = request.form['name'] item_url = request.form['item_url'] price_limit = float(request.form['price_limit']) store = Store.find_by_url(item_url) item = Item(item_url, store.tag_name, store.query) item.load_price() item.save_to_mongo() Alert(alert_name, item._id, price_limit, session['email']).save_to_mongo() return render_template('alerts/new_alert.html')
from src.models.alert import Alert from dotenv import load_dotenv load_dotenv() alerts = Alert.all() for alert in alerts: alert.load_item_price() alert.notify_if_price_reached() alert.json() if not alerts: print("No alerts have been created. Add an item and an alert to begin!")
def delete_alert(alert_id): alert = Alert.get_by_id(alert_id) if alert.user_email == session['email']: alert.remove_from_mongo() return redirect(url_for('.index'))
def index(): alerts = Alert.find_many_by('user_email', session['email']) return render_template('alerts/index.html', alerts=alerts)
from src.models.alert import Alert if __name__ == '__main__': print("running from heroku scheduler") Alert.send_alerts()