コード例 #1
0
def home():
    if current_user.is_authenticated:
        logged_in = 1
        username=current_user.username
    else:
        logged_in = 0
        username=None
    return _render_template('main/main.html', logged_in=logged_in, username=username)
コード例 #2
0
ファイル: routes.py プロジェクト: kkl116/Stonks
def search_redirect(q):
    q = q.strip().upper()
    price_chart_json = get_hist_vol_json(q)
    dropdowns = get_dropdown_items()
    return _render_template('searches/main.html',
                            q=q,
                            price_chart_json=price_chart_json,
                            dropdowns=dropdowns)
コード例 #3
0
def settings():
    #settings should include ability to change password, change username, change email, alert settings, and change default currency
    changePasswordForm = ChangePasswordForm()
    changeEmailForm = ChangeEmailForm()
    changeUsernameForm = ChangeUsernameForm()
    changeSettingsForm = ChangeSettingsForm()
    changeSettingsForm.currency.data = current_user.currency

    return _render_template('accounts/settings.html',
                            changePasswordForm=changePasswordForm,
                            changeEmailForm=changeEmailForm,
                            changeUsernameForm=changeUsernameForm,
                            changeSettingsForm=changeSettingsForm)
コード例 #4
0
def email_verification(token):
    if current_user.is_authenticated:
        return redirect(url_for('main.home'))

    user = User.verify_token(token, timed=False)
    if user is None:
        flash('The token is invalid.', 'warning')
        return redirect_next_page()
    #submit user details to db
    user.verified = True
    db.session.commit()
    #make a account activated page
    return _render_template('accounts/account_activated.html')
コード例 #5
0
ファイル: routes.py プロジェクト: kkl116/Stonks
def search():
    q = request.args.get('q')
    if q:
        q = q.strip().upper()
        #put in a check here to check that stock is valid and time check (if premarket/afterhours redirect to somewhere else)
        if check_ticker_exists(q):
            #SSE
            try:
                price_chart_json = get_hist_vol_json(q)
                dropdowns = get_dropdown_items()
                return _render_template('searches/main.html',
                                        q=q,
                                        price_chart_json=price_chart_json,
                                        dropdowns=dropdowns)
            except Exception as e:
                return error_500_response(e)
        else:
            pass
    return redirect_next_page()
コード例 #6
0
def reset_password(token):
    if current_user.is_authenticated:
        return redirect(url_for('main.home'))
    user = User.verify_token(token, timed=True)
    if user is None:
        flash('The token is invalid or has expired.', 'warning')
        return redirect_next_page()

    reset_password_form = ResetPasswordForm()
    if request.method == "POST":
        if reset_password_form.validate_on_submit():
            print('reset form submitted')
            hashed_password = bcrypt.generate_password_hash(
                reset_password_form.password.data).decode('utf-8')
            user.password = hashed_password
            db.session.commit()
            flash('Password has been updated!', 'success')
            #redirect does not work with ajax, so instead return json then use js to switch url
            return redirect_json(route="main.home")
        else:
            return form_errors_400(reset_password_form)
    return _render_template('accounts/reset_password.html')
コード例 #7
0
ファイル: handlers.py プロジェクト: kkl116/Stonks
def error_404(e):
    """functions as an error handler for 404"""
    return _render_template('errors/404.html')
コード例 #8
0
ファイル: handlers.py プロジェクト: kkl116/Stonks
def error_500():
    """functions primarily as a ROUTE that js redirects to when 500 status code encountered"""
    return _render_template('errors/500.html')
コード例 #9
0
def require_login():
    return _render_template('accounts/require_login.html')
コード例 #10
0
def main():
    return _render_template('alerts/main.html')
コード例 #11
0
ファイル: routes.py プロジェクト: kkl116/Stonks
def main():
    order_form = OrderForm()
    return _render_template('portfolio/main.html', order_form=order_form)
コード例 #12
0
def main():
    add_form = AddForm()
    return _render_template('watchlist/main.html', add_form=add_form)