add button to hide posts with child warning

pull/222/head
Aevann 2024-02-12 21:42:36 +02:00
parent 4a14e50c9f
commit f2092abeb2
5 changed files with 18 additions and 1 deletions

View File

@ -161,6 +161,7 @@ class User(Base):
earlylife = 0
hole_creation_notifs = False
hidevotedon = Column(Boolean, default=False)
hide_cw = Column(Boolean, default=False)
else:
nitter = Column(Boolean, default=False)
imgsed = Column(Boolean, default=False)
@ -170,6 +171,7 @@ class User(Base):
earlylife = Column(Integer, default=0)
hole_creation_notifs = Column(Boolean, default=True)
hidevotedon = False
hide_cw = False
if IS_HOMOWEEN():
zombie = Column(Integer, default=0) # > 0 vaxxed; < 0 zombie

View File

@ -69,6 +69,8 @@ def front_all(v, hole=None):
calc_users()
return result
hide_cw = (SITE_NAME == 'WPD' and v and v.hide_cw)
ids, total, size = frontlist(sort=sort,
page=page,
t=t,
@ -79,6 +81,7 @@ def front_all(v, hole=None):
hole=hole,
pins=pins,
effortposts_only=effortposts_only,
hide_cw=hide_cw,
)
posts = get_posts(ids, v=v)
@ -102,7 +105,7 @@ LIMITED_WPD_HOLES = {'aftermath', 'fights', 'gore', 'medical', 'request', 'selfh
'slavshit', 'sandshit'}
@cache.memoize()
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', gt=0, lt=0, hole=None, pins=True, effortposts_only=False):
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', gt=0, lt=0, hole=None, pins=True, effortposts_only=False, hide_cw=False):
posts = g.db.query(Post)
if v and v.hidevotedon:
@ -133,6 +136,14 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
Post.deleted_utc == 0,
)
if hide_cw:
posts = posts.filter(
or_(
Post.cw == False,
Post.author_id == v.id,
)
)
if pins and not gt and not lt:
if hole: posts = posts.filter(Post.hole_pinned == None)
else: posts = posts.filter(Post.stickied == None)

View File

@ -167,6 +167,7 @@ def settings_personal_post(v):
return profanity_filter_updated
updated = updated or update_flag("hidevotedon", "hidevotedon")
updated = updated or update_flag("hide_cw", "hide_cw")
updated = updated or update_flag("newtab", "newtab")
updated = updated or update_flag("newtabexternal", "newtabexternal")
updated = updated or update_flag("nitter", "nitter")

View File

@ -135,6 +135,7 @@
{% endif %}
{% if SITE_NAME == 'WPD' %}
{{common.toggle_section('Hide Posts Voted On', 'hidevotedon', 'hidevotedon', v.hidevotedon, 'Enable if you would like to automatically hide posts you have voted on from your frontpage.', false)}}
{{common.toggle_section('Hide Posts with Child Warning', 'hide_cw', 'hide_cw', v.hide_cw, 'Enable if you would like to automatically hide posts that have a child warning.', false)}}
{% endif %}
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">

View File

@ -0,0 +1,2 @@
alter table users add column hide_cw bool default false not null;
alter table users alter column hide_cw drop default;