/
note_form.py
executable file
·64 lines (53 loc) · 1.59 KB
/
note_form.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python
# IMPORTS:
import cgi
import cgitb
cgitb.enable()
import base, settings, module, testers
# :IMPORTS
# FUNCTIONS:
def print_form(db, cardid):
sn = module.fetch_sn_from_cardid(db, cardid)
print '<form method="post" class="sub-id-form" action="add_note.py?db={0}">'.format(db)
print '<div class="row">'
print '<div class="col-md-12">'
print '<h4>Add a note for the board a serial number of \"{0}\"</h4>'.format(sn)
print '</div>'
print '</div>'
print '<br><br>'
print '<div class="row">'
print '<div class="col-md-6">'
print '<label>Tester: <select name="person_id"><option value="0">Select tester</option>'
people = testers.fetch_user_info(db)
for person in people:
print u'<option value="{0}">{1}</option>'.format(person["id"], person["name"]).encode("utf-8")
print '</select></label></div></div>'
print '<div class="row">'
print '<div class = "col-md-6">'
print '<label class="sub-id">'
print 'Note: <br>'
print '<textarea rows="10" cols="100" , name="note"></textarea> <br>'
print '</label>'
print '<input type="hidden" name="serial_num" value="{0}">'.format(sn)
print '<input type="hidden" name="card_id" value="{0}">'.format(cardid)
print '<input type="submit" value="Submit">'
print '</div>'
print '</div>'
print '</form>'
def main():
# Arguments:
form = cgi.FieldStorage()
cardid = base.cleanCGInumber(form.getvalue('card_id'))
db = settings.get_db()
# Basic:
base.begin()
base.header(title='{0}: module'.format(db))
base.top(db)
# Form:
print_form(db, cardid)
base.bottom()
# :FUNCTIONS
# MAIN:
if __name__ == "__main__":
main()
# :MAIN