mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Format with Black
This commit is contained in:
parent
d36699bd1f
commit
02d99a1671
5 changed files with 35 additions and 27 deletions
|
@ -47,13 +47,13 @@ def create_app(): # pylint: disable=R0914
|
||||||
register_user = User(
|
register_user = User(
|
||||||
username=app.config["ADMIN_CONF"]["username"],
|
username=app.config["ADMIN_CONF"]["username"],
|
||||||
email=app.config["ADMIN_CONF"]["email"],
|
email=app.config["ADMIN_CONF"]["email"],
|
||||||
password=generate_password_hash('changeme!', method="sha256"),
|
password=generate_password_hash("changeme!", method="sha256"),
|
||||||
)
|
)
|
||||||
db.session.add(register_user)
|
db.session.add(register_user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"""
|
"""
|
||||||
####################################################
|
####################################################
|
||||||
# DEFAULY ADMIN USER GENERATED WITH GIVEN USERNAME #
|
# DEFAULY ADMIN USER GENERATED WITH GIVEN USERNAME #
|
||||||
# THE DEFAULT PASSWORD "changeme!" HAS BEEN USED, #
|
# THE DEFAULT PASSWORD "changeme!" HAS BEEN USED, #
|
||||||
|
|
|
@ -170,7 +170,12 @@ def modify_group():
|
||||||
if group.author_id != current_user.id:
|
if group.author_id != current_user.id:
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
if action == "add" and not GroupJunction.query.filter_by(group_id=group_id, post_id=image_id).first():
|
if (
|
||||||
|
action == "add"
|
||||||
|
and not GroupJunction.query.filter_by(
|
||||||
|
group_id=group_id, post_id=image_id
|
||||||
|
).first()
|
||||||
|
):
|
||||||
db.session.add(GroupJunction(group_id=group_id, post_id=image_id))
|
db.session.add(GroupJunction(group_id=group_id, post_id=image_id))
|
||||||
elif request.form["action"] == "remove":
|
elif request.form["action"] == "remove":
|
||||||
GroupJunction.query.filter_by(group_id=group_id, post_id=image_id).delete()
|
GroupJunction.query.filter_by(group_id=group_id, post_id=image_id).delete()
|
||||||
|
|
|
@ -11,6 +11,7 @@ class GroupJunction(db.Model): # pylint: disable=too-few-public-methods, C0103
|
||||||
Junction table for posts and groups
|
Junction table for posts and groups
|
||||||
Joins with posts and groups
|
Joins with posts and groups
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__tablename__ = "group_junction"
|
__tablename__ = "group_junction"
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
@ -29,6 +30,7 @@ class Post(db.Model): # pylint: disable=too-few-public-methods, C0103
|
||||||
"""
|
"""
|
||||||
Post table
|
Post table
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__tablename__ = "post"
|
__tablename__ = "post"
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
@ -51,10 +53,12 @@ class Post(db.Model): # pylint: disable=too-few-public-methods, C0103
|
||||||
|
|
||||||
junction = db.relationship("GroupJunction", backref="posts")
|
junction = db.relationship("GroupJunction", backref="posts")
|
||||||
|
|
||||||
|
|
||||||
class Group(db.Model): # pylint: disable=too-few-public-methods, C0103
|
class Group(db.Model): # pylint: disable=too-few-public-methods, C0103
|
||||||
"""
|
"""
|
||||||
Group table
|
Group table
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__tablename__ = "group"
|
__tablename__ = "group"
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
@ -76,6 +80,7 @@ class User(db.Model, UserMixin): # pylint: disable=too-few-public-methods, C010
|
||||||
"""
|
"""
|
||||||
User table
|
User table
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__tablename__ = "user"
|
__tablename__ = "user"
|
||||||
|
|
||||||
# Gallery used information
|
# Gallery used information
|
||||||
|
@ -93,8 +98,8 @@ class User(db.Model, UserMixin): # pylint: disable=too-few-public-methods, C010
|
||||||
server_default=db.func.now(), # pylint: disable=E1102
|
server_default=db.func.now(), # pylint: disable=E1102
|
||||||
)
|
)
|
||||||
|
|
||||||
posts = db.relationship('Post', backref='author')
|
posts = db.relationship("Post", backref="author")
|
||||||
groups = db.relationship('Group', backref='author')
|
groups = db.relationship("Group", backref="author")
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return str(self.alt_id)
|
return str(self.alt_id)
|
||||||
|
|
|
@ -30,8 +30,7 @@ def groups():
|
||||||
|
|
||||||
# Get the 3 most recent images
|
# Get the 3 most recent images
|
||||||
images = (
|
images = (
|
||||||
GroupJunction.query
|
GroupJunction.query.with_entities(GroupJunction.post_id)
|
||||||
.with_entities(GroupJunction.post_id)
|
|
||||||
.filter(GroupJunction.group_id == group.id)
|
.filter(GroupJunction.group_id == group.id)
|
||||||
.order_by(GroupJunction.date_added.desc())
|
.order_by(GroupJunction.date_added.desc())
|
||||||
.limit(3)
|
.limit(3)
|
||||||
|
@ -41,8 +40,7 @@ def groups():
|
||||||
group.images = []
|
group.images = []
|
||||||
for image in images:
|
for image in images:
|
||||||
group.images.append(
|
group.images.append(
|
||||||
Post.query
|
Post.query.with_entities(Post.filename, Post.alt, Post.colours, Post.id)
|
||||||
.with_entities(Post.filename, Post.alt, Post.colours, Post.id)
|
|
||||||
.filter(Post.id == image[0])
|
.filter(Post.id == image[0])
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
|
@ -60,8 +58,7 @@ def group(group_id):
|
||||||
|
|
||||||
# Get all images in the group from the junction table
|
# Get all images in the group from the junction table
|
||||||
junction = (
|
junction = (
|
||||||
GroupJunction.query
|
GroupJunction.query.with_entities(GroupJunction.post_id)
|
||||||
.with_entities(GroupJunction.post_id)
|
|
||||||
.filter(GroupJunction.group_id == group_id)
|
.filter(GroupJunction.group_id == group_id)
|
||||||
.order_by(GroupJunction.date_added.desc())
|
.order_by(GroupJunction.date_added.desc())
|
||||||
.all()
|
.all()
|
||||||
|
|
|
@ -38,8 +38,9 @@ def index():
|
||||||
|
|
||||||
# get the images for the current page
|
# get the images for the current page
|
||||||
images = (
|
images = (
|
||||||
Post.query
|
Post.query.with_entities(
|
||||||
.with_entities( Post.filename, Post.alt, Post.colours, Post.created_at, Post.id)
|
Post.filename, Post.alt, Post.colours, Post.created_at, Post.id
|
||||||
|
)
|
||||||
.order_by(Post.id.desc())
|
.order_by(Post.id.desc())
|
||||||
.offset((page - 1) * limit)
|
.offset((page - 1) * limit)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue