コード例 #1
0
ファイル: scheduler.py プロジェクト: ChanChar/SteamScout
def send_game_alerts():
    user_preferences = Preferences.query.all()
    user_email = User.query.filter
    
    for user in User.query.all():
        user_id = user.id
        user_email = user.email
        user_validated = user.validated
        user_preferences = Preferences.query.filter_by(user_id=user_id)

        if user_preferences.first() and user_validated:
            game_alerts = []
            for preference in user_preferences:
                if not preference.notification_sent:
                    current_game_info = get_price_info(preference.game_id)
                    if preference.threshold_amount >= current_game_info["current_price"]/100.0:
                        game_alerts.append([preference.game_name, "${:.2f}".format(preference.threshold_amount)])
                        preference.notification_sent = True #
                        db.session.add(preference)
                        db.session.commit()
            if game_alerts:
                with app.app_context():
                    html = render_template("email/scout_alert.html", game_alerts=game_alerts)
                    subject = "Scout Report"
                    send_mail(user_email, subject, html)
    print "send_game_alerts() executed."
コード例 #2
0
ファイル: views.py プロジェクト: ChanChar/SteamScout
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        steam_email = app.config["MAIL_USERNAME"]
        html = render_template(
            "email/contact.html", message=form.message.data)
        subject = form.header.data
        send_mail(steam_email, subject, html, form.email.data, sender=form.email.data)
        flash("Message Sent!", "success")
        return redirect(url_for('games'))
    else:
        return render_template('contact.html', form=form)
コード例 #3
0
ファイル: views.py プロジェクト: ChanChar/SteamScout
def signup():
    form = SignUpForm(request.form)
    if request.method == 'POST' and form.validate():
        new_user = User(form.username.data.lower(), form.email.data, form.password.data)
        db.session.add(new_user)
        db.session.commit()

        token = generate_email_token(form.email.data)
        confirmation_url = url_for('.confirm_user', token=token, _external=True)
        html = render_template(
            "email/email_confirmation.html", confirmation_url=confirmation_url)
        subject = "Confirm your email"
        send_mail(new_user.email, subject, html)

        flash('We sent you an email to activate your account!', 'info')
        return redirect(url_for('login'))
    else:
        return render_template('signup.html', form=form)