mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-24 14:07:03 +01:00
Add reasons to admin token transactions
This commit is contained in:
parent
247133229c
commit
dad92d1e53
@ -213,11 +213,12 @@ def manage_titan_tokens():
|
||||
def post_titan_tokens():
|
||||
user_id = request.form.get("user_id", None)
|
||||
amount = request.form.get("amount", None, type=int)
|
||||
reason = request.form.get("reason", None)
|
||||
if not user_id or not amount:
|
||||
abort(400)
|
||||
if get_titan_token(user_id) != -1:
|
||||
abort(409)
|
||||
set_titan_token(user_id, amount, "NEW VIA ADMIN")
|
||||
set_titan_token(user_id, amount, "NEW VIA ADMIN [{}]".format(str(reason)))
|
||||
return ('', 204)
|
||||
|
||||
@admin.route("/tokens", methods=["PATCH"])
|
||||
@ -225,9 +226,10 @@ def post_titan_tokens():
|
||||
def patch_titan_tokens():
|
||||
user_id = request.form.get("user_id", None)
|
||||
amount = request.form.get("amount", None, type=int)
|
||||
reason = request.form.get("reason", None)
|
||||
if not user_id or not amount:
|
||||
abort(400)
|
||||
if get_titan_token(user_id) == -1:
|
||||
abort(409)
|
||||
set_titan_token(user_id, amount, "MODIFY VIA ADMIN")
|
||||
set_titan_token(user_id, amount, "MODIFY VIA ADMIN [{}]".format(str(reason)))
|
||||
return ('', 204)
|
@ -1,19 +1,19 @@
|
||||
/* global $, Materialize, location */
|
||||
|
||||
function postForm(user_id, amount) {
|
||||
function postForm(user_id, amount, reason) {
|
||||
var funct = $.ajax({
|
||||
dataType: "json",
|
||||
method: "POST",
|
||||
data: {"user_id": user_id, "amount": amount}
|
||||
data: {"user_id": user_id, "amount": amount, "reason": reason}
|
||||
});
|
||||
return funct.promise();
|
||||
}
|
||||
|
||||
function patchForm(user_id, amount) {
|
||||
function patchForm(user_id, amount, reason) {
|
||||
var funct = $.ajax({
|
||||
dataType: "json",
|
||||
method: "PATCH",
|
||||
data: {"user_id": user_id, "amount": amount}
|
||||
data: {"user_id": user_id, "amount": amount, "reason": reason}
|
||||
});
|
||||
return funct.promise();
|
||||
}
|
||||
@ -22,11 +22,12 @@ $(function() {
|
||||
$("#new_submit").click(function () {
|
||||
var user_id = $("#new_user_id").val();
|
||||
var user_token = $("#new_user_token").val();
|
||||
var reason = $("#new_reason").val();
|
||||
if (user_id.length < 1 || user_token.length < 1) {
|
||||
Materialize.toast("The user ID or balance field can't be blank!", 2000);
|
||||
return;
|
||||
}
|
||||
var formPost = postForm(user_id, user_token);
|
||||
var formPost = postForm(user_id, user_token, reason);
|
||||
formPost.done(function (data) {
|
||||
location.reload();
|
||||
});
|
||||
@ -42,7 +43,8 @@ $(function() {
|
||||
|
||||
function submit_modify_user(user_id) {
|
||||
var amount = $("#input_"+user_id).val();
|
||||
var formPatch = patchForm(user_id, amount);
|
||||
var reason = $("#input_reason_"+user_id).val();
|
||||
var formPatch = patchForm(user_id, amount, reason);
|
||||
formPatch.done(function (data) {
|
||||
location.reload();
|
||||
});
|
||||
|
@ -13,6 +13,7 @@
|
||||
<tr>
|
||||
<th>User ID</th>
|
||||
<th>Starting Balance</th>
|
||||
<th>Reason</th>
|
||||
<th>Submit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -28,6 +29,11 @@
|
||||
<input id="new_user_token" placeholder="Starting Balance" type="number">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-field inline">
|
||||
<input id="new_reason" placeholder="Reason">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a class="waves-effect waves-light btn" id="new_submit">Submit</a>
|
||||
</td>
|
||||
@ -49,6 +55,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Modify Amount</th>
|
||||
<th>Reason</th>
|
||||
<th>Submit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -58,7 +65,11 @@
|
||||
<div class="input-field inline">
|
||||
<input placeholder="Modify Amount" type="number" id="input_{{ don.user_id }}">
|
||||
</div>
|
||||
<p>(Place a subtract sign in the front to remove tokens. Otherwise, it will add the amount)</p>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-field inline">
|
||||
<input placeholder="Reason" id="input_reason_{{ don.user_id }}">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a class="waves-effect waves-light btn" onclick="submit_modify_user('{{ don.user_id }}')">Submit</a>
|
||||
@ -66,7 +77,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>(Place a subtract sign in the front to remove tokens. Otherwise, it will add the amount)</p>
|
||||
<h4>Balance: <strong>{{ don.tokens }}</strong> Tokens</h4>
|
||||
<table class="striped">
|
||||
<thead>
|
||||
|
Loading…
Reference in New Issue
Block a user