-
Notifications
You must be signed in to change notification settings - Fork 0
/
revoke.py
executable file
·47 lines (38 loc) · 1.04 KB
/
revoke.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python
# IMPORTS:
import cgitb
cgitb.enable()
import cgi
import base, settings, test
from connect import connect
# :IMPORTS
# FUNCTIONS:
def revoke_test(db, test_id, revoke=True, comment="default"):
con = connect(True, db)
cur = con.cursor()
# The following method escapes characters correctly:
cmd = "INSERT INTO TestRevoke (test_id, comment) VALUES (%s, %s)"
values = (test_id, comment)
cur.execute(cmd, values)
con.commit()
def main():
# Arguments:
form = cgi.FieldStorage()
test_id = base.cleanCGInumber(form.getvalue('test_id'))
comment = form.getvalue('comment')
db = settings.get_db()
card_id = test.fetch_cardid_from_testid(db, test_id)
testtype_id = test.fetch_testtypeid_from_testid(db, test_id)
# Revoke:
revoke_test(db, test_id, revoke=True, comment=comment)
# Basic:
base.begin()
# base.header(title='{0}: revoke'.format(db))
base.header_redirect("module.py?db={0}&card_id={1}#test-{2}".format(db, card_id, testtype_id))
base.top(db)
base.bottom()
# :FUNCTIONS
# MAIN:
if __name__ == "__main__":
main()
# :MAIN