add toggle for event music

master
Aevann1 2022-12-20 03:38:19 +02:00
parent 0936e80cc5
commit 2183161916
4 changed files with 12 additions and 5 deletions

View File

@ -138,6 +138,8 @@ class User(Base):
marsify = Column(Integer, default=0) marsify = Column(Integer, default=0)
rainbow = Column(Integer) rainbow = Column(Integer)
spider = Column(Integer, default=0) spider = Column(Integer, default=0)
if HOLIDAY_EVENT:
event_music = Column(Boolean, default=True, nullable=False)
badges = relationship("Badge", order_by="Badge.created_utc", back_populates="user") badges = relationship("Badge", order_by="Badge.created_utc", back_populates="user")
subscriptions = relationship("Subscription", back_populates="user") subscriptions = relationship("Subscription", back_populates="user")
@ -1139,7 +1141,5 @@ class User(Base):
if HOLIDAY_EVENT: if HOLIDAY_EVENT:
@property @property
@lazy @lazy
def event_music(self): def can_toggle_event_music(self):
if SITE_NAME != 'rDrama': return False return self.has_badge(91)
if self.has_badge(91): return False
return True

View File

@ -194,7 +194,9 @@ def settings_personal_post(v):
else: else:
badge = v.has_badge(179) badge = v.has_badge(179)
if badge: g.db.delete(badge) if badge: g.db.delete(badge)
elif not updated and request.values.get("event_music", v.event_music) != v.event_music and v.can_toggle_event_music:
updated = True
v.event_music = not v.event_music
elif not updated and request.values.get("bio") == "" and not request.files.get('file'): elif not updated and request.values.get("bio") == "" and not request.files.get('file'):
v.bio = None v.bio = None
v.bio_html = None v.bio_html = None

View File

@ -19,6 +19,9 @@
<section id="site-settings-experience-section" class="settings-section-section"> <section id="site-settings-experience-section" class="settings-section-section">
<h5>Site Experience</h5> <h5>Site Experience</h5>
<div class="settings-section rounded" id="site-settings-experience"> <div class="settings-section rounded" id="site-settings-experience">
{% if v.can_toggle_event_music %}
{{common.toggle_section('Event Music', 'event_music_switch', 'event_music', v.event_music, 'Toggle event music.', false)}}
{% endif %}
<div class="d-lg-flex border-bottom"> <div class="d-lg-flex border-bottom">
<div class="title w-lg-25"> <div class="title w-lg-25">
<label for="patron-status">{{patron}} Status</label> <label for="patron-status">{{patron}} Status</label>

View File

@ -0,0 +1,2 @@
alter table users add column event_music boolean NOT NULL default True;
alter table users alter column event_music drop default;