forked from MarseyWorld/MarseyWorld
allow asset submitters to remove their pending shit
parent
aefc3703ce
commit
fda1f1e562
|
@ -149,18 +149,19 @@ def approve_marsey(v, name):
|
||||||
|
|
||||||
return {"message": f"'{marsey.name}' approved!"}
|
return {"message": f"'{marsey.name}' approved!"}
|
||||||
|
|
||||||
@app.post("/admin/reject/marsey/<name>")
|
|
||||||
@admin_level_required(3)
|
|
||||||
def reject_marsey(v, name):
|
|
||||||
if CARP_ID and v.id != CARP_ID:
|
|
||||||
return {"error": "Only Carp can reject marseys!"}, 403
|
|
||||||
|
|
||||||
|
@app.post("/remove/marsey/<name>")
|
||||||
|
@auth_required
|
||||||
|
def remove_marsey(v, name):
|
||||||
name = name.lower().strip()
|
name = name.lower().strip()
|
||||||
|
|
||||||
marsey = g.db.query(Marsey).filter_by(name=name).one_or_none()
|
marsey = g.db.query(Marsey).filter_by(name=name).one_or_none()
|
||||||
if not marsey:
|
if not marsey:
|
||||||
return {"error": f"This marsey '{name}' doesn't exist!"}, 404
|
return {"error": f"This marsey '{name}' doesn't exist!"}, 404
|
||||||
|
|
||||||
|
if v.id not in {marsey.submitter_id, CARP_ID}:
|
||||||
|
return {"error": "Only Carp can remove marseys!"}, 403
|
||||||
|
|
||||||
if v.id != marsey.submitter_id:
|
if v.id != marsey.submitter_id:
|
||||||
msg = f"@{v.username} has rejected a marsey you submitted: `'{marsey.name}'`"
|
msg = f"@{v.username} has rejected a marsey you submitted: `'{marsey.name}'`"
|
||||||
send_repeatable_notification(marsey.submitter_id, msg)
|
send_repeatable_notification(marsey.submitter_id, msg)
|
||||||
|
@ -168,7 +169,7 @@ def reject_marsey(v, name):
|
||||||
g.db.delete(marsey)
|
g.db.delete(marsey)
|
||||||
os.remove(f"/asset_submissions/marseys/{marsey.name}.webp")
|
os.remove(f"/asset_submissions/marseys/{marsey.name}.webp")
|
||||||
|
|
||||||
return {"message": f"'{marsey.name}' rejected!"}
|
return {"message": f"'{marsey.name}' removed!"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,18 +299,19 @@ def approve_hat(v, name):
|
||||||
|
|
||||||
return {"message": f"'{hat.name}' approved!"}
|
return {"message": f"'{hat.name}' approved!"}
|
||||||
|
|
||||||
@app.post("/admin/reject/hat/<name>")
|
|
||||||
@admin_level_required(3)
|
|
||||||
def reject_hat(v, name):
|
|
||||||
if CARP_ID and v.id != CARP_ID:
|
|
||||||
return {"error": "Only Carp can reject hats!"}, 403
|
|
||||||
|
|
||||||
|
@app.post("/remove/hat/<name>")
|
||||||
|
@auth_required
|
||||||
|
def remove_hat(v, name):
|
||||||
name = name.strip()
|
name = name.strip()
|
||||||
|
|
||||||
hat = g.db.query(HatDef).filter_by(name=name).one_or_none()
|
hat = g.db.query(HatDef).filter_by(name=name).one_or_none()
|
||||||
if not hat:
|
if not hat:
|
||||||
return {"error": f"This hat '{name}' doesn't exist!"}, 404
|
return {"error": f"This hat '{name}' doesn't exist!"}, 404
|
||||||
|
|
||||||
|
if v.id not in {hat.submitter_id, CARP_ID}:
|
||||||
|
return {"error": "Only Carp can remove hats!"}, 403
|
||||||
|
|
||||||
if v.id != hat.submitter_id:
|
if v.id != hat.submitter_id:
|
||||||
msg = f"@{v.username} has rejected a hat you submitted: `'{hat.name}'`"
|
msg = f"@{v.username} has rejected a hat you submitted: `'{hat.name}'`"
|
||||||
send_repeatable_notification(hat.submitter_id, msg)
|
send_repeatable_notification(hat.submitter_id, msg)
|
||||||
|
@ -317,4 +319,4 @@ def reject_hat(v, name):
|
||||||
g.db.delete(hat)
|
g.db.delete(hat)
|
||||||
os.remove(f"/asset_submissions/hats/{hat.name}.webp")
|
os.remove(f"/asset_submissions/hats/{hat.name}.webp")
|
||||||
|
|
||||||
return {"message": f"'{hat.name}' rejected!"}
|
return {"message": f"'{hat.name}' removed!"}
|
|
@ -133,6 +133,24 @@
|
||||||
t.classList.remove("disabled");
|
t.classList.remove("disabled");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remove_hat(t, name) {
|
||||||
|
t.disabled = true;
|
||||||
|
t.classList.add("disabled");
|
||||||
|
post_toast_callback(`/remove/hat/${name}`,
|
||||||
|
{
|
||||||
|
},
|
||||||
|
(xhr) => {
|
||||||
|
if(xhr.status == 200) {
|
||||||
|
document.getElementById(`${name}-hat`).remove()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setTimeout(() => {
|
||||||
|
t.disabled = false;
|
||||||
|
t.classList.remove("disabled");
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h2 class="mt-5 mx-4">Pending Carp Approval</h2>
|
<h2 class="mt-5 mx-4">Pending Carp Approval</h2>
|
||||||
|
@ -164,13 +182,13 @@
|
||||||
<input autocomplete="off" type="number" id="{{hat.name}}-price" class="form-control" name="price" min="0" value="{{hat.price}}" required>
|
<input autocomplete="off" type="number" id="{{hat.name}}-price" class="form-control" name="price" min="0" value="{{hat.price}}" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if v.admin_level > 2 %}
|
|
||||||
<div class="d-flex my-4 mx-3">
|
<div class="d-flex my-4 mx-3">
|
||||||
<a role="button" class="btn btn-secondary ml-auto mr-2" onclick="post_toast(this,'/admin/reject/hat/{{hat.name}}', true)">Reject</a>
|
<a role="button" class="btn btn-primary ml-auto" onclick="remove_hat(this, '{{hat.name}}')">Remove</a>
|
||||||
<a role="button" class="btn btn-primary mr-0" onclick="approve_hat(this, '{{hat.name}}')">Approve</a>
|
{% if v.admin_level > 2 %}
|
||||||
</div>
|
<a role="button" class="btn btn-primary ml-3" onclick="approve_hat(this, '{{hat.name}}')">Approve</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -134,6 +134,24 @@
|
||||||
t.classList.remove("disabled");
|
t.classList.remove("disabled");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remove_marsey(t, name) {
|
||||||
|
t.disabled = true;
|
||||||
|
t.classList.add("disabled");
|
||||||
|
post_toast_callback(`/remove/marsey/${name}`,
|
||||||
|
{
|
||||||
|
},
|
||||||
|
(xhr) => {
|
||||||
|
if(xhr.status == 200) {
|
||||||
|
document.getElementById(`${name}-marsey`).remove()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setTimeout(() => {
|
||||||
|
t.disabled = false;
|
||||||
|
t.classList.remove("disabled");
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h2 class="mt-5 mx-4">Pending Carp Approval</h2>
|
<h2 class="mt-5 mx-4">Pending Carp Approval</h2>
|
||||||
|
@ -162,13 +180,13 @@
|
||||||
<input autocomplete="off" type="text" id="{{marsey.name}}-tags" class="form-control" name="tags" maxlength="200" value="{{marsey.tags}}" pattern='[a-z0-9: ]{1,200}' required>
|
<input autocomplete="off" type="text" id="{{marsey.name}}-tags" class="form-control" name="tags" maxlength="200" value="{{marsey.tags}}" pattern='[a-z0-9: ]{1,200}' required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if v.admin_level > 2 %}
|
|
||||||
<div class="d-flex my-4 mx-3">
|
<div class="d-flex my-4 mx-3">
|
||||||
<a role="button" class="btn btn-secondary ml-auto mr-2" onclick="post_toast(this,'/admin/reject/marsey/{{marsey.name}}', true)">Reject</a>
|
<a role="button" class="btn btn-primary ml-auto" onclick="remove_marsey(this, '{{marsey.name}}')">Remove</a>
|
||||||
<a role="button" class="btn btn-primary mr-0" onclick="approve_marsey(this, '{{marsey.name}}')">Approve</a>
|
{% if v.admin_level > 2 %}
|
||||||
</div>
|
<a role="button" class="btn btn-primary ml-3" onclick="approve_marsey(this, '{{marsey.name}}')">Approve</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue