forked from rDrama/rDrama
more fixes
parent
e7dc7c5641
commit
fe2f1293f1
|
@ -490,6 +490,7 @@ class User(Base):
|
|||
def referral_count(self):
|
||||
return len(self.referrals)
|
||||
|
||||
@lazy
|
||||
def has_blocked(self, target):
|
||||
return db.query(UserBlock).filter_by(user_id=self.id, target_id=target.id).one_or_none()
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from flask import g
|
||||
|
||||
def lazy(f):
|
||||
'''
|
||||
Prevents certain properties from having to be recomputed each time they are referenced
|
||||
|
@ -6,7 +8,7 @@ def lazy(f):
|
|||
o = args[0]
|
||||
if "_lazy" not in o.__dict__:
|
||||
o.__dict__["_lazy"] = {}
|
||||
name = f.__name__ + str(args) + str(kwargs),
|
||||
name = f.__name__ + str(args) + str(kwargs) + g.nonce,
|
||||
if name not in o.__dict__["_lazy"]:
|
||||
o.__dict__["_lazy"][name] = f(*args, **kwargs)
|
||||
return o.__dict__["_lazy"][name]
|
||||
|
|
Loading…
Reference in New Issue