Skip to content

Commit

Permalink
Flask updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Osvaldo Matos-Junior committed Oct 25, 2017
1 parent 7be8802 commit 0d4253c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bolao/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class OnlyAdmin(BaseView):

def is_accessible(self):
return login.current_user.is_authenticated() and login.current_user.is_admin()
return login.current_user.is_authenticated and login.current_user.is_admin


class IndexView(AdminIndexView, OnlyAdmin):
Expand Down
2 changes: 2 additions & 0 deletions bolao/database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import pymysql
pymysql.install_as_MySQLdb()

from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
Expand Down
6 changes: 3 additions & 3 deletions bolao/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
</div>
<nav id="menu-left">
<ul>
{% if current_user.is_anonymous() %}
{% if current_user.is_anonymous %}
<li><a href="{{url_for('.login')}}">Entrar</a></li>
{% endif %}
{% if current_user.is_authenticated() %}
{% if current_user.is_authenticated %}
<li{{' class=mm-selected' if '.index' in request.endpoint}}><a href="{{url_for('.index')}}">{{current_user.name}}</a>
<ul>
<li{{' class=mm-selected' if '.games' in request.endpoint}}><a href="{{url_for('.games')}}">Jogos</a></li>
Expand All @@ -57,7 +57,7 @@
{% endif %}
<li{{' class=mm-selected' if '.comofunciona' in request.endpoint}}><a href="{{url_for('.comofunciona')}}">Como funciona</a></li>
<li{{' class=mm-selected' if '.sobre' in request.endpoint}}><a href="{{url_for('.sobre')}}">Sobre</a></li>
{% if current_user.is_authenticated() %}
{% if current_user.is_authenticated %}
<li><a href="{{url_for('.logout')}}">Logout</a></li>
{% endif %}
</ul>
Expand Down
6 changes: 3 additions & 3 deletions bolao/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@app.route('/')
def index():
if g.user.is_anonymous():
if g.user.is_anonymous:
return redirect(url_for('.login'))
return profile(g.user.id)

Expand Down Expand Up @@ -227,7 +227,7 @@ def add_scorer():

@app.route("/login", methods=["GET", "POST"])
def login():
if g.user.is_authenticated():
if g.user.is_authenticated:
return redirect('/')

form = LoginForm()
Expand All @@ -247,7 +247,7 @@ def login():

@app.route("/logout")
def logout():
if g.user.is_authenticated():
if g.user.is_authenticated:
logout_user()
return redirect('/')

Expand Down
5 changes: 2 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import json
import datetime

from flask.ext import script
from flask.ext.script import Command
from flask_script import Manager, Command

from bolao.database import create_all, drop_all

Expand Down Expand Up @@ -78,7 +77,7 @@ def run(self):
if __name__ == "__main__":
from bolao.main import app_factory

manager = script.Manager(app_factory)
manager = Manager(app_factory)
manager.add_option("-c", "--config", dest="config", required=False, default='Dev')
manager.add_command("create_db", CreateDB())
manager.add_command("drop_db", DropDB())
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Flask
Flask==0.10.0
Flask-Admin==1.0.8
Flask-Login
Flask-Mobility
flask-Script
Flask-SQLAlchemy
Flask-Testing
Flask-WTF
freezegun==0.1.18
freezegun
pymysql

0 comments on commit 0d4253c

Please sign in to comment.