mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-14 18:11:23 +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():
|
def post_titan_tokens():
|
||||||
user_id = request.form.get("user_id", None)
|
user_id = request.form.get("user_id", None)
|
||||||
amount = request.form.get("amount", None, type=int)
|
amount = request.form.get("amount", None, type=int)
|
||||||
|
reason = request.form.get("reason", None)
|
||||||
if not user_id or not amount:
|
if not user_id or not amount:
|
||||||
abort(400)
|
abort(400)
|
||||||
if get_titan_token(user_id) != -1:
|
if get_titan_token(user_id) != -1:
|
||||||
abort(409)
|
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)
|
return ('', 204)
|
||||||
|
|
||||||
@admin.route("/tokens", methods=["PATCH"])
|
@admin.route("/tokens", methods=["PATCH"])
|
||||||
@ -225,9 +226,10 @@ def post_titan_tokens():
|
|||||||
def patch_titan_tokens():
|
def patch_titan_tokens():
|
||||||
user_id = request.form.get("user_id", None)
|
user_id = request.form.get("user_id", None)
|
||||||
amount = request.form.get("amount", None, type=int)
|
amount = request.form.get("amount", None, type=int)
|
||||||
|
reason = request.form.get("reason", None)
|
||||||
if not user_id or not amount:
|
if not user_id or not amount:
|
||||||
abort(400)
|
abort(400)
|
||||||
if get_titan_token(user_id) == -1:
|
if get_titan_token(user_id) == -1:
|
||||||
abort(409)
|
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)
|
return ('', 204)
|
@ -1,19 +1,19 @@
|
|||||||
/* global $, Materialize, location */
|
/* global $, Materialize, location */
|
||||||
|
|
||||||
function postForm(user_id, amount) {
|
function postForm(user_id, amount, reason) {
|
||||||
var funct = $.ajax({
|
var funct = $.ajax({
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: {"user_id": user_id, "amount": amount}
|
data: {"user_id": user_id, "amount": amount, "reason": reason}
|
||||||
});
|
});
|
||||||
return funct.promise();
|
return funct.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
function patchForm(user_id, amount) {
|
function patchForm(user_id, amount, reason) {
|
||||||
var funct = $.ajax({
|
var funct = $.ajax({
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
data: {"user_id": user_id, "amount": amount}
|
data: {"user_id": user_id, "amount": amount, "reason": reason}
|
||||||
});
|
});
|
||||||
return funct.promise();
|
return funct.promise();
|
||||||
}
|
}
|
||||||
@ -22,11 +22,12 @@ $(function() {
|
|||||||
$("#new_submit").click(function () {
|
$("#new_submit").click(function () {
|
||||||
var user_id = $("#new_user_id").val();
|
var user_id = $("#new_user_id").val();
|
||||||
var user_token = $("#new_user_token").val();
|
var user_token = $("#new_user_token").val();
|
||||||
|
var reason = $("#new_reason").val();
|
||||||
if (user_id.length < 1 || user_token.length < 1) {
|
if (user_id.length < 1 || user_token.length < 1) {
|
||||||
Materialize.toast("The user ID or balance field can't be blank!", 2000);
|
Materialize.toast("The user ID or balance field can't be blank!", 2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var formPost = postForm(user_id, user_token);
|
var formPost = postForm(user_id, user_token, reason);
|
||||||
formPost.done(function (data) {
|
formPost.done(function (data) {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
@ -42,7 +43,8 @@ $(function() {
|
|||||||
|
|
||||||
function submit_modify_user(user_id) {
|
function submit_modify_user(user_id) {
|
||||||
var amount = $("#input_"+user_id).val();
|
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) {
|
formPatch.done(function (data) {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>User ID</th>
|
<th>User ID</th>
|
||||||
<th>Starting Balance</th>
|
<th>Starting Balance</th>
|
||||||
|
<th>Reason</th>
|
||||||
<th>Submit</th>
|
<th>Submit</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -28,6 +29,11 @@
|
|||||||
<input id="new_user_token" placeholder="Starting Balance" type="number">
|
<input id="new_user_token" placeholder="Starting Balance" type="number">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="input-field inline">
|
||||||
|
<input id="new_reason" placeholder="Reason">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="waves-effect waves-light btn" id="new_submit">Submit</a>
|
<a class="waves-effect waves-light btn" id="new_submit">Submit</a>
|
||||||
</td>
|
</td>
|
||||||
@ -49,6 +55,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Modify Amount</th>
|
<th>Modify Amount</th>
|
||||||
|
<th>Reason</th>
|
||||||
<th>Submit</th>
|
<th>Submit</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -58,7 +65,11 @@
|
|||||||
<div class="input-field inline">
|
<div class="input-field inline">
|
||||||
<input placeholder="Modify Amount" type="number" id="input_{{ don.user_id }}">
|
<input placeholder="Modify Amount" type="number" id="input_{{ don.user_id }}">
|
||||||
</div>
|
</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>
|
||||||
<td>
|
<td>
|
||||||
<a class="waves-effect waves-light btn" onclick="submit_modify_user('{{ don.user_id }}')">Submit</a>
|
<a class="waves-effect waves-light btn" onclick="submit_modify_user('{{ don.user_id }}')">Submit</a>
|
||||||
@ -66,7 +77,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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>
|
<h4>Balance: <strong>{{ don.tokens }}</strong> Tokens</h4>
|
||||||
<table class="striped">
|
<table class="striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
Loading…
Reference in New Issue
Block a user