get rid of Boolean columns for permenant awards

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-14 18:59:49 +02:00
parent f9840d5c71
commit 77312317f3
4 changed files with 41 additions and 18 deletions

View File

@ -59,7 +59,6 @@ class User(Base):
marseyawarded = Column(Integer)
rehab = Column(Integer)
longpost = Column(Integer)
unblockable = Column(Boolean)
bird = Column(Integer)
email = deferred(Column(String))
css = Column(String)
@ -88,11 +87,6 @@ class User(Base):
reddit = Column(String, default='old.reddit.com')
nitter = Column(Boolean)
imginn = Column(Boolean)
mute = Column(Boolean)
unmutable = Column(Boolean)
eye = Column(Boolean)
alt = Column(Boolean)
offsitementions = Column(Boolean, default=False, nullable=False)
frontsize = Column(Integer, default=25)
controversial = Column(Boolean, default=True)
bio = deferred(Column(String))
@ -101,7 +95,6 @@ class User(Base):
sig_html = Column(String)
fp = Column(String)
sigs_disabled = Column(Boolean)
fish = Column(Boolean)
progressivestack = Column(Integer)
deflector = Column(Integer)
friends = deferred(Column(String))
@ -980,3 +973,39 @@ class User(Base):
@lazy
def can_see_shadowbanned(self):
return (self.admin_level >= PERMS['USER_SHADOWBAN']) or self.shadowbanned
@property
@lazy
def unmutable(self):
return self.has_badge(67)
@property
@lazy
def mute(self):
return self.has_badge(68)
@property
@lazy
def eye(self):
return self.has_badge(83)
@property
@lazy
def alt(self):
return self.has_badge(84)
@property
@lazy
def unblockable(self):
return self.has_badge(87)
@property
@lazy
def fish(self):
return self.has_badge(90)
@property
@lazy
def offsitementions(self):
return self.has_badge(140)

View File

@ -16,10 +16,11 @@ from files.helpers.sanitize import sanitize
def offsite_mentions_task():
if const.REDDIT_NOTIFS_SITE:
row_send_to = g.db.query(User.id) \
.filter(or_(User.admin_level >= const.PERMS['NOTIFICATIONS_REDDIT'],
User.offsitementions == True)).all()
row_send_to = g.db.query(Badge.user_id).filter_by(badge_id=140).all()
row_send_to += g.db.query(User.id).filter(or_(User.admin_level >= const.PERMS['NOTIFICATIONS_REDDIT'])).all()
send_to = [x[0] for x in row_send_to]
send_to = set(send_to)
site_mentions = get_mentions(const.REDDIT_NOTIFS_SITE)
notify_mentions(send_to, site_mentions)

View File

@ -530,7 +530,7 @@ def badge_grant_post(v):
try: badge_id = int(request.values.get("badge_id"))
except: abort(400)
if badge_id in {16,17,21,22,23,24,25,26,27,94,95,96,97,98,109,137} and v.id != AEVANN_ID and SITE != 'pcmemes.net':
if badge_id in {16,17,21,22,23,24,25,26,27,94,95,96,97,98,109,137,67,68,83,84,87,90,140} and v.id != AEVANN_ID and SITE != 'pcmemes.net':
abort(403)
if user.has_badge(badge_id):

View File

@ -269,10 +269,8 @@ def award_thing(v, thing_type, id):
author.flairchanged = int(time.time()) + 86400
badge_grant(user=author, badge_id=96)
elif kind == "pause":
author.mute = True
badge_grant(badge_id=68, user=author)
elif kind == "unpausable":
author.unmutable = True
badge_grant(badge_id=67, user=author)
elif kind == "marsey":
if author.marseyawarded: author.marseyawarded += 86400
@ -291,20 +289,15 @@ def award_thing(v, thing_type, id):
else: author.bird = int(time.time()) + 86400
badge_grant(user=author, badge_id=95)
elif kind == "eye":
author.eye = True
badge_grant(badge_id=83, user=author)
elif kind == "offsitementions":
author.offsitementions = True
badge_grant(user=author, badge_id=140)
elif kind == "alt":
author.alt = True
badge_grant(badge_id=84, user=author)
elif kind == "unblockable":
author.unblockable = True
badge_grant(badge_id=87, user=author)
for block in g.db.query(UserBlock).filter_by(target_id=author.id).all(): g.db.delete(block)
elif kind == "fish":
author.fish = True
badge_grant(badge_id=90, user=author)
elif kind == "progressivestack":
if not FEATURES['PINS']: