transaction list as template
This commit is contained in:
parent
a31337f0f2
commit
efff31aa27
1 changed files with 40 additions and 38 deletions
|
@ -69,49 +69,51 @@ def create_app(test_config=None):
|
||||||
def transactionlist():
|
def transactionlist():
|
||||||
db = get_db()
|
db = get_db()
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
text = ""
|
action_list = []
|
||||||
c.execute("SELECT * FROM transaction_log ORDER BY ROWID DESC LIMIT 1000")
|
c.execute("SELECT * FROM transaction_log ORDER BY ROWID DESC LIMIT 1000")
|
||||||
transactionlist = c.fetchall()
|
transactionlist = c.fetchall()
|
||||||
for i in transactionlist:
|
for i in transactionlist:
|
||||||
statement = i[0]
|
action = {
|
||||||
user_id = i[1]
|
"statement":i[0],
|
||||||
before = i[2]
|
"user_id":i[1],
|
||||||
after = i[3]
|
"before":i[2],
|
||||||
change = i[4]
|
"after":i[3],
|
||||||
if statement == "balance":
|
"change":i[4]
|
||||||
reverse_statement = "balance"
|
}
|
||||||
reverse_user_id = user_id
|
if action["statement"] == "balance":
|
||||||
reverse_before = None
|
action["reverse_statement"] = "balance"
|
||||||
reverse_after = None
|
action["reverse_user_id"] = action["user_id"]
|
||||||
reverse_change = change *(-1)
|
action["reverse_before"] = None
|
||||||
elif statement == "add_user":
|
action["reverse_after"] = None
|
||||||
reverse_statement = "remove_user"
|
action["reverse_change"] = action["change"] *(-1)
|
||||||
reverse_user_id = user_id
|
elif action["statement"] == "add_user":
|
||||||
reverse_before = after
|
action["reverse_statement"] = "remove_user"
|
||||||
reverse_after = None
|
action["reverse_user_id"] = action["user_id"]
|
||||||
reverse_change = None
|
action["reverse_before"] = action["after"]
|
||||||
elif statement == "remove_user":
|
action["reverse_after"] = None
|
||||||
reverse_statement = "add_user"
|
action["reverse_change"] = None
|
||||||
reverse_user_id = user_id
|
elif action["statement"] == "remove_user":
|
||||||
reverse_before = None
|
action["reverse_statement"] = "add_user"
|
||||||
reverse_after = before
|
action["reverse_user_id"] = action["user_id"]
|
||||||
reverse_change = None
|
action["reverse_before"] = None
|
||||||
elif statement == "add_tag":
|
action["reverse_after"] = action["before"]
|
||||||
reverse_statement = "remove_tag"
|
action["reverse_change"] = None
|
||||||
reverse_user_id = user_id
|
elif action["statement"] == "add_tag":
|
||||||
reverse_before = after
|
action["reverse_statement"] = "remove_tag"
|
||||||
reverse_after = None
|
action["reverse_user_id"] = action["user_id"]
|
||||||
reverse_change = None
|
action["reverse_before"] = action["after"]
|
||||||
elif statement == "remove_tag":
|
action["reverse_after"] = None
|
||||||
reverse_statement = "add_tag"
|
action["reverse_change"] = None
|
||||||
reverse_user_id = user_id
|
elif action["statement"] == "remove_tag":
|
||||||
reverse_before = None
|
action["reverse_statement"] = "add_tag"
|
||||||
reverse_after = before
|
action["reverse_user_id"] = action["user_id"]
|
||||||
reverse_change = None
|
action["reverse_before"] = None
|
||||||
|
action["reverse_after"] = action["before"]
|
||||||
|
action["reverse_change"] = None
|
||||||
else:
|
else:
|
||||||
raise Exception(statement)
|
raise Exception(statement)
|
||||||
text = text + f'<form action="/api/change" method="post"><p style="display: inline;">{statement} userid:{user_id} {before} {after} {change}</p><input type="hidden" name="statement" value={reverse_statement}><input type="hidden" name="user_id" value={reverse_user_id}><input type="hidden" name="before" value={reverse_before}><input type="hidden" name="after" value={reverse_after}><input type="hidden" name="change" value={reverse_change}><button type="submit">rollback</button></form><br></br>'
|
action_list.append(action)
|
||||||
return text
|
return render_template("transactionlist.html", action_list=action_list)
|
||||||
|
|
||||||
@app.route("/list/user", methods=['GET'])
|
@app.route("/list/user", methods=['GET'])
|
||||||
def user_info():
|
def user_info():
|
||||||
|
|
Loading…
Reference in a new issue