MarseyWorld/files/classes/sub.py

34 lines
923 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-11 23:32:14 +00:00
SITE = environ.get("DOMAIN", '').strip()
if SITE == "localhost": SITE_FULL = 'http://' + SITE
else: SITE_FULL = 'https://' + SITE
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-11 23:32:14 +00:00
css = 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):
2022-02-11 20:01:07 +00:00
if self.sidebarurl: return SITE_FULL + self.sidebarurl
2022-02-28 02:06:15 +00:00
return f'{SITE_FULL}/static/assets/images/{SITE_NAME}/sidebar.webp?v=1041'
2022-02-10 20:35:16 +00:00
@property
@lazy
def banner_url(self):
2022-02-11 20:01:07 +00:00
if self.bannerurl: return SITE_FULL + self.bannerurl
2022-03-02 00:05:30 +00:00
return f'{SITE_FULL}/static/assets/images/{SITE_NAME}/banner.webp?v=1042'