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]
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]

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

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

@ -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.route('/')
@bp.route('', defaults={'page': 1})
@bp.route('/<int:page>')
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/<int:id>')
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:

Loading…
Cancel
Save