예제 #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)