Merge branch 'frost' of https://github.com/Aevann1/rDrama into frost

master
Aevann1 2022-07-12 20:01:22 +00:00
commit 03bb6c2c8d
8 changed files with 16 additions and 94 deletions

View File

@ -481,7 +481,8 @@ class User(Base):
Submission.deleted_utc == 0,
Submission.is_banned == False,
Submission.private == False,
Submission.author_id != self.id
Submission.author_id != self.id,
Submission.ghost == False
).count()
@property

View File

@ -146,41 +146,6 @@ def merge_all(v, id):
return redirect(user.url)
if SITE_NAME == 'PCM':
@app.get('/admin/sidebar')
@admin_level_required(3)
def get_sidebar(v):
try:
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
except:
sidebar = None
return render_template('admin/sidebar.html', v=v, sidebar=sidebar)
@app.post('/admin/sidebar')
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(3)
def post_sidebar(v):
text = request.values.get('sidebar', '').strip()
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+', encoding="utf-8") as f: f.write(text)
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
ma = ModAction(
kind="change_sidebar",
user_id=v.id,
)
g.db.add(ma)
return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!')
@app.post("/@<username>/make_admin")
@admin_level_required(3)
def make_admin(v, username):
@ -290,6 +255,7 @@ def revert_actions(v, username):
for item in posts + comments:
item.is_banned = False
item.ban_reason = None
item.is_approved = v.id
g.db.add(item)
users = (x[0] for x in g.db.query(ModAction.target_user_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind.in_(('shadowban', 'ban_user'))).all())
@ -1049,9 +1015,9 @@ def ban_user(user_id, v):
send_repeatable_notification(user.id, text)
if days == 0: duration = "permanent"
elif days == 1: duration = "1 day"
else: duration = f"{days} days"
if days == 0: duration = "permanently"
elif days == 1: duration = "for 1 day"
else: duration = f"for {days} days"
note = f'reason: "{reason}", duration: {duration}'
ma=ModAction(
@ -1523,6 +1489,7 @@ def admin_nunuke_user(v):
post.is_banned = False
post.ban_reason = None
post.is_approved = v.id
g.db.add(post)
for comment in g.db.query(Comment).filter_by(author_id=user.id).all():
@ -1531,6 +1498,7 @@ def admin_nunuke_user(v):
comment.is_banned = False
comment.ban_reason = None
comment.is_approved = v.id
g.db.add(comment)
ma=ModAction(

View File

@ -102,6 +102,7 @@ def notifications_posts(v):
Submission.is_banned == False,
Submission.private == False,
Submission.author_id != v.id,
Submission.ghost == False
).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()]
next_exists = (len(listing) > 25)

View File

@ -61,16 +61,10 @@
<li><a href="/daily_chart">Daily Stat Chart</a></li>
</ul>
{% if SITE_NAME in ['PCM', 'WPD'] -%}
<h4>Configuration</h4>
<ul>
{% if SITE_NAME == 'PCM' -%}
<li><a href="/admin/sidebar">Edit Sidebar</a></li>
{%- elif SITE_NAME == 'WPD' -%}
<li><a href="/create_hole">Create {{ HOLE_NAME | capitalize }}</a></li>
{%- endif %}
</ul>
{%- endif %}
<h4>Configuration</h4>
<ul>
<li><a href="/create_hole">Create {{ HOLE_NAME | capitalize }}</a></li>
</ul>
{% if v.admin_level > 2 %}
<pre></pre>

View File

@ -1,42 +0,0 @@
{% extends "default.html" %}
{% block pagetitle %}Edit {{SITE_NAME}} sidebar{% endblock %}
{% block content %}
{% 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 class="close" data-bs-dismiss="alert" aria-label="Close">
<span aria-hidden="true"><i class="far fa-times"></i></span>
</button>
</div>
{% endif %}
<div class="row my-5">
<div class="col col-md-8">
<div class="settings">
<div id="description">
<h2>Edit Sidebar</h2>
<br>
</div>
<div class="body d-lg-flex">
<div class="w-lg-100">
<form id="profile-settings" action="/admin/sidebar" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<textarea autocomplete="off" maxlength="10000" class="form-control rounded" id="bio-text" aria-label="With textarea" placeholder="Enter sidebar here..." rows="50" name="sidebar" form="profile-settings">{% if sidebar %}{{sidebar}}{% endif %}</textarea>
<div class="d-flex mt-2">
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Save">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -175,7 +175,7 @@
{% endif %}
{% if c.bannedfor %}
<i class="fas fa-hammer-crash text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User was banned for this comment for {{c.bannedfor}}"></i>
<i class="fas fa-hammer-crash text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User was banned for this comment {{c.bannedfor}}"></i>
{% endif %}
{% if c.active_flags(v) and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}<a class="btn btn-primary" style="padding:1px 5px; font-size:10px"role="button" onclick="document.getElementById('flaggers-{{c.id}}').classList.toggle('d-none')">{{c.active_flags(v)}} Report{{ help.plural(c.active_flags(v)) }}</a>{% endif %}
{% if c.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span>{% endif %}

View File

@ -636,7 +636,7 @@
{% endif %}
{% if p.bannedfor %}
<i class="fas fa-hammer-crash text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User was banned for this post for {{p.bannedfor}}"></i>
<i class="fas fa-hammer-crash text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User was banned for this post {{p.bannedfor}}"></i>
{% endif %}
{% for a in p.awards %}

View File

@ -163,7 +163,7 @@
{% endif %}
{% if p.bannedfor %}
<i class="fas fa-hammer-crash text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User was banned for this post for {{p.bannedfor}}"></i>
<i class="fas fa-hammer-crash text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User was banned for this post {{p.bannedfor}}"></i>
{% endif %}
{% for a in p.awards %}