~ferruck/idekadoh

8d48d5cc8b5cbdadad74802a5f1bedeab5f2d180 — Philipp Trommler 7 months ago 294635e
Fix PEP8 issues
5 files changed, 37 insertions(+), 18 deletions(-)

M idekadoh/__init__.py
M idekadoh/models.py
M idekadoh/views/home.py
M idekadoh/views/user.py
M requirements.txt
M idekadoh/__init__.py => idekadoh/__init__.py +5 -5
@@ 1,6 1,6 @@
from flask import Flask

app = Flask(__name__, instance_relative_config = True)
app = Flask(__name__, instance_relative_config=True)

# Load the default configuration
app.config.from_object('config.default')


@@ 12,17 12,17 @@ app.config.from_pyfile('config.py')
app.config.from_envvar('APP_CONFIG_FILE')

# Initialize the database
from flask_sqlalchemy import SQLAlchemy
from flask_sqlalchemy import SQLAlchemy # noqa: E402
db = SQLAlchemy(app)

# Initialize the authentication system
from flask_login import LoginManager
from flask_login import LoginManager # noqa: E402

login_manager = LoginManager(app)

# Add the blueprints
from .views.home import home
from .views.user import user
from .views.home import home # noqa: E402
from .views.user import user # noqa: E402

app.register_blueprint(home)
app.register_blueprint(user)

M idekadoh/models.py => idekadoh/models.py +21 -10
@@ 4,16 4,19 @@ from werkzeug.security import check_password_hash, generate_password_hash

from . import db, login_manager


class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(64),
    username = db.Column(
            db.String(64),
            unique=True,
            index=True,
            nullable=False)
    password_hash = db.Column(db.String(128), nullable=False)
    email = db.Column(db.String(128), nullable=False)
    lists = db.relationship('List')
    usershared = db.relationship('UserShare',
    usershared = db.relationship(
            'UserShare',
            backref='sharer',
            foreign_keys='UserShare.sharer_id')
    linkshared = db.relationship('LinkShare', backref='sharer')


@@ 33,26 36,32 @@ def load_user(user_id):
    return User.query.get(int(user_id))


list_entry_association_table = db.Table('list_entry_association',
list_entry_association_table = db.Table(
        'list_entry_association',
        db.Model.metadata,
        db.Column('list',
        db.Column(
            'list',
            db.Integer,
            db.ForeignKey('list.id'),
            primary_key=True),
        db.Column('entry',
        db.Column(
            'entry',
            db.Integer,
            db.ForeignKey('entry.id'),
            primary_key=True)
)


entry_category_association_table = db.Table('entry_category_association',
entry_category_association_table = db.Table(
        'entry_category_association',
        db.Model.metadata,
        db.Column('entry',
        db.Column(
            'entry',
            db.Integer,
            db.ForeignKey('entry.id'),
            primary_key=True),
        db.Column('category',
        db.Column(
            'category',
            db.Integer,
            db.ForeignKey('category.id'),
            primary_key=True)


@@ 65,7 74,8 @@ class List(db.Model):
    created = db.Column(db.DateTime)
    last_modified = db.Column(db.DateTime)
    owner = db.Column(db.Integer, db.ForeignKey('user.id'), index=True)
    entries = db.relationship('Entry',
    entries = db.relationship(
            'Entry',
            secondary=list_entry_association_table,
            backref='lists')
    usershares = db.relationship('UserShare', backref='list')


@@ 83,7 93,8 @@ class Entry(db.Model):
    img = db.Column(db.LargeBinary)
    price = db.Column(db.Float)
    comment = db.Column(db.Text)
    categories = db.relationship('Category',
    categories = db.relationship(
            'Category',
            secondary=entry_category_association_table,
            backref='entries')


M idekadoh/views/home.py => idekadoh/views/home.py +1 -0
@@ 2,6 2,7 @@ from flask import Blueprint, render_template

home = Blueprint('home', __name__)


@home.route('/')
def index():
    return render_template('index.html', text='Hello, World!')

M idekadoh/views/user.py => idekadoh/views/user.py +2 -1
@@ 8,6 8,7 @@ from ..models import User

user = Blueprint('user', __name__)


@user.route('/login', methods=['GET', 'POST'])
def login():
    """Logs the user in.


@@ 27,7 28,7 @@ def login():
        login_user(user, remember=form.remember_me.data)

        next_page = request.args.get('next')
        if not next_page or url_parse(next_page).netloc is not '':
        if not next_page or url_parse(next_page).netloc != '':
            next_page = url_for('home.index')

        return redirect(next_page)

M requirements.txt => requirements.txt +8 -2
@@ 1,14 1,20 @@
bcrypt==3.1.7
cffi==1.13.2
Click==7.0
Flask==1.1.1
Flask-Bcrypt==0.7.1
Flask-Login==0.4.1
Flask-SQLAlchemy==2.4.1
Flask-WTF==0.14.2
itsdangerous==1.1.0
Jinja2==2.10.3
MarkupSafe==1.1.1
mccabe==0.6.1
pycodestyle==2.5.0
pycparser==2.19
pydocstyle==4.0.1
pyflakes==2.1.1
pylama==7.7.1
six==1.13.0
snowballstemmer==2.0.0
SQLAlchemy==1.3.10
Werkzeug==0.16.0
WTForms==2.2.1