From e3bc937036e5aae7c258018178cb2e940c05b8a3 Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Wed, 5 Apr 2023 18:58:17 +0000 Subject: [PATCH] Fix date not being set correctly Fix small UI not having correct controlls on empy groups Not being able to login Overflowing text on upload button --- gallery/auth.py | 2 +- gallery/db.py | 20 +++++++++---------- .../static/sass/components/buttons/block.sass | 8 ++++++++ gallery/templates/groups/group.html | 18 +++++++++-------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/gallery/auth.py b/gallery/auth.py index 0ab360b..36e1bc7 100644 --- a/gallery/auth.py +++ b/gallery/auth.py @@ -28,7 +28,7 @@ def login(): username = request.form['username'].strip() password = request.form['password'].strip() - remember = bool(request.form['remember']) + remember = bool(request.form['remember-me']) user = db_session.query(db.Users).filter_by(username=username).first() diff --git a/gallery/db.py b/gallery/db.py index 525b3bb..b94e035 100644 --- a/gallery/db.py +++ b/gallery/db.py @@ -1,14 +1,12 @@ """ -OnlyLegs - Database models and functions for SQLAlchemy +OnlyLegs - Database models and ions for SQLAlchemy """ from uuid import uuid4 import os -from datetime import datetime as dt import platformdirs -from sqlalchemy import create_engine, Column, Integer, String, DateTime, ForeignKey, PickleType +from sqlalchemy import create_engine, Column, Integer, String, DateTime, ForeignKey, PickleType, func from sqlalchemy.orm import declarative_base, relationship - from flask_login import UserMixin @@ -35,7 +33,7 @@ class Users (base, UserMixin): # pylint: disable=too-few-public-methods, C0103 username = Column(String, unique=True, nullable=False) email = Column(String, unique=True, nullable=False) password = Column(String, nullable=False) - joined_at = Column(DateTime, nullable=False, default=dt.utcnow()) + joined_at = Column(DateTime, nullable=False, server_default=func.now()) posts = relationship('Posts', backref='users') groups = relationship('Groups', backref='users') @@ -54,7 +52,7 @@ class Posts (base): # pylint: disable=too-few-public-methods, C0103 id = Column(Integer, primary_key=True) author_id = Column(Integer, ForeignKey('users.id')) - created_at = Column(DateTime, nullable=False, default=dt.utcnow()) + created_at = Column(DateTime, nullable=False, server_default=func.now()) filename = Column(String, unique=True, nullable=False) mimetype = Column(String, nullable=False) exif = Column(PickleType, nullable=False) @@ -75,7 +73,7 @@ class Groups (base): # pylint: disable=too-few-public-methods, C0103 name = Column(String, nullable=False) description = Column(String, nullable=False) author_id = Column(Integer, ForeignKey('users.id')) - created_at = Column(DateTime, nullable=False, default=dt.utcnow()) + created_at = Column(DateTime, nullable=False, server_default=func.now()) junction = relationship('GroupJunction', backref='groups') @@ -88,7 +86,7 @@ class GroupJunction (base): # pylint: disable=too-few-public-methods, C0103 __tablename__ = 'group_junction' id = Column(Integer, primary_key=True) - date_added = Column(DateTime, nullable=False, default=dt.utcnow()) + date_added = Column(DateTime, nullable=False, server_default=func.now()) group_id = Column(Integer, ForeignKey('groups.id')) post_id = Column(Integer, ForeignKey('posts.id')) @@ -105,7 +103,7 @@ class Logs (base): # pylint: disable=too-few-public-methods, C0103 ip_address = Column(String, nullable=False) code = Column(Integer, nullable=False) note = Column(String, nullable=False) - created_at = Column(DateTime, nullable=False, default=dt.utcnow()) + created_at = Column(DateTime, nullable=False, server_default=func.now()) class Bans (base): # pylint: disable=too-few-public-methods, C0103 @@ -118,10 +116,10 @@ class Bans (base): # pylint: disable=too-few-public-methods, C0103 ip_address = Column(String, nullable=False) code = Column(Integer, nullable=False) note = Column(String, nullable=False) - banned_at = Column(DateTime, nullable=False, default=dt.utcnow()) + banned_at = Column(DateTime, nullable=False, server_default=func.now()) # check if database file exists, if not create it if not os.path.isfile(DB_PATH): - base.metadata.create_all(engine) + base.metadata.create_all(engine) print('Database created') diff --git a/gallery/static/sass/components/buttons/block.sass b/gallery/static/sass/components/buttons/block.sass index 2a7f772..15be087 100644 --- a/gallery/static/sass/components/buttons/block.sass +++ b/gallery/static/sass/components/buttons/block.sass @@ -137,6 +137,7 @@ border-radius: $rad-inner cursor: pointer + overflow: hidden transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out input @@ -145,6 +146,13 @@ opacity: 0 cursor: pointer + .status + width: 100% + white-space: nowrap + text-overflow: ellipsis + text-align: center + overflow: hidden + &:hover background-color: RGBA($white, 0.2) color: RGB($white) diff --git a/gallery/templates/groups/group.html b/gallery/templates/groups/group.html index 21297b7..11638ab 100644 --- a/gallery/templates/groups/group.html +++ b/gallery/templates/groups/group.html @@ -240,16 +240,18 @@

{{ group.name }}

+
+ +
{% if current_user.id == group.author_id %}
- -
- {% else %} -
-
{% endif %} @@ -261,7 +263,7 @@ {% if images %}