Skip to content

Commit

Permalink
pep8 format
Browse files Browse the repository at this point in the history
  • Loading branch information
okhaliavka committed Jul 22, 2015
1 parent 577632e commit d14ff0b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion project/admin/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Blueprint, render_template, url_for, session, g, redirect
from flask import Blueprint, render_template, url_for, session, redirect
from project.admin.forms import VacancyForm, CategoryForm, CityForm
from project.admin.utils import EntryDetail, EntryList
from project.auth.forms import RegisterForm
Expand All @@ -9,13 +9,15 @@

admin_app = Blueprint('admin', __name__)


@admin_app.before_request
def check_user_logged_in():
if 'user_id' in session:
return

return redirect(url_for("auth.login"))


def register_section(*, section_name, list_endpoint,
list_route, detail_route,
list_view, detail_view):
Expand Down
1 change: 1 addition & 0 deletions project/auth/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ResetForm(Form):
],
)


class LoginForm(Form):
login = StringField(
'Логин',
Expand Down
2 changes: 2 additions & 0 deletions project/auth/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
' цифр и символов (_.-), начинаться с буквы,'
' содержать хоть одну цифру')


class PasswordCorrect(object):
def __init__(self, message=None):
self.message = message or 'Неверный пароль'
Expand All @@ -27,6 +28,7 @@ def __call__(self, _, field):
if not check_password_hash(g.user.password, field.data):
raise ValidationError(self.message)


class Exists(object):
def __init__(self, message=None, reverse=False):
if message:
Expand Down
4 changes: 3 additions & 1 deletion project/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

auth = Blueprint('auth', __name__)


@auth.before_app_request
def add_login_to_g():
if 'user_id' in session:
Expand All @@ -14,6 +15,7 @@ def add_login_to_g():
else:
g.user = None


@auth.route('/login', methods=['GET', 'POST'])
def login():
form = LoginForm()
Expand Down Expand Up @@ -62,6 +64,7 @@ def confirm_reset(token):
else:
abort(404)


@auth.route('/password_change', methods=['GET', 'POST'])
@login_required
def change_password():
Expand All @@ -78,7 +81,6 @@ def change_password():
)



@auth.route('/logout', methods=['GET'])
@login_required
def logout():
Expand Down

0 comments on commit d14ff0b

Please sign in to comment.