From 5ba68fdc5016391b24a0e57f3edce042bad3dc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C5=BE=C3=ADlek?= Date: Mon, 9 Mar 2020 12:33:38 +0100 Subject: [PATCH] Small cleanup, reinitialized migrations --- Pipfile | 14 +++++------ .../{e671b32307e0_.py => f4e1b4727000_.py} | 24 +++++++++---------- yadc/__init__.py | 17 +------------ yadc/bp/api.py | 12 ---------- yadc/bp/post.py | 6 ----- 5 files changed, 20 insertions(+), 53 deletions(-) rename migrations/versions/{e671b32307e0_.py => f4e1b4727000_.py} (84%) delete mode 100644 yadc/bp/api.py diff --git a/Pipfile b/Pipfile index b41ef18..2317802 100644 --- a/Pipfile +++ b/Pipfile @@ -10,6 +10,7 @@ rope = "*" [packages] flask = "*" +werkzeug = "==0.16.1" flask-sqlalchemy = "*" flask-migrate = "*" pillow = "*" @@ -17,17 +18,16 @@ psycopg2 = "*" flask-login = "*" flask-wtf = "*" flask-assets = "*" -pyscss = "*" +# pyscss = "*" libsass = "*" cssmin = "*" -python-magic = "*" -flask-mail = "*" +# python-magic = "*" +# flask-mail = "*" sqlalchemy-utc = "*" -flask-admin = "*" -sqlalchemy-utils = "*" -werkzeug = "==0.16.1" +# flask-admin = "*" +# sqlalchemy-utils = "*" humanize = "*" -uwsgi = "*" +# uwsgi = "*" gunicorn = "*" [requires] diff --git a/migrations/versions/e671b32307e0_.py b/migrations/versions/f4e1b4727000_.py similarity index 84% rename from migrations/versions/e671b32307e0_.py rename to migrations/versions/f4e1b4727000_.py index 89f8c43..ee8c221 100644 --- a/migrations/versions/e671b32307e0_.py +++ b/migrations/versions/f4e1b4727000_.py @@ -1,8 +1,8 @@ """empty message -Revision ID: e671b32307e0 +Revision ID: f4e1b4727000 Revises: -Create Date: 2020-02-24 23:58:13.446588 +Create Date: 2020-03-09 12:32:25.827118 """ from alembic import op @@ -11,7 +11,7 @@ import sqlalchemy_utc # revision identifiers, used by Alembic. -revision = 'e671b32307e0' +revision = 'f4e1b4727000' down_revision = None branch_labels = None depends_on = None @@ -20,17 +20,17 @@ depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('tag', - sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), - sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), + sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), + sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), sa.Column('id', sa.Integer(), nullable=False), sa.Column('content', sa.String(length=128), nullable=False), - sa.Column('category', sa.Enum('general', 'style', 'circle', 'artist', 'character', 'copyright', name='tag_category'), nullable=True), + sa.Column('category', sa.Enum('general', 'style', 'circle', 'artist', 'character', 'copyright', name='tag_category'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('content') ) op.create_table('user', - sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), - sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), + sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), + sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=128), nullable=False), sa.Column('email', sa.String(length=256), nullable=True), @@ -43,8 +43,8 @@ def upgrade(): sa.UniqueConstraint('username') ) op.create_table('post', - sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), - sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), + sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), + sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), sa.Column('id', sa.Integer(), nullable=False), sa.Column('md5', sa.String(length=32), nullable=False), sa.Column('filetype', sa.Enum('png', 'jpeg', name='filetype'), nullable=False), @@ -63,8 +63,8 @@ def upgrade(): sa.UniqueConstraint('md5') ) op.create_table('comment', - sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), - sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), + sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), + sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), sa.Column('id', sa.Integer(), nullable=False), sa.Column('content', sa.String(length=512), nullable=False), sa.Column('deleted', sa.Boolean(), nullable=True), diff --git a/yadc/__init__.py b/yadc/__init__.py index b10e2b9..fbb2cf1 100644 --- a/yadc/__init__.py +++ b/yadc/__init__.py @@ -7,17 +7,11 @@ from flask_migrate import Migrate from flask_login import LoginManager from flask_assets import Environment as AssetsEnvironment, Bundle as AssetsBundle -# from flask_admin import Admin -# from flask_admin.contrib.sqla import ModelView - db = SQLAlchemy() migrate = Migrate() login = LoginManager() assets = AssetsEnvironment() -# THIS FUCKER DARES TO MESS WITH MY BLUEPRINTS (that blueprint collision shitxception) -# admin = Admin() - def create_app(): app = Flask(__name__, instance_relative_config=True) @@ -42,21 +36,12 @@ def create_app(): login.init_app(app) assets.init_app(app) - # from yadc import models - - # admin.init_app(app) - # admin.add_view(ModelView(models.User, db.session, endpoint='admin_user')) - # admin.add_view(ModelView(models.Post, db.session, endpoint='admin_post')) - # admin.add_view(ModelView(models.Tag, db.session, endpoint='admin_tag')) - # admin.add_view(ModelView(models.Comment, db.session, endpoint='admin_comment')) - - from yadc.bp import main, post, auth, manage, user, api + from yadc.bp import main, post, auth, manage, user app.register_blueprint(main.bp) app.register_blueprint(post.bp, url_prefix='/post') app.register_blueprint(auth.bp, url_prefix='/auth') app.register_blueprint(manage.bp, url_prefix='/manage') app.register_blueprint(user.bp, url_prefix='/user') - # app.register_blueprint(api.bp) # now deprecated login.login_view = 'auth.login' diff --git a/yadc/bp/api.py b/yadc/bp/api.py deleted file mode 100644 index 993c612..0000000 --- a/yadc/bp/api.py +++ /dev/null @@ -1,12 +0,0 @@ -from flask import Blueprint, flash, redirect, render_template, request, url_for, jsonify - -from yadc import db -from yadc.models import Tag - -bp = Blueprint('api', __name__) - -@bp.route('/posts.json') -def post_index(): - return jsonify( - get=request.args, - post=request.form) diff --git a/yadc/bp/post.py b/yadc/bp/post.py index e1560ed..2fb3f06 100644 --- a/yadc/bp/post.py +++ b/yadc/bp/post.py @@ -15,7 +15,6 @@ from yadc.utils import query_replace bp = Blueprint('post', __name__) -# @bp.route('/') @bp.route('', defaults={'page': 1}) @bp.route('/') def posts(page): @@ -33,7 +32,6 @@ def posts(page): # PARSING ARGUMENTS f_tags = request.args.get('tags', '').split() - # m_ratings = RATING.matched(request.args.get('rating')) f_rating = {r.name : r for r in RATING}.get(request.args.get('rating'), RATING.safe) m_ratings = f_rating.matched @@ -45,9 +43,6 @@ def posts(page): posts = posts_query.paginate(page, current_app.config.get('POSTS_PER_PAGE')) tags = tags_prepare(posts.items) - # flash(f_tags) - # flash(m_ratings) - # session['index_settings'] = dict(tags=f_tags, rating=f_rating) session['index_settings'] = dict(tags=request.args.get('tags', ''), rating=f_rating.name) return render_template('post/index.html', posts=posts, tags=tags) @@ -55,7 +50,6 @@ def posts(page): @bp.route('/show/') def post_show(id): post = Post.query.filter_by(id=id).first() - # flash(post) tags_count = db.session.query(Tag, func.count(Post.id)).join(Tag.posts).filter(Post.id==id).join(aliased(Post), Tag.posts).group_by(Tag).all() for tag,tag.count in tags_count: