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
This commit is contained in:
Michał 2023-04-05 18:58:17 +00:00
parent ca1204d6f4
commit e3bc937036
4 changed files with 28 additions and 20 deletions

View file

@ -28,7 +28,7 @@ def login():
username = request.form['username'].strip() username = request.form['username'].strip()
password = request.form['password'].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() user = db_session.query(db.Users).filter_by(username=username).first()

View file

@ -1,14 +1,12 @@
""" """
OnlyLegs - Database models and functions for SQLAlchemy OnlyLegs - Database models and ions for SQLAlchemy
""" """
from uuid import uuid4 from uuid import uuid4
import os import os
from datetime import datetime as dt
import platformdirs 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 sqlalchemy.orm import declarative_base, relationship
from flask_login import UserMixin 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) username = Column(String, unique=True, nullable=False)
email = Column(String, unique=True, nullable=False) email = Column(String, unique=True, nullable=False)
password = Column(String, 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') posts = relationship('Posts', backref='users')
groups = relationship('Groups', 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) id = Column(Integer, primary_key=True)
author_id = Column(Integer, ForeignKey('users.id')) 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) filename = Column(String, unique=True, nullable=False)
mimetype = Column(String, nullable=False) mimetype = Column(String, nullable=False)
exif = Column(PickleType, 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) name = Column(String, nullable=False)
description = Column(String, nullable=False) description = Column(String, nullable=False)
author_id = Column(Integer, ForeignKey('users.id')) 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') junction = relationship('GroupJunction', backref='groups')
@ -88,7 +86,7 @@ class GroupJunction (base): # pylint: disable=too-few-public-methods, C0103
__tablename__ = 'group_junction' __tablename__ = 'group_junction'
id = Column(Integer, primary_key=True) 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')) group_id = Column(Integer, ForeignKey('groups.id'))
post_id = Column(Integer, ForeignKey('posts.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) ip_address = Column(String, nullable=False)
code = Column(Integer, nullable=False) code = Column(Integer, nullable=False)
note = Column(String, 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 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) ip_address = Column(String, nullable=False)
code = Column(Integer, nullable=False) code = Column(Integer, nullable=False)
note = Column(String, 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 # check if database file exists, if not create it
if not os.path.isfile(DB_PATH): if not os.path.isfile(DB_PATH):
base.metadata.create_all(engine) base.metadata.create_all(engine)
print('Database created') print('Database created')

View file

@ -137,6 +137,7 @@
border-radius: $rad-inner border-radius: $rad-inner
cursor: pointer cursor: pointer
overflow: hidden
transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out
input input
@ -145,6 +146,13 @@
opacity: 0 opacity: 0
cursor: pointer cursor: pointer
.status
width: 100%
white-space: nowrap
text-overflow: ellipsis
text-align: center
overflow: hidden
&:hover &:hover
background-color: RGBA($white, 0.2) background-color: RGBA($white, 0.2)
color: RGB($white) color: RGB($white)

View file

@ -240,16 +240,18 @@
<h1 class="banner-header">{{ group.name }}</h1> <h1 class="banner-header">{{ group.name }}</h1>
<p class="banner-info">By {{ group.author_username }}</p> <p class="banner-info">By {{ group.author_username }}</p>
<div class="pill-row"> <div class="pill-row">
<div>
<button class="pill-item" onclick="groupShare()">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M216,112v96a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V112A16,16,0,0,1,56,96H80a8,8,0,0,1,0,16H56v96H200V112H176a8,8,0,0,1,0-16h24A16,16,0,0,1,216,112ZM93.66,69.66,120,43.31V136a8,8,0,0,0,16,0V43.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,69.66Z"></path></svg>
</button>
</div>
{% if current_user.id == group.author_id %} {% if current_user.id == group.author_id %}
<div> <div>
<button class="pill-item" onclick="groupShare()"> <button class="pill-item pill__critical" onclick="groupDelete()">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"></path></svg>
</button> </button>
</div> <button class="pill-item pill__critical" onclick="groupEdit()">
{% else %} <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM92.69,208H48V163.31l88-88L180.69,120ZM192,108.68,147.31,64l24-24L216,84.68Z"></path></svg>
<div>
<button class="pill-item" onclick="groupShare()">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M216,112v96a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V112A16,16,0,0,1,56,96H80a8,8,0,0,1,0,16H56v96H200V112H176a8,8,0,0,1,0-16h24A16,16,0,0,1,216,112ZM93.66,69.66,120,43.31V136a8,8,0,0,0,16,0V43.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,69.66Z"></path></svg>
</button> </button>
</div> </div>
{% endif %} {% endif %}
@ -261,7 +263,7 @@
{% if images %} {% if images %}
<div class="gallery-grid"> <div class="gallery-grid">
{% for image in images %} {% for image in images %}
<a id="image-{{ image.id }}" class="gallery-item" href="{{ url_for('group.group_post', group_id=group.id, image_id=image.id) }}" style="background-color: rgb({{ image.image_colours.0.0 }}, {{ image.image_colours.0.1 }}, {{ image.image_colours.0.2 }})"> <a id="image-{{ image.id }}" class="gallery-item" href="{{ url_for('group.group_post', group_id=group.id, image_id=image.id) }}" style="background-color: rgb({{ image.colours.0.0 }}, {{ image.colours.0.1 }}, {{ image.colours.0.2 }})">
<div class="image-filter"> <div class="image-filter">
<p class="image-subtitle"></p> <p class="image-subtitle"></p>
<p class="image-title"><span class="time">{{ image.created_at }}</span></p> <p class="image-title"><span class="time">{{ image.created_at }}</span></p>