gfd
This commit is contained in:
parent
83e029092b
commit
19a1f907a7
7 changed files with 11 additions and 11 deletions
|
@ -58,10 +58,7 @@ class Comment(Base):
|
|||
reports = relationship("CommentFlag", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
if "created_utc" not in kwargs:
|
||||
kwargs["created_utc"] = int(time.time())
|
||||
|
||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
@ -2,7 +2,7 @@ from sqlalchemy import *
|
|||
from sqlalchemy.orm import relationship
|
||||
from files.__main__ import Base
|
||||
from files.helpers.lazy import *
|
||||
from time import strftime, gmtime
|
||||
import time
|
||||
|
||||
class Mod(Base):
|
||||
|
||||
|
@ -11,10 +11,14 @@ class Mod(Base):
|
|||
sub = Column(String, ForeignKey("subs.name"), primary_key=True)
|
||||
created_utc = Column(Integer)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Mod(user_id={self.user_id}, sub={self.sub})>"
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def created_datetime(self):
|
||||
return str(strftime("%d/%B/%Y %H:%M:%S UTC", gmtime(self.created_utc)))
|
||||
return str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(self.created_utc)))
|
|
@ -61,6 +61,7 @@ class Submission(Base):
|
|||
subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
@ -146,7 +146,7 @@ class User(Base):
|
|||
kwargs["passhash"] = self.hash_password(kwargs["password"])
|
||||
kwargs.pop("password")
|
||||
|
||||
kwargs["created_utc"] = int(time.time())
|
||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
|
|
@ -331,7 +331,6 @@ def sign_up_post(v):
|
|||
admin_level = admin_level,
|
||||
password=request.values.get("password"),
|
||||
email=email,
|
||||
created_utc=int(time.time()),
|
||||
referred_by=ref_id or None,
|
||||
ban_evade = int(any((x.is_banned or x.shadowbanned) and not x.unban_utc for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x))
|
||||
)
|
||||
|
|
|
@ -1078,7 +1078,6 @@ def submit_post(v, sub=None):
|
|||
embed_url=embed,
|
||||
title=title[:500],
|
||||
title_html=title_html,
|
||||
created_utc=int(time.time()),
|
||||
sub=sub
|
||||
)
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ def add_mod(v, sub):
|
|||
existing = g.db.query(Mod).filter_by(user_id=user.id, sub=sub).one_or_none()
|
||||
|
||||
if not existing:
|
||||
mod = Mod(user_id=user.id, sub=sub, created_utc=int(time.time()))
|
||||
mod = Mod(user_id=user.id, sub=sub)
|
||||
g.db.add(mod)
|
||||
|
||||
send_repeatable_notification(user.id, f"You have been added as a mod to /s/{sub}")
|
||||
|
@ -146,7 +146,7 @@ def create_sub2(v):
|
|||
sub = Sub(name=name)
|
||||
g.db.add(sub)
|
||||
g.db.flush()
|
||||
mod = Mod(user_id=v.id, sub=sub.name, created_utc=int(time.time()))
|
||||
mod = Mod(user_id=v.id, sub=sub.name)
|
||||
g.db.add(mod)
|
||||
g.db.commit()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue