Revert "remove hidevotedon"

This reverts commit d8cf302a43.
pull/142/head
Aevann 2023-03-15 07:22:13 +02:00
parent 9f86dfad9e
commit a5d5e8e3b8
6 changed files with 11 additions and 1 deletions

View File

@ -106,6 +106,7 @@ class User(Base):
shadowbanned = Column(Integer, ForeignKey("users.id"))
chudded_by = Column(Integer, ForeignKey("users.id"))
over_18 = Column(Boolean, default=False)
hidevotedon = Column(Boolean, default=False)
slurreplacer = Column(Integer, default=1)
profanityreplacer = Column(Integer, default=1)
flairchanged = Column(Integer)

View File

@ -66,6 +66,7 @@ def front_all(v, sub=None, subdomain=None):
posts = get_posts(ids, v=v, eager=True)
if v:
if v.hidevotedon: posts = [x for x in posts if not hasattr(x, 'voted') or not x.voted]
award_timers(v)
if v and v.client: return {"data": [x.json(g.db) for x in posts], "next_exists": next_exists}
@ -78,6 +79,11 @@ LIMITED_WPD_HOLES = ('gore', 'aftermath', 'selfharm', 'meta', 'discussion', 'soc
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', gt=0, lt=0, sub=None, site=None, pins=True, holes=True):
posts = g.db.query(Submission)
if v and v.hidevotedon:
posts = posts.outerjoin(Vote,
and_(Vote.submission_id == Submission.id, Vote.user_id == v.id)
).filter(Vote.submission_id == None)
if sub: posts = posts.filter(Submission.sub == sub.name)
elif v: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks)))

View File

@ -183,6 +183,7 @@ def settings_personal_post(v):
g.db.add(v)
return profanity_filter_updated
updated = updated or update_flag("hidevotedon", "hidevotedon")
updated = updated or update_flag("newtab", "newtab")
updated = updated or update_flag("newtabexternal", "newtabexternal")
updated = updated or update_flag("nitter", "nitter")

View File

@ -132,6 +132,7 @@
{% if FEATURES['NSFW_MARKING'] %}
{{common.toggle_section('Disable +18 Warnings', 'over_18', 'over_18', v.over_18, "Disable the warnings that appear when viewing +18 content.", false)}}
{% endif %}
{{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)}}
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">
<label for="custom-filter">Custom Filters</label>

View File

@ -1 +0,0 @@
alter table users drop column hidevotedon;

View File

@ -984,6 +984,7 @@ CREATE TABLE public.users (
titlecolor character varying(6) NOT NULL,
profileurl character varying(65),
bannerurl character varying(65),
hidevotedon boolean DEFAULT false NOT NULL,
newtab boolean DEFAULT false NOT NULL,
flairchanged integer,
defaultsortingcomments character varying(15) NOT NULL,
@ -2879,3 +2880,4 @@ ALTER TABLE ONLY public.comments
--
-- PostgreSQL database dump complete
--