more approval/removal refactors
parent
5d846e64c7
commit
80eedbd58d
|
@ -98,11 +98,19 @@ function delete_commentModal(id) {
|
|||
try {data = JSON.parse(xhr[0].response)}
|
||||
catch(e) {console.log(e)}
|
||||
if (xhr[0].status >= 200 && xhr[0].status < 300 && data && data['message']) {
|
||||
if (window.location.pathname == '/admin/reported/comments')
|
||||
{
|
||||
document.getElementById("post-info-"+id).remove()
|
||||
document.getElementById("comment-"+id).remove()
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementsByClassName(`comment-${id}-only`)[0].classList.add('deleted');
|
||||
document.getElementById(`delete-${id}`).classList.add('d-none');
|
||||
document.getElementById(`undelete-${id}`).classList.remove('d-none');
|
||||
document.getElementById(`delete2-${id}`).classList.add('d-none');
|
||||
document.getElementById(`undelete2-${id}`).classList.remove('d-none');
|
||||
}
|
||||
showToast(true, getMessageFromJsonData(true, data));
|
||||
} else {
|
||||
showToast(false, getMessageFromJsonData(false, data));
|
||||
|
|
|
@ -8,11 +8,19 @@ function delete_postModal(id) {
|
|||
success = xhr[0].status >= 200 && xhr[0].status < 300;
|
||||
showToast(success, getMessageFromJsonData(success, data));
|
||||
if (success && data["message"]) {
|
||||
if (window.location.pathname == '/admin/reported/posts')
|
||||
{
|
||||
document.getElementById("flaggers-"+id).remove()
|
||||
document.getElementById("post-"+id).remove()
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById(`post-${id}`).classList.add('deleted');
|
||||
document.getElementById(`delete-${id}`).classList.add('d-none');
|
||||
document.getElementById(`undelete-${id}`).classList.remove('d-none');
|
||||
document.getElementById(`delete2-${id}`).classList.add('d-none');
|
||||
document.getElementById(`undelete2-${id}`).classList.remove('d-none');
|
||||
}
|
||||
} else {
|
||||
showToast(false, getMessageFromJsonData(false, data));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
function removePost(t,post_id,button1,button2,cls) {
|
||||
url="/remove_post/"+post_id
|
||||
|
||||
post_toast(t,url,button1,button2,cls)
|
||||
|
||||
if (window.location.pathname == '/admin/reported/posts')
|
||||
{
|
||||
document.getElementById("flaggers-"+post_id).remove()
|
||||
document.getElementById("post-"+post_id).remove()
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("post-"+post_id).classList.add("banned");
|
||||
}
|
||||
};
|
||||
|
||||
function approvePost(t,post_id,button1,button2,cls) {
|
||||
url="/approve_post/"+post_id
|
||||
|
||||
post_toast(t,url,button1,button2,cls)
|
||||
|
||||
if (window.location.pathname == '/admin/reported/posts')
|
||||
{
|
||||
document.getElementById("flaggers-"+post_id).remove()
|
||||
document.getElementById("post-"+post_id).remove()
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("post-"+post_id).classList.remove("banned");
|
||||
}
|
||||
}
|
|
@ -382,7 +382,8 @@ def reported_posts(v):
|
|||
|
||||
listing = g.db.query(Submission).filter_by(
|
||||
is_approved=None,
|
||||
is_banned=False
|
||||
is_banned=False,
|
||||
deleted_utc=0
|
||||
).join(Submission.flags).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
|
@ -404,7 +405,8 @@ def reported_comments(v):
|
|||
listing = g.db.query(Comment
|
||||
).filter_by(
|
||||
is_approved=None,
|
||||
is_banned=False
|
||||
is_banned=False,
|
||||
deleted_utc=0
|
||||
).join(Comment.flags).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
|
|
|
@ -61,14 +61,12 @@
|
|||
{% endif %}
|
||||
|
||||
{% if v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
|
||||
{% if "/reported/" in request.path %}
|
||||
{% if v.id != p.author.id %}<a class="dropdown-item list-inline-item text-danger" role="button" onclick="post_toast(this,'/remove_post/{{p.id}}')"><i class="fas fa-ban"></i>Remove</a>{% endif %}
|
||||
<a class="dropdown-item list-inline-item text-success" role="button" onclick="post_toast(this,'/approve_post/{{p.id}}')"><i class="fas fa-check"></i>Approve</a>
|
||||
{% else %}
|
||||
{% if v.id != p.author.id %}<a id="remove-{{p.id}}" class="dropdown-item {% if p.is_banned %}d-none{% endif %} list-inline-item text-danger" role="button" onclick="post_toast(this,'/remove_post/{{p.id}}','remove-{{p.id}}','approve-{{p.id}}','d-none')"><i class="fas fa-ban"></i>Remove</a>{% endif %}
|
||||
<a id="approve-{{p.id}}" class="dropdown-item {% if not p.is_banned %}d-none{% endif %} list-inline-item text-success" role="button" onclick="post_toast(this,'/approve_post/{{p.id}}','remove-{{p.id}}','approve-{{p.id}}','d-none')"><i class="fas fa-check"></i>Approve</a>
|
||||
{% if v.id != p.author.id %}
|
||||
<a id="remove-{{p.id}}" class="dropdown-item {% if p.is_banned %}d-none{% endif %} list-inline-item text-danger" role="button" onclick="removePost(this,'{{p.id}}','remove-{{p.id}}','approve-{{p.id}}','d-none')"><i class="fas fa-ban"></i>Remove</a>
|
||||
{% endif %}
|
||||
|
||||
<a id="approve-{{p.id}}" class="dropdown-item {% if not p.is_banned and request.path != '/admin/reported/posts' %}d-none{% endif %} list-inline-item text-success" role="button" onclick="approvePost(this,'{{p.id}}','remove-{{p.id}}','approve-{{p.id}}','d-none')"><i class="fas fa-check"></i>Approve</a>
|
||||
|
||||
{% if p.oauth_app %}
|
||||
<a class="dropdown-item list-inline-item" href="{{p.oauth_app.permalink}}"><i class="fas fa-code"></i>API App</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -25,13 +25,12 @@
|
|||
{% if v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
|
||||
<button id="pin2-{{p.id}}" class="{% if p.stickied and not p.stickied_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" role="button" onclick="pinPost(this,'{{p.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center text-primary mr-2"></i>Pin {% if p.stickied_utc %}permanently{% else %}for 1 hour{% endif %}</button>
|
||||
<button id="unpin2-{{p.id}}" class="{% if not p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" role="button" onclick="post_toast(this,'/unsticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-center text-primary mr-2"></i>Unpin</button>
|
||||
{% if "/reported/" in request.path %}
|
||||
<button class="nobackground btn btn-link btn-block btn-lg text-danger text-left" role="button" onclick="post_toast(this,'/remove_post/{{p.id}}')" data-bs-dismiss="modal"><i class="far fa-ban text-center mr-2"></i>Remove</button>
|
||||
<button class="nobackground btn btn-link btn-block btn-lg text-success text-left" role="button" onclick="post_toast(this,'/approve_post/{{p.id}}')" data-bs-dismiss="modal"><i class="far fa-check text-center mr-2"></i>Approve</button>
|
||||
{% else %}
|
||||
<button id="remove2-{{p.id}}" class="{% if p.is_banned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" role="button" onclick="post_toast(this,'/remove_post/{{p.id}}','remove2-{{p.id}}','approve2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-ban text-center mr-2"></i>Remove</button>
|
||||
<button id="approve2-{{p.id}}" class="{% if not p.is_banned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" role="button" onclick="post_toast(this,'/approve_post/{{p.id}}','remove2-{{p.id}}','approve2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-check text-center mr-2"></i>Approve</button>
|
||||
|
||||
{% if v.id != p.author.id %}
|
||||
<button id="remove2-{{p.id}}" class="{% if p.is_banned %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" role="button" onclick="removePost(this,'{{p.id}}','remove2-{{p.id}}','approve2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-ban text-center mr-2"></i>Remove</button>
|
||||
{% endif %}
|
||||
|
||||
<button id="approve2-{{p.id}}" class="{% if not p.is_banned and request.path != '/admin/reported/posts' %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" role="button" onclick="approvePost(this,'{{p.id}}','remove2-{{p.id}}','approve2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-check text-center mr-2"></i>Approve</button>
|
||||
{% endif %}
|
||||
{% if p.oauth_app and v.admin_level >= PERMS['APPS_MODERATION'] %}
|
||||
<a href="{{p.oauth_app.permalink}}"><button class="nobackground btn btn-link btn-block btn-lg text-muted text-left"><i class="far fa-code text-center text-info mr-2"></i>API App</button></a>
|
||||
|
|
|
@ -423,3 +423,6 @@
|
|||
<script defer src="{{'js/clipboard.js' | asset}}"></script>
|
||||
<script defer src="{{'js/comments+submission_listing.js' | asset}}"></script>
|
||||
<script defer src="{{'js/submission_listing.js' | asset}}"></script>
|
||||
{% if v and v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
|
||||
<script defer src="{{'js/submission_listing_admin.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue