2022-02-05 21:09:17 +00:00
|
|
|
from sqlalchemy import *
|
2022-03-06 00:21:13 +00:00
|
|
|
from sqlalchemy.orm import relationship
|
2022-02-05 21:09:17 +00:00
|
|
|
from files.__main__ import Base
|
2022-02-10 20:35:16 +00:00
|
|
|
from files.helpers.lazy import lazy
|
2022-07-08 18:13:18 +00:00
|
|
|
from os import environ
|
2022-03-06 01:53:11 +00:00
|
|
|
from .sub_block import *
|
2022-07-08 19:03:04 +00:00
|
|
|
from .sub_subscription import *
|
2022-02-10 20:35:16 +00:00
|
|
|
|
2022-07-08 18:13:18 +00:00
|
|
|
SITE_NAME = environ.get("SITE_NAME", '').strip()
|
|
|
|
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-08-24 22:22:44 +00:00
|
|
|
marseyurl = Column(String)
|
2022-02-11 23:32:14 +00:00
|
|
|
css = Column(String)
|
2022-08-19 21:31:26 +00:00
|
|
|
stealth = Column(Boolean)
|
2022-02-05 21:09:17 +00:00
|
|
|
|
2022-07-02 06:48:04 +00:00
|
|
|
blocks = relationship("SubBlock", primaryjoin="SubBlock.sub==Sub.name")
|
|
|
|
followers = relationship("SubSubscription", primaryjoin="SubSubscription.sub==Sub.name")
|
2022-03-06 00:21:13 +00:00
|
|
|
|
2022-02-05 21:09:17 +00:00
|
|
|
def __repr__(self):
|
2022-09-11 14:32:04 +00:00
|
|
|
return self.name
|
2022-02-10 20:35:16 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def sidebar_url(self):
|
2022-02-11 20:01:07 +00:00
|
|
|
if self.sidebarurl: return SITE_FULL + self.sidebarurl
|
2022-08-24 22:22:44 +00:00
|
|
|
return f'/i/{SITE_NAME}/sidebar.webp?v=3009'
|
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-08-24 22:22:44 +00:00
|
|
|
return f'/i/{SITE_NAME}/banner.webp?v=3009'
|
|
|
|
|
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def marsey_url(self):
|
|
|
|
if self.marseyurl: return SITE_FULL + self.marseyurl
|
|
|
|
return f'/i/{SITE_NAME}/headericon.webp?v=3009'
|
2022-03-06 00:21:13 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def subscription_num(self):
|
2022-03-06 01:53:11 +00:00
|
|
|
return self.subscriptions.count()
|
|
|
|
|
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def block_num(self):
|
2022-06-10 10:06:34 +00:00
|
|
|
return len(self.blocks)
|
|
|
|
|
|
|
|
@property
|
|
|
|
@lazy
|
|
|
|
def follow_num(self):
|
|
|
|
return len(self.followers)
|