MarseyWorld/files/classes/sub.py

30 lines
725 B
Python
Raw Normal View History

2022-02-05 21:09:17 +00:00
from sqlalchemy import *
from files.__main__ import Base
2022-02-10 20:35:16 +00:00
from files.helpers.lazy import lazy
from os import environ
SITE_NAME = environ.get("SITE_NAME", '').strip()
2022-02-05 21:09:17 +00:00
class Sub(Base):
__tablename__ = "subs"
name = Column(String, primary_key=True)
sidebar = Column(String)
sidebar_html = Column(String)
2022-02-10 20:35:16 +00:00
sidebarurl = Column(String)
bannerurl = Column(String)
2022-02-05 21:09:17 +00:00
def __repr__(self):
2022-02-10 20:35:16 +00:00
return f"<Sub(name={self.name})>"
@property
@lazy
def sidebar_url(self):
if self.sidebarurl: return self.sidebarurl
return f'/static/assets/images/{SITE_NAME}/sidebar.webp?a=1039'
@property
@lazy
def banner_url(self):
if self.bannerurl: return self.bannerurl
return f'/static/assets/images/{SITE_NAME}/banner.webp?a=1039'