rename property

pull/161/head
Aevann 2023-06-29 23:52:07 +03:00
parent 10a715302f
commit d417fe14f0
3 changed files with 4 additions and 4 deletions

View File

@ -394,7 +394,7 @@ class User(Base):
@property
@lazy
def all_blocks(self):
def sub_blocks(self):
stealth = set([x[0] for x in g.db.query(Sub.name).filter_by(stealth=True).all()])
stealth = stealth - set([x[0] for x in g.db.query(SubJoin.sub).filter_by(user_id=self.id).all()])
if self.chud == 1: stealth = stealth - {'chudrama'}

View File

@ -92,7 +92,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
if sub:
posts = posts.filter(Post.sub == sub.name)
elif v:
posts = posts.filter(or_(Post.sub == None, Post.sub.notin_(v.all_blocks)))
posts = posts.filter(or_(Post.sub == None, Post.sub.notin_(v.sub_blocks)))
else:
stealth = [x[0] for x in g.db.query(Sub.name).filter_by(stealth=True).all()]
posts = posts.filter(or_(Post.sub == None, Post.sub.notin_(stealth)))
@ -148,7 +148,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
pins = g.db.query(Post).options(load_only(Post.id)).filter(Post.stickied != None, Post.is_banned == False)
if v:
pins = pins.filter(or_(Post.sub == None, Post.sub.notin_(v.all_blocks)))
pins = pins.filter(or_(Post.sub == None, Post.sub.notin_(v.sub_blocks)))
for pin in pins:
if pin.stickied_utc and int(time.time()) > pin.stickied_utc:
pin.stickied = None

View File

@ -18,7 +18,7 @@
{% for sub, count in subs %}
<tr>
<td>{{loop.index}}</td>
<td><a href="/h/{{sub}}">{{sub}} {% if sub.name in v.all_blocks %}<span class="text-danger">[blocked, visit it to unblock it]</span>{% endif %}</a></td>
<td><a href="/h/{{sub}}">{{sub}} {% if sub.name in v.sub_blocks %}<span class="text-danger">[blocked, visit it to unblock it]</span>{% endif %}</a></td>
<td><a href="/h/{{sub}}">{{count}}</a></td>
<td><a href="/h/{{sub}}/followers">{{sub.follow_num}}</a></td>
{% if sub.stealth %}