1
1
Fork 0

Small cleanup, reinitialized migrations

dev
Jan Kužílek 5 years ago
parent 3302de5668
commit 5ba68fdc50

@ -10,6 +10,7 @@ rope = "*"
[packages] [packages]
flask = "*" flask = "*"
werkzeug = "==0.16.1"
flask-sqlalchemy = "*" flask-sqlalchemy = "*"
flask-migrate = "*" flask-migrate = "*"
pillow = "*" pillow = "*"
@ -17,17 +18,16 @@ psycopg2 = "*"
flask-login = "*" flask-login = "*"
flask-wtf = "*" flask-wtf = "*"
flask-assets = "*" flask-assets = "*"
pyscss = "*" # pyscss = "*"
libsass = "*" libsass = "*"
cssmin = "*" cssmin = "*"
python-magic = "*" # python-magic = "*"
flask-mail = "*" # flask-mail = "*"
sqlalchemy-utc = "*" sqlalchemy-utc = "*"
flask-admin = "*" # flask-admin = "*"
sqlalchemy-utils = "*" # sqlalchemy-utils = "*"
werkzeug = "==0.16.1"
humanize = "*" humanize = "*"
uwsgi = "*" # uwsgi = "*"
gunicorn = "*" gunicorn = "*"
[requires] [requires]

@ -1,8 +1,8 @@
"""empty message """empty message
Revision ID: e671b32307e0 Revision ID: f4e1b4727000
Revises: Revises:
Create Date: 2020-02-24 23:58:13.446588 Create Date: 2020-03-09 12:32:25.827118
""" """
from alembic import op from alembic import op
@ -11,7 +11,7 @@ import sqlalchemy_utc
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = 'e671b32307e0' revision = 'f4e1b4727000'
down_revision = None down_revision = None
branch_labels = None branch_labels = None
depends_on = None depends_on = None
@ -20,17 +20,17 @@ depends_on = None
def upgrade(): def upgrade():
# ### commands auto generated by Alembic - please adjust! ### # ### commands auto generated by Alembic - please adjust! ###
op.create_table('tag', op.create_table('tag',
sa.Column('created', 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), 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('id', sa.Integer(), nullable=False),
sa.Column('content', sa.String(length=128), 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.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('content') sa.UniqueConstraint('content')
) )
op.create_table('user', op.create_table('user',
sa.Column('created', 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), 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('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=128), nullable=False), sa.Column('username', sa.String(length=128), nullable=False),
sa.Column('email', sa.String(length=256), nullable=True), sa.Column('email', sa.String(length=256), nullable=True),
@ -43,8 +43,8 @@ def upgrade():
sa.UniqueConstraint('username') sa.UniqueConstraint('username')
) )
op.create_table('post', op.create_table('post',
sa.Column('created', 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), 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('id', sa.Integer(), nullable=False),
sa.Column('md5', sa.String(length=32), nullable=False), sa.Column('md5', sa.String(length=32), nullable=False),
sa.Column('filetype', sa.Enum('png', 'jpeg', name='filetype'), nullable=False), sa.Column('filetype', sa.Enum('png', 'jpeg', name='filetype'), nullable=False),
@ -63,8 +63,8 @@ def upgrade():
sa.UniqueConstraint('md5') sa.UniqueConstraint('md5')
) )
op.create_table('comment', op.create_table('comment',
sa.Column('created', 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), 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('id', sa.Integer(), nullable=False),
sa.Column('content', sa.String(length=512), nullable=False), sa.Column('content', sa.String(length=512), nullable=False),
sa.Column('deleted', sa.Boolean(), nullable=True), sa.Column('deleted', sa.Boolean(), nullable=True),

@ -7,17 +7,11 @@ from flask_migrate import Migrate
from flask_login import LoginManager from flask_login import LoginManager
from flask_assets import Environment as AssetsEnvironment, Bundle as AssetsBundle from flask_assets import Environment as AssetsEnvironment, Bundle as AssetsBundle
# from flask_admin import Admin
# from flask_admin.contrib.sqla import ModelView
db = SQLAlchemy() db = SQLAlchemy()
migrate = Migrate() migrate = Migrate()
login = LoginManager() login = LoginManager()
assets = AssetsEnvironment() assets = AssetsEnvironment()
# THIS FUCKER DARES TO MESS WITH MY BLUEPRINTS (that blueprint collision shitxception)
# admin = Admin()
def create_app(): def create_app():
app = Flask(__name__, instance_relative_config=True) app = Flask(__name__, instance_relative_config=True)
@ -42,21 +36,12 @@ def create_app():
login.init_app(app) login.init_app(app)
assets.init_app(app) assets.init_app(app)
# from yadc import models from yadc.bp import main, post, auth, manage, user
# 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
app.register_blueprint(main.bp) app.register_blueprint(main.bp)
app.register_blueprint(post.bp, url_prefix='/post') app.register_blueprint(post.bp, url_prefix='/post')
app.register_blueprint(auth.bp, url_prefix='/auth') app.register_blueprint(auth.bp, url_prefix='/auth')
app.register_blueprint(manage.bp, url_prefix='/manage') app.register_blueprint(manage.bp, url_prefix='/manage')
app.register_blueprint(user.bp, url_prefix='/user') app.register_blueprint(user.bp, url_prefix='/user')
# app.register_blueprint(api.bp) # now deprecated
login.login_view = 'auth.login' login.login_view = 'auth.login'

@ -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)

@ -15,7 +15,6 @@ from yadc.utils import query_replace
bp = Blueprint('post', __name__) bp = Blueprint('post', __name__)
# @bp.route('/')
@bp.route('', defaults={'page': 1}) @bp.route('', defaults={'page': 1})
@bp.route('/<int:page>') @bp.route('/<int:page>')
def posts(page): def posts(page):
@ -33,7 +32,6 @@ def posts(page):
# PARSING ARGUMENTS # PARSING ARGUMENTS
f_tags = request.args.get('tags', '').split() 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) f_rating = {r.name : r for r in RATING}.get(request.args.get('rating'), RATING.safe)
m_ratings = f_rating.matched m_ratings = f_rating.matched
@ -45,9 +43,6 @@ def posts(page):
posts = posts_query.paginate(page, current_app.config.get('POSTS_PER_PAGE')) posts = posts_query.paginate(page, current_app.config.get('POSTS_PER_PAGE'))
tags = tags_prepare(posts.items) 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) session['index_settings'] = dict(tags=request.args.get('tags', ''), rating=f_rating.name)
return render_template('post/index.html', posts=posts, tags=tags) return render_template('post/index.html', posts=posts, tags=tags)
@ -55,7 +50,6 @@ def posts(page):
@bp.route('/show/<int:id>') @bp.route('/show/<int:id>')
def post_show(id): def post_show(id):
post = Post.query.filter_by(id=id).first() 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() 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: for tag,tag.count in tags_count:

Loading…
Cancel
Save