From 5ed72c3e475423d167c4f6f0136fee0c9a23b9d5 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 23 Oct 2021 17:57:25 +0200 Subject: [PATCH] pause,unpausable --- files/classes/user.py | 2 + files/helpers/const.py | 32 +++++++++++++ files/routes/awards.py | 77 ++++++++++++++++++++++++++++++- files/templates/admin/awards.html | 2 +- files/templates/award_modal.html | 2 +- files/templates/shop.html | 2 +- files/templates/userpage.html | 51 ++++++++++++-------- 7 files changed, 143 insertions(+), 25 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 528369ad5..b1002f36d 100755 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -76,6 +76,8 @@ class User(Base): newtabexternal = Column(Boolean, default=True) oldreddit = Column(Boolean, default=True) nitter = Column(Boolean) + mute = Column(Boolean) + unmutable = Column(Boolean) frontsize = Column(Integer, default=25) controversial = Column(Boolean, default=False) bio = Column(String) diff --git a/files/helpers/const.py b/files/helpers/const.py index 547814dc5..688c954ce 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -213,6 +213,22 @@ if SITE_NAME == "Drama": "color": "text-success", "price": 10000 }, + "pause": { + "kind": "pause", + "title": "Pause", + "description": "Gives the recipient the ability to pause profile anthems.", + "icon": "fas fa-volume-mute", + "color": "text-danger", + "price": 20000 + }, + "unpausable": { + "kind": "unpausable", + "title": "Unpausable", + "description": "Makes the profile anthem of the recipient unpausable.", + "icon": "fas fa-volume", + "color": "text-success", + "price": 40000 + }, } else: AWARDS = { @@ -256,4 +272,20 @@ else: "color": "text-black", "price": 1000 }, + "pause": { + "kind": "pause", + "title": "Pause", + "description": "Gives the recipient the ability to pause profile anthems.", + "icon": "fas fa-volume-mute", + "color": "text-danger", + "price": 20000 + }, + "unpausable": { + "kind": "unpausable", + "title": "Unpausable", + "description": "Makes the profile anthem of the recipient unpausable.", + "icon": "fas fa-volume", + "color": "text-success", + "price": 40000 + }, } \ No newline at end of file diff --git a/files/routes/awards.py b/files/routes/awards.py index 100738c86..2e197d470 100755 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -131,6 +131,24 @@ def shop(v): "owned": 0, "price": 10000 }, + "pause": { + "kind": "pause", + "title": "Pause", + "description": "Gives the recipient the ability to pause profile anthems.", + "icon": "fas fa-volume-mute", + "color": "text-danger", + "owned": 0, + "price": 20000 + }, + "unpausable": { + "kind": "unpausable", + "title": "Unpausable", + "description": "Makes the profile anthem of the recipient unpausable.", + "icon": "fas fa-volume", + "color": "text-success", + "owned": 0, + "price": 40000 + }, } else: AWARDS = { @@ -179,6 +197,24 @@ def shop(v): "owned": 0, "price": 1000 }, + "pause": { + "kind": "pause", + "title": "Pause", + "description": "Gives the recipient the ability to pause profile anthems.", + "icon": "fas fa-volume-mute", + "color": "text-danger", + "owned": 0, + "price": 20000 + }, + "unpausable": { + "kind": "unpausable", + "title": "Unpausable", + "description": "Makes the profile anthem of the recipient unpausable.", + "icon": "fas fa-volume", + "color": "text-success", + "owned": 0, + "price": 40000 + }, } for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all(): AWARDS[useraward.kind]["owned"] += 1 @@ -280,7 +316,22 @@ def buy(v, award): "color": "text-success", "price": 10000 }, - + "pause": { + "kind": "pause", + "title": "Pause", + "description": "Gives the recipient the ability to pause profile anthems.", + "icon": "fas fa-volume-mute", + "color": "text-danger", + "price": 20000 + }, + "unpausable": { + "kind": "unpausable", + "title": "Unpausable", + "description": "Makes the profile anthem of the recipient unpausable.", + "icon": "fas fa-volume", + "color": "text-success", + "price": 40000 + }, } else: AWARDS = { @@ -324,6 +375,22 @@ def buy(v, award): "color": "text-black", "price": 1000 }, + "pause": { + "kind": "pause", + "title": "Pause", + "description": "Gives the recipient the ability to pause profile anthems.", + "icon": "fas fa-volume-mute", + "color": "text-danger", + "price": 20000 + }, + "unpausable": { + "kind": "unpausable", + "title": "Unpausable", + "description": "Makes the profile anthem of the recipient unpausable.", + "icon": "fas fa-volume", + "color": "text-success", + "price": 40000 + }, } if award not in AWARDS: abort(400) @@ -458,6 +525,10 @@ def award_post(pid, v): author.customtitle = filter_title(new_name) if len(author.customtitle) > 1000: abort(403) author.flairchanged = time.time() + 86400 + elif kind == "pause": + author.mute = True + elif kind == "unpausable": + author.unmutable = True post.author.received_award_count += 1 g.db.add(post.author) @@ -565,7 +636,9 @@ def award_comment(cid, v): author.customtitle = filter_title(new_name) if len(author.customtitle) > 1000: abort(403) author.flairchanged = time.time() + 86400 - + elif kind == "pause": author.mute = True + elif kind == "unpausable": author.unmutable = True + c.author.received_award_count += 1 g.db.add(c.author) diff --git a/files/templates/admin/awards.html b/files/templates/admin/awards.html index 6380e7bb4..6466a0e4d 100755 --- a/files/templates/admin/awards.html +++ b/files/templates/admin/awards.html @@ -55,7 +55,7 @@ {{a['title']}} - + {% endfor %} diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index 827cc2e59..530bff6d9 100755 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -76,7 +76,7 @@ @media (min-width: 767.98px) { .award-columns { - column-count: 5 !important; + column-count: 6 !important; } } \ No newline at end of file diff --git a/files/templates/shop.html b/files/templates/shop.html index aee2df219..105fc7edd 100644 --- a/files/templates/shop.html +++ b/files/templates/shop.html @@ -63,7 +63,7 @@ {% set kind = a['kind'] %} Buy - {% if v.procoins and kind not in ["agendaposter","grass"] %}Buy with Marseybux{% endif %} + {% if v.procoins and kind not in ["agendaposter","grass","pause","unpausable"] %}Buy with Marseybux{% endif %} {% endfor %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 8b65497ec..064c31bf7 100755 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -66,6 +66,24 @@ {% if u.song %} var audio = new Audio('/songs/{{u.id}}'); audio.loop=true; + + {% if not u.unmutable %} + function pause() { + audio.pause(); + document.getElementById("pause1").classList.toggle("d-none"); + document.getElementById("play1").classList.toggle("d-none"); + document.getElementById("pause2").classList.toggle("d-none"); + document.getElementById("play2").classList.toggle("d-none"); + } + + function play() { + audio.play(); + document.getElementById("pause1").classList.toggle("d-none"); + document.getElementById("play1").classList.toggle("d-none"); + document.getElementById("pause2").classList.toggle("d-none"); + document.getElementById("play2").classList.toggle("d-none"); + } + {% endif %} window.addEventListener( 'load', function() { audio.play(); @@ -74,28 +92,9 @@ }, {once : true}); }); - - {% if not u.unmutable %} - function pause() { - audio.pause(); - document.getElementById("pause").classList.toggle("d-none"); - document.getElementById("play").classList.toggle("d-none"); - } - - function play() { - audio.play(); - document.getElementById("pause").classList.toggle("d-none"); - document.getElementById("play").classList.toggle("d-none"); - } - {% endif %} {% endif %} -{% if not u.unmutable %} - Pause - Play -{% endif %} -
@@ -256,6 +255,12 @@ Edit profile Profile views {% endif %} + + {% if v and v.mute and not u.unmutable %} + Pause anthem + Play anthem + {% endif %} + {% if v and v.id != u.id and v.admin_level > 1 %}

@@ -463,7 +468,13 @@ {% if v and v.id == u.id %} Edit profile Profile views - {% endif %} + {% endif %} + + {% if v and v.mute and not u.unmutable %} + Pause anthem + Play anthem + {% endif %} + {% if v and v.id != u.id %} {% if u.id != 995 %}Unfollow{% endif %} Follow