fsdfs
This commit is contained in:
parent
a16d56358c
commit
c5f8e567bb
10 changed files with 77 additions and 7 deletions
|
@ -70,17 +70,21 @@ class AwardRelationship(Base):
|
||||||
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id", lazy="joined", viewonly=True)
|
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id", lazy="joined", viewonly=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def given(self):
|
def given(self):
|
||||||
return bool(self.submission_id) or bool(self.comment_id)
|
return bool(self.submission_id) or bool(self.comment_id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def type(self):
|
def type(self):
|
||||||
return AWARDS[self.kind]
|
return AWARDS[self.kind]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def title(self):
|
def title(self):
|
||||||
return self.type['title']
|
return self.type['title']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def class_list(self):
|
def class_list(self):
|
||||||
return self.type['icon']+' '+self.type['color']
|
return self.type['icon']+' '+self.type['color']
|
||||||
|
|
|
@ -22,11 +22,13 @@ class BadgeDef(Base):
|
||||||
return f"<BadgeDef(badge_id={self.id})>"
|
return f"<BadgeDef(badge_id={self.id})>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def path(self):
|
def path(self):
|
||||||
|
|
||||||
return f"/assets/images/{site_name}/badges/{self.icon}"
|
return f"/assets/images/{site_name}/badges/{self.icon}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_core(self):
|
def json_core(self):
|
||||||
return {
|
return {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
|
@ -53,6 +55,7 @@ class Badge(Base):
|
||||||
return f"<Badge(user_id={self.user_id}, badge_id={self.badge_id})>"
|
return f"<Badge(user_id={self.user_id}, badge_id={self.badge_id})>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def text(self):
|
def text(self):
|
||||||
if self.description:
|
if self.description:
|
||||||
return self.description
|
return self.description
|
||||||
|
@ -60,18 +63,22 @@ class Badge(Base):
|
||||||
return self.badge.description
|
return self.badge.description
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def type(self):
|
def type(self):
|
||||||
return self.badge.id
|
return self.badge.id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def name(self):
|
def name(self):
|
||||||
return self.badge.name
|
return self.badge.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def path(self):
|
def path(self):
|
||||||
return self.badge.path
|
return self.badge.path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_core(self):
|
def json_core(self):
|
||||||
|
|
||||||
return {'text': self.text,
|
return {'text': self.text,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
from flask import *
|
from flask import *
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship, lazyload
|
from sqlalchemy.orm import relationship, lazyload
|
||||||
|
|
||||||
from .submission import Submission
|
from .submission import Submission
|
||||||
from .comment import Comment
|
from .comment import Comment
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
class OauthApp(Base):
|
class OauthApp(Base):
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ class OauthApp(Base):
|
||||||
return str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(self.created_utc)))
|
return str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(self.created_utc)))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def permalink(self): return f"/admin/app/{self.id}"
|
def permalink(self): return f"/admin/app/{self.id}"
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,6 +56,8 @@ class OauthApp(Base):
|
||||||
|
|
||||||
return [x[0] for x in posts.all()]
|
return [x[0] for x in posts.all()]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ClientAuth(Base):
|
class ClientAuth(Base):
|
||||||
|
|
||||||
__tablename__ = "client_auths"
|
__tablename__ = "client_auths"
|
||||||
|
|
|
@ -2,7 +2,7 @@ import re
|
||||||
from urllib.parse import urlencode, urlparse, parse_qs
|
from urllib.parse import urlencode, urlparse, parse_qs
|
||||||
from flask import *
|
from flask import *
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship, deferred
|
from sqlalchemy.orm import relationship
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
from files.helpers.const import SLURS
|
from files.helpers.const import SLURS
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
|
@ -187,6 +187,7 @@ class Comment(Base):
|
||||||
self.__dict__["replies"] = value
|
self.__dict__["replies"] = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def replies2(self):
|
def replies2(self):
|
||||||
return self.__dict__.get("replies2", [])
|
return self.__dict__.get("replies2", [])
|
||||||
|
|
||||||
|
@ -215,6 +216,7 @@ class Comment(Base):
|
||||||
else: return f"/comment/{self.id}/"
|
else: return f"/comment/{self.id}/"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_raw(self):
|
def json_raw(self):
|
||||||
flags = {}
|
flags = {}
|
||||||
for f in self.flags: flags[f.user.username] = f.reason
|
for f in self.flags: flags[f.user.username] = f.reason
|
||||||
|
@ -252,6 +254,7 @@ class Comment(Base):
|
||||||
return len([x for x in self.awards if x.kind == kind])
|
return len([x for x in self.awards if x.kind == kind])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_core(self):
|
def json_core(self):
|
||||||
if self.is_banned:
|
if self.is_banned:
|
||||||
data= {'is_banned': True,
|
data= {'is_banned': True,
|
||||||
|
@ -280,6 +283,7 @@ class Comment(Base):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json(self):
|
def json(self):
|
||||||
|
|
||||||
data=self.json_core
|
data=self.json_core
|
||||||
|
@ -297,14 +301,17 @@ class Comment(Base):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_blocking(self):
|
def is_blocking(self):
|
||||||
return self.__dict__.get('_is_blocking', 0)
|
return self.__dict__.get('_is_blocking', 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_blocked(self):
|
def is_blocked(self):
|
||||||
return self.__dict__.get('_is_blocked', 0)
|
return self.__dict__.get('_is_blocked', 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def body(self):
|
def body(self):
|
||||||
if self.comment_aux: return self.comment_aux.body
|
if self.comment_aux: return self.comment_aux.body
|
||||||
else: return ""
|
else: return ""
|
||||||
|
@ -315,6 +322,7 @@ class Comment(Base):
|
||||||
g.db.add(self.comment_aux)
|
g.db.add(self.comment_aux)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def body_html(self):
|
def body_html(self):
|
||||||
return self.comment_aux.body_html
|
return self.comment_aux.body_html
|
||||||
|
|
||||||
|
@ -349,6 +357,7 @@ class Comment(Base):
|
||||||
return body
|
return body
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def ban_reason(self):
|
def ban_reason(self):
|
||||||
return self.comment_aux.ban_reason
|
return self.comment_aux.ban_reason
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
class Flag(Base):
|
class Flag(Base):
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
import time
|
import time
|
||||||
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
class ModAction(Base):
|
class ModAction(Base):
|
||||||
__tablename__ = "modactions"
|
__tablename__ = "modactions"
|
||||||
|
@ -35,6 +36,7 @@ class ModAction(Base):
|
||||||
return f"<ModAction(id={self.id})>"
|
return f"<ModAction(id={self.id})>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def age_string(self):
|
def age_string(self):
|
||||||
|
|
||||||
age = self.age
|
age = self.age
|
||||||
|
@ -68,6 +70,7 @@ class ModAction(Base):
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def note(self):
|
def note(self):
|
||||||
|
|
||||||
if self.kind=="ban_user":
|
if self.kind=="ban_user":
|
||||||
|
@ -84,6 +87,7 @@ class ModAction(Base):
|
||||||
self._note=x
|
self._note=x
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def string(self):
|
def string(self):
|
||||||
|
|
||||||
output = ACTIONTYPES[self.kind]["str"].format(self=self)
|
output = ACTIONTYPES[self.kind]["str"].format(self=self)
|
||||||
|
@ -93,6 +97,7 @@ class ModAction(Base):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def target_link(self):
|
def target_link(self):
|
||||||
if self.target_user:
|
if self.target_user:
|
||||||
return f'<a href="{self.target_user.url}">{self.target_user.username}</a>'
|
return f'<a href="{self.target_user.url}">{self.target_user.username}</a>'
|
||||||
|
@ -104,14 +109,17 @@ class ModAction(Base):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def icon(self):
|
def icon(self):
|
||||||
return ACTIONTYPES[self.kind]['icon']
|
return ACTIONTYPES[self.kind]['icon']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def color(self):
|
def color(self):
|
||||||
return ACTIONTYPES[self.kind]['color']
|
return ACTIONTYPES[self.kind]['color']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def permalink(self):
|
def permalink(self):
|
||||||
return f"/log/{self.id}"
|
return f"/log/{self.id}"
|
||||||
|
|
||||||
|
|
|
@ -313,6 +313,7 @@ class Submission(Base):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_core(self):
|
def json_core(self):
|
||||||
|
|
||||||
if self.is_banned:
|
if self.is_banned:
|
||||||
|
@ -334,6 +335,7 @@ class Submission(Base):
|
||||||
return self.json_raw
|
return self.json_raw
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json(self):
|
def json(self):
|
||||||
|
|
||||||
data=self.json_core
|
data=self.json_core
|
||||||
|
@ -357,6 +359,7 @@ class Submission(Base):
|
||||||
return len([x for x in self.awards if x.kind == kind])
|
return len([x for x in self.awards if x.kind == kind])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def title(self):
|
def title(self):
|
||||||
return self.submission_aux.title
|
return self.submission_aux.title
|
||||||
|
|
||||||
|
@ -366,6 +369,7 @@ class Submission(Base):
|
||||||
g.db.add(self.submission_aux)
|
g.db.add(self.submission_aux)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def url(self):
|
def url(self):
|
||||||
return self.submission_aux.url
|
return self.submission_aux.url
|
||||||
|
|
||||||
|
@ -390,6 +394,7 @@ class Submission(Base):
|
||||||
else: return ""
|
else: return ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def body(self):
|
def body(self):
|
||||||
return self.submission_aux.body
|
return self.submission_aux.body
|
||||||
|
|
||||||
|
@ -399,6 +404,7 @@ class Submission(Base):
|
||||||
g.db.add(self.submission_aux)
|
g.db.add(self.submission_aux)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def body_html(self):
|
def body_html(self):
|
||||||
return self.submission_aux.body_html
|
return self.submission_aux.body_html
|
||||||
|
|
||||||
|
@ -420,6 +426,7 @@ class Submission(Base):
|
||||||
return body
|
return body
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def title_html(self):
|
def title_html(self):
|
||||||
return self.submission_aux.title_html
|
return self.submission_aux.title_html
|
||||||
|
|
||||||
|
@ -439,6 +446,7 @@ class Submission(Base):
|
||||||
return title
|
return title
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def ban_reason(self):
|
def ban_reason(self):
|
||||||
return self.submission_aux.ban_reason
|
return self.submission_aux.ban_reason
|
||||||
|
|
||||||
|
@ -448,6 +456,7 @@ class Submission(Base):
|
||||||
g.db.add(self.submission_aux)
|
g.db.add(self.submission_aux)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def embed_url(self):
|
def embed_url(self):
|
||||||
return self.submission_aux.embed_url
|
return self.submission_aux.embed_url
|
||||||
|
|
||||||
|
@ -457,10 +466,12 @@ class Submission(Base):
|
||||||
g.db.add(self.submission_aux)
|
g.db.add(self.submission_aux)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_blocked(self):
|
def is_blocked(self):
|
||||||
return self.__dict__.get('_is_blocked', False)
|
return self.__dict__.get('_is_blocked', False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_blocking(self):
|
def is_blocking(self):
|
||||||
return self.__dict__.get('_is_blocking', False)
|
return self.__dict__.get('_is_blocking', False)
|
||||||
|
|
||||||
|
@ -469,11 +480,13 @@ class Submission(Base):
|
||||||
#return len(self.awards)
|
#return len(self.awards)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_image(self):
|
def is_image(self):
|
||||||
if self.url: return self.url.lower().endswith('.webp') or self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999')
|
if self.url: return self.url.lower().endswith('.webp') or self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999')
|
||||||
else: return False
|
else: return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_video(self) -> bool:
|
def is_video(self) -> bool:
|
||||||
if self.url:
|
if self.url:
|
||||||
return self.url.startswith("https://i.imgur.com") and self.url.lower().endswith('.mp4')
|
return self.url.startswith("https://i.imgur.com") and self.url.lower().endswith('.mp4')
|
||||||
|
|
|
@ -210,6 +210,7 @@ class User(Base):
|
||||||
user_id=self.id, target_id=target.id).first()
|
user_id=self.id, target_id=target.id).first()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def paid_dues(self):
|
def paid_dues(self):
|
||||||
return self.admin_level == 6 or self.club_allowed or (self.truecoins > int(environ.get("DUES").strip()) and not self.club_banned)
|
return self.admin_level == 6 or self.club_allowed or (self.truecoins > int(environ.get("DUES").strip()) and not self.club_banned)
|
||||||
|
|
||||||
|
@ -225,10 +226,12 @@ class User(Base):
|
||||||
return x.verify(token, valid_window=1)
|
return x.verify(token, valid_window=1)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def age(self):
|
def age(self):
|
||||||
return int(time.time()) - self.created_utc
|
return int(time.time()) - self.created_utc
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def strid(self):
|
def strid(self):
|
||||||
return str(self.id)
|
return str(self.id)
|
||||||
|
|
||||||
|
@ -277,10 +280,12 @@ class User(Base):
|
||||||
return listing
|
return listing
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def fullname(self):
|
def fullname(self):
|
||||||
return f"t1_{self.id}"
|
return f"t1_{self.id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def banned_by(self):
|
def banned_by(self):
|
||||||
if not self.is_suspended: return None
|
if not self.is_suspended: return None
|
||||||
return g.db.query(User).filter_by(id=self.is_banned).first()
|
return g.db.query(User).filter_by(id=self.is_banned).first()
|
||||||
|
@ -296,6 +301,7 @@ class User(Base):
|
||||||
return check_password_hash(self.passhash, password)
|
return check_password_hash(self.passhash, password)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def formkey(self):
|
def formkey(self):
|
||||||
|
|
||||||
if "session_id" not in session:
|
if "session_id" not in session:
|
||||||
|
@ -310,6 +316,7 @@ class User(Base):
|
||||||
return validate_hash(f"{session['session_id']}+{self.id}+{self.login_nonce}", formkey)
|
return validate_hash(f"{session['session_id']}+{self.id}+{self.login_nonce}", formkey)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def url(self):
|
def url(self):
|
||||||
return f"/@{self.username}"
|
return f"/@{self.username}"
|
||||||
|
|
||||||
|
@ -317,6 +324,7 @@ class User(Base):
|
||||||
return f"<User(username={self.username})>"
|
return f"<User(username={self.username})>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def unban_string(self):
|
def unban_string(self):
|
||||||
if self.unban_utc == 0:
|
if self.unban_utc == 0:
|
||||||
return "permanently banned"
|
return "permanently banned"
|
||||||
|
@ -445,6 +453,7 @@ class User(Base):
|
||||||
return g.db.query(Follow).options(lazyload('*')).filter_by(target_id=self.id, user_id=user.id).first()
|
return g.db.query(Follow).options(lazyload('*')).filter_by(target_id=self.id, user_id=user.id).first()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def banner_url(self):
|
def banner_url(self):
|
||||||
if self.bannerurl: return self.bannerurl
|
if self.bannerurl: return self.bannerurl
|
||||||
else: return f"https://{site}/assets/images/{site_name}/preview.webp"
|
else: return f"https://{site}/assets/images/{site_name}/preview.webp"
|
||||||
|
@ -455,12 +464,14 @@ class User(Base):
|
||||||
return f"https://{site}/assets/images/defaultpictures/{pic}.webp"
|
return f"https://{site}/assets/images/defaultpictures/{pic}.webp"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def profile_url(self):
|
def profile_url(self):
|
||||||
if self.profileurl: return self.profileurl
|
if self.profileurl: return self.profileurl
|
||||||
elif "rdrama" in site: return self.defaultpicture()
|
elif "rdrama" in site: return self.defaultpicture()
|
||||||
else: return f"https://{site}/assets/images/default-profile-pic.webp"
|
else: return f"https://{site}/assets/images/default-profile-pic.webp"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_raw(self):
|
def json_raw(self):
|
||||||
data = {'username': self.username,
|
data = {'username': self.username,
|
||||||
'url': self.url,
|
'url': self.url,
|
||||||
|
@ -478,6 +489,7 @@ class User(Base):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_core(self):
|
def json_core(self):
|
||||||
|
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
|
@ -492,6 +504,7 @@ class User(Base):
|
||||||
return self.json_raw
|
return self.json_raw
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json(self):
|
def json(self):
|
||||||
data = self.json_core
|
data = self.json_core
|
||||||
|
|
||||||
|
@ -528,19 +541,23 @@ class User(Base):
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_suspended(self):
|
def is_suspended(self):
|
||||||
return (self.is_banned and (not self.unban_utc or self.unban_utc > time.time()))
|
return (self.is_banned and (not self.unban_utc or self.unban_utc > time.time()))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_blocking(self):
|
def is_blocking(self):
|
||||||
return self.__dict__.get('_is_blocking', 0)
|
return self.__dict__.get('_is_blocking', 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def is_blocked(self):
|
def is_blocked(self):
|
||||||
return self.__dict__.get('_is_blocked', 0)
|
return self.__dict__.get('_is_blocked', 0)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def applications(self):
|
def applications(self):
|
||||||
return [x for x in self._applications.order_by(
|
return [x for x in self._applications.order_by(
|
||||||
OauthApp.id.asc()).all()]
|
OauthApp.id.asc()).all()]
|
||||||
|
@ -600,6 +617,7 @@ class User(Base):
|
||||||
return [x[0] for x in comments.offset(25 * (page - 1)).limit(26).all()]
|
return [x[0] for x in comments.offset(25 * (page - 1)).limit(26).all()]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def filter_words(self):
|
def filter_words(self):
|
||||||
l = [i.strip() for i in self.custom_filter_list.split('\n')] if self.custom_filter_list else []
|
l = [i.strip() for i in self.custom_filter_list.split('\n')] if self.custom_filter_list else []
|
||||||
l = [i for i in l if i]
|
l = [i for i in l if i]
|
||||||
|
@ -625,11 +643,13 @@ class ViewerRelationship(Base):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def last_view_since(self):
|
def last_view_since(self):
|
||||||
|
|
||||||
return int(time.time()) - self.last_view_utc
|
return int(time.time()) - self.last_view_utc
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def last_view_string(self):
|
def last_view_string(self):
|
||||||
|
|
||||||
age = self.last_view_since
|
age = self.last_view_since
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
|
from files.helpers.lazy import lazy
|
||||||
|
|
||||||
class UserBlock(Base):
|
class UserBlock(Base):
|
||||||
|
|
||||||
|
@ -12,11 +13,11 @@ class UserBlock(Base):
|
||||||
user = relationship("User", innerjoin=True, primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
user = relationship("User", innerjoin=True, primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
||||||
target = relationship("User", innerjoin=True, primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
target = relationship("User", innerjoin=True, primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def created_date(self):
|
|
||||||
return time.strftime("%d %b %Y", time.gmtime(self.created_utc))
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
||||||
return f"<UserBlock(user={user.username}, target={target.username})>"
|
return f"<UserBlock(user={user.username}, target={target.username})>"
|
||||||
|
|
||||||
|
@property
|
||||||
|
@lazy
|
||||||
|
def created_date(self):
|
||||||
|
return time.strftime("%d %b %Y", time.gmtime(self.created_utc))
|
|
@ -24,6 +24,7 @@ class Vote(Base):
|
||||||
return f"<Vote(id={self.id})>"
|
return f"<Vote(id={self.id})>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_core(self):
|
def json_core(self):
|
||||||
data={
|
data={
|
||||||
"user_id": self.user_id,
|
"user_id": self.user_id,
|
||||||
|
@ -33,6 +34,7 @@ class Vote(Base):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json(self):
|
def json(self):
|
||||||
data=self.json_core
|
data=self.json_core
|
||||||
data["user"]=self.user.json_core
|
data["user"]=self.user.json_core
|
||||||
|
@ -62,6 +64,7 @@ class CommentVote(Base):
|
||||||
return f"<CommentVote(id={self.id})>"
|
return f"<CommentVote(id={self.id})>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json_core(self):
|
def json_core(self):
|
||||||
data={
|
data={
|
||||||
"user_id": self.user_id,
|
"user_id": self.user_id,
|
||||||
|
@ -71,6 +74,7 @@ class CommentVote(Base):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@lazy
|
||||||
def json(self):
|
def json(self):
|
||||||
data=self.json_core
|
data=self.json_core
|
||||||
data["user"]=self.user.json_core
|
data["user"]=self.user.json_core
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue