Commit 27dc41ff authored by Willard's avatar Willard

Reorganize classes in views.py

parent 74cd8246
...@@ -24,13 +24,6 @@ class FormView(View): ...@@ -24,13 +24,6 @@ class FormView(View):
def render_get(self, **kwargs): def render_get(self, **kwargs):
return '' return ''
@app.route('/')
def index():
if current_user.is_authenticated:
return redirect(url_for('stalls'))
else:
return render_template('landing.html')
def not_logged_in(f): def not_logged_in(f):
@wraps(f) @wraps(f)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
...@@ -49,8 +42,6 @@ class LoginView(FormView): ...@@ -49,8 +42,6 @@ class LoginView(FormView):
def get_form(self): def get_form(self):
return OwnerLoginForm() return OwnerLoginForm()
app.add_url_rule('/login', view_func=LoginView.as_view('login'))
class RegisterView(FormView): class RegisterView(FormView):
decorators=[not_logged_in] decorators=[not_logged_in]
def render_post(self): def render_post(self):
...@@ -64,8 +55,14 @@ class RegisterView(FormView): ...@@ -64,8 +55,14 @@ class RegisterView(FormView):
def get_form(self): def get_form(self):
return OwnerRegisterForm() return OwnerRegisterForm()
app.add_url_rule('/login', view_func=LoginView.as_view('login'))
app.add_url_rule('/register', view_func=RegisterView.as_view('register')) app.add_url_rule('/register', view_func=RegisterView.as_view('register'))
@app.route('/')
@not_logged_in
def index():
return render_template('landing.html')
@app.route('/logout') @app.route('/logout')
def logout(): def logout():
logout_user() logout_user()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment