示例#1
0
 def test_validate_invalid_password(self, user):
     """Invalid password."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'Invalid password' in form.password.errors
示例#2
0
 def test_validate_success(self, user):
     """Login successful."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is True
     assert form.user == user
示例#3
0
 def test_validate_inactive_user(self, user):
     """Inactive user."""
     user.active = False
     user.set_password('example')
     user.save()
     # Correct username and password, but user is not activated
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'User not activated' in form.username.errors
示例#4
0
def about():
    """About page."""
    form = LoginForm(request.form)
    site_settings = current_app.config['SITE_SETTINGS']
    return render_template('public/about.html',
                           site_settings=site_settings,
                           login_form=form)
示例#5
0
    def render_error(error):
        """Render error template."""
        form = LoginForm(request.form)

        # If a HTTPException, pull the `code` attribute; default to 500
        error_code = getattr(error, 'code', 500)
        return render_template('{0}.html'.format(error_code),
                               login_form=form), error_code
示例#6
0
def dashboard():
    """Dashboard."""
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user)
            flash('You are logged in.', 'success')
            redirect_url = (request.args.get('next')
                            or url_for('dashboard.dashboard'))
            return redirect(redirect_url)
        else:
            flash_errors(form)
    players = Player.query.all()
    games = Game.query.all()
    return render_template('dashboard/dashboard.html',
                           login_form=form,
                           players=players,
                           games=games,
                           episode_stats=Game.episode_stats())
示例#7
0
def get_player(player_id):
    """Get game history and statistics for player."""
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user)
            flash('You are logged in.', 'success')
            redirect_url = request.args.get('next') or url_for('public.home')
            return redirect(redirect_url)
        else:
            flash_errors(form)

    player = Player.get_by_id(player_id)

    return render_template('dashboard/player.html',
                           player=player,
                           episode_stats=player.episode_stats(),
                           season_stats=player.season_stats(),
                           league_stats=player.league_stats(),
                           login_form=form)
示例#8
0
def about():
    """About page."""
    form = LoginForm(request.form)
    return render_template('public/about.html', login_form=form)
示例#9
0
 def test_validate_unknown_username(self, db):
     """Unknown username."""
     form = LoginForm(username='******', password='******')
     assert form.validate() is False
     assert 'Unknown username' in form.username.errors
     assert form.user is None