2021-07-21 01:12:26 +00:00
|
|
|
from sqlalchemy import *
|
|
|
|
from sqlalchemy.orm import relationship
|
2021-08-04 15:35:10 +00:00
|
|
|
from files.__main__ import Base
|
2021-09-19 18:25:40 +00:00
|
|
|
from files.helpers.lazy import lazy
|
2021-09-19 18:28:31 +00:00
|
|
|
import time
|
2021-07-21 01:12:26 +00:00
|
|
|
|
2021-09-19 18:22:57 +00:00
|
|
|
class UserBlock(Base):
|
2021-07-21 01:12:26 +00:00
|
|
|
|
|
|
|
__tablename__ = "userblocks"
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
|
|
|
target_id = Column(Integer, ForeignKey("users.id"))
|
|
|
|
|
2021-09-22 14:51:36 +00:00
|
|
|
user = relationship("User", primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
|
|
|
target = relationship("User", primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
2021-07-21 01:12:26 +00:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
|
|
|
|
return f"<UserBlock(user={user.username}, target={target.username})>"
|
2021-09-19 18:25:40 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def created_date(self):
|
|
|
|
return time.strftime("%d %b %Y", time.gmtime(self.created_utc))
|