move over_18 setting to cookies so ppl can have different settings for different devices

master
Aevann 2023-08-04 00:17:55 +03:00
parent 05c04979ed
commit 11b7c15758
3 changed files with 10 additions and 2 deletions

View File

@ -101,7 +101,6 @@ class User(Base):
email_verified = Column(Boolean, default=False) email_verified = Column(Boolean, default=False)
shadowbanned = Column(Integer, ForeignKey("users.id")) shadowbanned = Column(Integer, ForeignKey("users.id"))
chudded_by = Column(Integer, ForeignKey("users.id")) chudded_by = Column(Integer, ForeignKey("users.id"))
over_18 = Column(Boolean, default=False)
hidevotedon = Column(Boolean, default=False) hidevotedon = Column(Boolean, default=False)
slurreplacer = Column(Integer, default=1) slurreplacer = Column(Integer, default=1)
profanityreplacer = Column(Integer, default=1) profanityreplacer = Column(Integer, default=1)
@ -263,6 +262,11 @@ class User(Base):
def cursormarsey(self): def cursormarsey(self):
return session.get('cursormarsey', CURSORMARSEY_DEFAULT) return session.get('cursormarsey', CURSORMARSEY_DEFAULT)
@property
@lazy
def over_18(self):
return session.get('over_18', False)
@property @property
@lazy @lazy
def num_of_bought_awards(self): def num_of_bought_awards(self):

View File

@ -161,7 +161,6 @@ def settings_personal_post(v):
updated = updated or update_flag("imginn", "imginn") updated = updated or update_flag("imginn", "imginn")
updated = updated or update_flag("controversial", "controversial") updated = updated or update_flag("controversial", "controversial")
updated = updated or update_flag("sigs_disabled", "sigs_disabled") updated = updated or update_flag("sigs_disabled", "sigs_disabled")
updated = updated or update_flag("over_18", "over_18")
updated = updated or update_flag("is_private", "private") updated = updated or update_flag("is_private", "private")
updated = updated or update_flag("lifetimedonated_visible", "lifetimedonated_visible") updated = updated or update_flag("lifetimedonated_visible", "lifetimedonated_visible")
@ -178,6 +177,10 @@ def settings_personal_post(v):
updated = True updated = True
session["cursormarsey"] = int(request.values.get("cursormarsey") == 'true') session["cursormarsey"] = int(request.values.get("cursormarsey") == 'true')
elif not updated and request.values.get("over_18", v.over_18) != v.over_18:
updated = True
session["over_18"] = int(request.values.get("over_18") == 'true')
elif not updated and request.values.get("marsify", v.marsify) != v.marsify and v.marsify <= 1: elif not updated and request.values.get("marsify", v.marsify) != v.marsify and v.marsify <= 1:
if not v.patron: if not v.patron:
abort(403, f"Perma-marsify is only available to {patron}s!") abort(403, f"Perma-marsify is only available to {patron}s!")

View File

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