forked from bton/matekasse
Transaction log without time
This commit is contained in:
parent
e76e5beae7
commit
dd9e3463c9
3 changed files with 7 additions and 8 deletions
|
@ -73,11 +73,11 @@ def create_app(test_config=None):
|
|||
c.execute("SELECT * FROM transaction_log ORDER BY ROWID DESC LIMIT 1000")
|
||||
transactionlist = c.fetchall()
|
||||
for i in transactionlist:
|
||||
statement = i[1]
|
||||
user_id = i[2]
|
||||
before = i[3]
|
||||
after = i[4]
|
||||
change = i[5]
|
||||
statement = i[0]
|
||||
user_id = i[1]
|
||||
before = i[2]
|
||||
after = i[3]
|
||||
change = i[4]
|
||||
if statement == "balance":
|
||||
reverse_statement = "balance"
|
||||
reverse_user_id = user_id
|
||||
|
@ -110,7 +110,7 @@ def create_app(test_config=None):
|
|||
reverse_change = None
|
||||
else:
|
||||
raise Exception(statement)
|
||||
text = text + f'<form action="/api/change" method="post"><p style="display: inline;">{i[0]} {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>'
|
||||
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>'
|
||||
return text
|
||||
|
||||
@app.route("/list/user", methods=['GET'])
|
||||
|
|
|
@ -8,7 +8,7 @@ from flask import current_app, g
|
|||
def log(statement, user_id=None, before=None, after=None, change=None):
|
||||
db = get_db()
|
||||
c = db.cursor()
|
||||
c.execute("INSERT INTO transaction_log (timestamp, type, user_id, before, after, change) VALUES (?, ?, ?, ?, ?, ?)", [datetime.now(), statement, user_id, before, after, change])
|
||||
c.execute("INSERT INTO transaction_log (type, user_id, before, after, change) VALUES (?, ?, ?, ?, ?)", [ statement, user_id, before, after, change])
|
||||
db.commit()
|
||||
|
||||
def add_user(after):
|
||||
|
|
|
@ -12,7 +12,6 @@ CREATE TABLE IF NOT EXISTS "tags" (
|
|||
PRIMARY KEY("tagid")
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "transaction_log" (
|
||||
"timestamp" INTEGER NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"user_id" INTEGER,
|
||||
"before" TEXT,
|
||||
|
|
Loading…
Reference in a new issue