vcxxcv
This commit is contained in:
parent
274f60cfa9
commit
68d445d97a
9 changed files with 41 additions and 214 deletions
|
@ -1,5 +1,3 @@
|
|||
const playing = localStorage.getItem("playing")
|
||||
|
||||
let u_username = document.getElementById('u_username')
|
||||
|
||||
if (u_username)
|
||||
|
@ -10,33 +8,14 @@ if (u_username)
|
|||
audio.loop=true;
|
||||
|
||||
function toggle() {
|
||||
if (audio.paused)
|
||||
{
|
||||
audio.play()
|
||||
localStorage.setItem("playing", "1")
|
||||
window.addEventListener("unload", function(e) {
|
||||
localStorage.setItem("playing", "")
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
audio.pause()
|
||||
localStorage.setItem("playing", "")
|
||||
}
|
||||
if (audio.paused) audio.play()
|
||||
else audio.pause()
|
||||
}
|
||||
|
||||
if (!playing)
|
||||
{
|
||||
audio.play();
|
||||
document.getElementById('userpage').addEventListener('click', () => {
|
||||
if (audio.paused) audio.play();
|
||||
}, {once : true});
|
||||
|
||||
localStorage.setItem("playing", "1")
|
||||
window.addEventListener("unload", function(e) {
|
||||
localStorage.setItem("playing", "")
|
||||
});
|
||||
}
|
||||
audio.play();
|
||||
document.getElementById('userpage').addEventListener('click', () => {
|
||||
if (audio.paused) audio.play();
|
||||
}, {once : true});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -55,30 +34,20 @@ else
|
|||
{
|
||||
audio.play()
|
||||
localStorage.setItem("paused", "")
|
||||
localStorage.setItem("playing", "1")
|
||||
window.addEventListener("unload", function(e) {
|
||||
localStorage.setItem("playing", "")
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
audio.pause()
|
||||
localStorage.setItem("paused", "1")
|
||||
localStorage.setItem("playing", "")
|
||||
}
|
||||
}
|
||||
|
||||
if (!paused && !playing)
|
||||
if (!paused)
|
||||
{
|
||||
audio.play();
|
||||
document.getElementById('userpage').addEventListener('click', () => {
|
||||
if (audio.paused) audio.play();
|
||||
}, {once : true});
|
||||
|
||||
localStorage.setItem("playing", "1")
|
||||
window.addEventListener("unload", function(e) {
|
||||
localStorage.setItem("playing", "")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ class Submission(Base):
|
|||
approved_by = relationship("User", uselist=False, primaryjoin="Submission.is_approved==User.id", viewonly=True)
|
||||
awards = relationship("AwardRelationship", viewonly=True)
|
||||
reports = relationship("Flag", viewonly=True)
|
||||
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id", viewonly=True)
|
||||
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -357,9 +357,7 @@ class Submission(Base):
|
|||
def realbody(self, v):
|
||||
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{CC} ONLY</p>"
|
||||
|
||||
body = self.body_html
|
||||
|
||||
if not body: return ""
|
||||
body = self.body_html or ""
|
||||
|
||||
body = censor_slurs(body, v)
|
||||
|
||||
|
@ -382,6 +380,29 @@ class Submission(Base):
|
|||
g.db.add(self.author)
|
||||
g.db.commit()
|
||||
|
||||
for o in self.options:
|
||||
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{o.id}" name="option"'
|
||||
if o.poll_voted(v): body += " checked"
|
||||
if v: body += f''' onchange="poll_vote('{o.id}', '{self.id}')"'''
|
||||
else: body += f''' onchange="poll_vote_no_v('{o.id}', '{self.id}')"'''
|
||||
body += f'''><label class="custom-control-label" for="{o.id}">{o.body_html}<span class="presult-{self.id}'''
|
||||
if not self.total_poll_voted(v): body += ' d-none'
|
||||
body += f'"> - <a href="/votes?link=t3_{o.id}"><span id="poll-{o.id}">{o.upvotes}</span> votes</a></span></label></div>'
|
||||
|
||||
|
||||
for c in self.bet_options:
|
||||
body += f'''<div class="custom-control mt-3"><input autocomplete="off" class="custom-control-input bet" type="radio" id="{c.id}" onchange="bet_vote('{c.id}')"'''
|
||||
if c.poll_voted(v): body += " checked "
|
||||
if not (v and v.coins > 200) or self.total_bet_voted(v): body += " disabled "
|
||||
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html} - <a href="/votes?link=t3_{c.id}"><span id="bet-{c.id}">{c.upvotes}</span> bets</a>'''
|
||||
if not self.total_bet_voted(v):
|
||||
body += '''<span class="cost"> (cost of entry: 200 coins)</span>'''
|
||||
body += "</label>"
|
||||
if v and v.admin_level > 2:
|
||||
body += f'''<button class="btn btn-primary px-2 mx-2" style="font-size:10px;padding:2px;margin-top:-5px" onclick="post_toast('/distribute/{c.id}')">Declare winner</button>'''
|
||||
body += "</div>"
|
||||
|
||||
|
||||
if self.author.sig_html and not self.ghost and (self.author_id == MOOSE_ID or not (v and v.sigs_disabled)):
|
||||
body += f"<hr>{self.author.sig_html}"
|
||||
|
||||
|
|
|
@ -588,73 +588,3 @@ def award_comment(cid, v):
|
|||
if request.referrer and len(request.referrer) > 1 and request.host in request.referrer:
|
||||
return redirect(request.referrer)
|
||||
return redirect("/")
|
||||
|
||||
@app.get("/admin/awards")
|
||||
@admin_level_required(2)
|
||||
def admin_userawards_get(v):
|
||||
|
||||
if v.admin_level != 3:
|
||||
return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v)
|
||||
|
||||
return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v)
|
||||
|
||||
@app.post("/admin/awards")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@admin_level_required(2)
|
||||
def admin_userawards_post(v):
|
||||
|
||||
try: u = request.values.get("username").strip()
|
||||
except: abort(404)
|
||||
|
||||
u = get_user(u, graceful=False, v=v)
|
||||
|
||||
notify_awards = {}
|
||||
|
||||
latest = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first()
|
||||
thing = latest.id
|
||||
|
||||
for key, value in request.values.items():
|
||||
if key not in AWARDS: continue
|
||||
|
||||
if value:
|
||||
|
||||
if int(value) > 10: abort(403)
|
||||
|
||||
if int(value): notify_awards[key] = int(value)
|
||||
|
||||
for x in range(int(value)):
|
||||
thing += 1
|
||||
|
||||
award = AwardRelationship(
|
||||
id=thing,
|
||||
user_id=u.id,
|
||||
kind=key
|
||||
)
|
||||
|
||||
g.db.add(award)
|
||||
|
||||
if v.id != u.id:
|
||||
text = "You were given the following awards:\n\n"
|
||||
for key, value in notify_awards.items():
|
||||
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
|
||||
send_repeatable_notification(u.id, text)
|
||||
|
||||
note = ""
|
||||
|
||||
for key, value in notify_awards.items():
|
||||
note += f"{value} {AWARDS[key]['title']}, "
|
||||
|
||||
if len(note) > 256: return {"error": "You're giving too many awards at the same time!"}
|
||||
|
||||
ma=ModAction(
|
||||
kind="grant_awards",
|
||||
user_id=v.id,
|
||||
target_user_id=u.id,
|
||||
_note=note[:-2]
|
||||
)
|
||||
g.db.add(ma)
|
||||
|
||||
g.db.commit()
|
||||
|
||||
if v.admin_level != 3: return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v)
|
||||
return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v)
|
|
@ -256,16 +256,10 @@ def transfer_coins(v, username):
|
|||
if v.coins < amount: return {"error": f"You don't have enough coins."}, 400
|
||||
if amount < 100: return {"error": f"You have to gift at least 100 coins."}, 400
|
||||
|
||||
if not v.patron and not receiver.patron and not v.alts_patron and not receiver.alts_patron:
|
||||
tax = math.ceil(amount*0.03)
|
||||
tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).one_or_none()
|
||||
tax_receiver.coins += tax
|
||||
g.db.add(tax_receiver)
|
||||
else: tax = 0
|
||||
tax = math.ceil(amount*0.03)
|
||||
|
||||
if TAX_RECEIVER_ID:
|
||||
log_message = f"@{v.username} has transferred {amount} coins to @{receiver.username}"
|
||||
send_repeatable_notification(TAX_RECEIVER_ID, log_message)
|
||||
log_message = f"@{v.username} has transferred {amount} coins to @{receiver.username}"
|
||||
send_repeatable_notification(CARP_ID, log_message)
|
||||
|
||||
receiver.coins += amount-tax
|
||||
v.coins -= amount
|
||||
|
@ -295,9 +289,8 @@ def transfer_bux(v, username):
|
|||
if v.procoins < amount: return {"error": "You don't have enough marseybux"}, 400
|
||||
if amount < 100: return {"error": "You have to gift at least 100 marseybux."}, 400
|
||||
|
||||
if TAX_RECEIVER_ID:
|
||||
log_message = f"@{v.username} has transferred {amount} Marseybux to @{receiver.username}"
|
||||
send_repeatable_notification(TAX_RECEIVER_ID, log_message)
|
||||
log_message = f"@{v.username} has transferred {amount} Marseybux to @{receiver.username}"
|
||||
send_repeatable_notification(CARP_ID, log_message)
|
||||
|
||||
receiver.procoins += amount
|
||||
v.procoins -= amount
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
{% extends "default.html" %}
|
||||
|
||||
{% block title %}
|
||||
<title>Grant User Award</title>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagetype %}message{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert-danger alert-dismissible fade show my-3" role="alert">
|
||||
<i class="fas fa-exclamation-circle my-auto"></i>
|
||||
<span>
|
||||
{{error}}
|
||||
</span>
|
||||
<button role="button" class="close" data-bs-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if msg %}
|
||||
<div class="alert alert-success alert-dismissible fade show my-3" role="alert">
|
||||
<i class="fas fa-check-circle my-auto" aria-hidden="true"></i>
|
||||
<span>
|
||||
{{msg}}
|
||||
</span>
|
||||
<button role="button" class="close" data-bs-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<pre></pre>
|
||||
<pre></pre>
|
||||
<h5>User Award Grant</h5>
|
||||
|
||||
<form action="/admin/awards", method="post">
|
||||
<input autocomplete="off" type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<label for="input-username">Username</label><br>
|
||||
<input autocomplete="off" id="input-username" class="form-control mb-3" type="text" name="username" required>
|
||||
|
||||
<div class="overflow-x-auto"><table class="table table-striped">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th scope="col">Icon</th>
|
||||
<th scope="col">Title</th>
|
||||
<th scope="col">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for a in awards %}
|
||||
<tr>
|
||||
<td><i class="{{a['icon']}} {{a['color']}}" style="font-size: 30px"></i></td>
|
||||
<td style="font-weight: bold">{{a['title']}}</td>
|
||||
<td><input autocomplete="off" type="number" class="form-control" name="{{a['kind']}}" value="0" min="0" max="10" placeholder="Enter amount..." ></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<input autocomplete="off" class="btn btn-primary mt-3" type="submit" value="Grant Awards">
|
||||
|
||||
</form>
|
||||
|
||||
<pre></pre>
|
||||
{% if request.host != 'rdrama.net' or v.id == AEVANN_ID %}
|
||||
<div><a class="btn btn-danger" role="button" onclick="post_toast('/admin/monthly')">Grant Monthly Marseybux</a></div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -524,23 +524,6 @@
|
|||
{% endif %}
|
||||
{{p.realbody(v) | safe}}
|
||||
|
||||
{% for c in p.options %}
|
||||
<div class="custom-control">
|
||||
<input autocomplete="off" type="checkbox" class="custom-control-input" id="{{c.id}}" name="option" {% if c.poll_voted(v) %}checked{% endif %} onchange="{% if v %}poll_vote('{{c.id}}'){% else %}poll_vote_no_v(){% endif %}">
|
||||
<label class="custom-control-label" for="{{c.id}}">{{c.body_html | safe}}<span class="presult {% if not p.total_poll_voted(v) %}d-none{% endif %}"> - <a href="/votes?link=t3_{{c.id}}"><span id="poll-{{c.id}}">{{c.upvotes}}</span> votes</a></span></label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for c in p.bet_options %}
|
||||
<div class="custom-control mt-3">
|
||||
<input autocomplete="off" {% if c.poll_voted(v) %}checked{% endif %} class="custom-control-input bet" {% if not (v and v.coins > 200) or p.total_bet_voted(v) %}disabled{% endif %} type="radio" id="{{c.id}}" onchange="bet_vote('{{c.id}}')">
|
||||
<label class="custom-control-label" for="{{c.id}}">{{c.body_html | safe}} - <a href="/votes?link=t3_{{c.id}}"><span id="bet-{{c.id}}">{{c.upvotes}}</span> bets</a>{% if not p.total_bet_voted(v) %}<span class="cost"> (cost of entry: 200 coins)</span>{% endif %}</label>
|
||||
{% if v and v.admin_level > 2 %}
|
||||
<button class="btn btn-primary px-2 mx-2" style="font-size:10px;padding:2px;margin-top:-5px" onclick="post_toast('/distribute/{{c.id}}')">Declare winner</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if p.is_banned and p.ban_reason %}
|
||||
<div class="text-removed mb-0">removed by @{{p.ban_reason}}</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -698,7 +698,7 @@
|
|||
<div id="username" class="d-none">{{u.username}}</div>
|
||||
{% endif %}
|
||||
|
||||
<script src="/static/assets/js/userpage.js?a=221"></script>
|
||||
<script src="/static/assets/js/userpage.js?a=222"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -114,5 +114,5 @@
|
|||
<div id="username" class="d-none">{{u.username}}</div>
|
||||
{% endif %}
|
||||
|
||||
<script src="/static/assets/js/userpage.js?a=221"></script>
|
||||
<script src="/static/assets/js/userpage.js?a=222"></script>
|
||||
{% endblock %}
|
|
@ -48,5 +48,5 @@
|
|||
<div id="username" class="d-none">{{u.username}}</div>
|
||||
{% endif %}
|
||||
|
||||
<script src="/static/assets/js/userpage.js?a=221"></script>
|
||||
<script src="/static/assets/js/userpage.js?a=222"></script>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue