mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 03:26:16 +00:00
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:
parent
ca1204d6f4
commit
e3bc937036
4 changed files with 28 additions and 20 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue