def main(): # Arguments: form = cgi.FieldStorage() sn = cgi.escape(form.getvalue('serial_num')) # This is coming from a form. cardid = cgi.escape(form.getvalue('card_id')) person_id = base.cleanCGInumber(form.getvalue('person_id')) db = settings.get_db() note = cgi.escape(form.getvalue('note')) if form.getvalue('note') else False # base.begin() # print person_id # print note # base.bottom() if not person_id: base.error(db, "You must select a tester to be associated with this note.") else: if not note: base.error(db, "You left the note field empty. You're not allowed to make an empty note.") else: # Begin: base.begin() base.header_redirect("module.py?db={0}&card_id={1}#notes".format(db, cardid)) base.top(db) # Add note: result = add_note(db, sn, note, person_id) if result: print "added note:<br>" print note # base.header_redirect_module_notes(card_id, serial_num) base.bottom()
def main(): # Arguments: form = cgi.FieldStorage() testtype_name = form.getvalue("testName") testtype_short = form.getvalue("descShort") testtype_long = form.getvalue("descLong") testtype_req = (False, True)[bool(form.getvalue("required"))] db = settings.get_db() # Begin: base.begin() base.header_redirect("erudition.py?db={0}".format(db),1) base.top(db) # Insert: con = connect(True, db) cur = con.cursor() if testtype_name and testtype_long: cur.execute("INSERT INTO Test_Type (name, required, desc_short, desc_long, relative_order) VALUES ('{0}', {1}, '{2}', '{3}', 1);".format(testtype_name, int(testtype_req), testtype_short, testtype_long)) con.commit() con.close() else: print '<center><h3 style="color:red"><i> ERROR: Null test type or test type description provided. Please input again.</i></h3></center>' base.bottom()
def main(): # Arguments: form = cgi.FieldStorage() if form.getvalue('unique_id'): uid = cgi.escape(form.getvalue('unique_id')) card_id = cgi.escape(form.getvalue('card_id')) db = settings.get_db() # Print basic HTML stuff: base.begin() base.header(title='Adding a unique ID...') base.header_redirect("module.py?db={0}&card_id={1}".format(db, card_id)) base.top(db) # Add: try: con = connect(True, db) cur = con.cursor() cur.execute('UPDATE Card SET unique_id="{0}" WHERE card_id={1}'.format(uid, card_id)) con.commit() con.close() except Exception as err: print "<span style='color: red'>ERROR</span><br>" print err # print("<h3>Serial number already exists!</h3>") base.bottom()
def main(): # Identify DB from URL: db = settings.get_db() base.begin() # Print the preamble and opening html tag. base.header(title='ePorridge') # Print the header. base.top(db) # Print the top portion of the body (title, buttons). This remains the same for every page. print_home(db) # Print what should appear on the home page. (Defined above.) base.bottom() # Print footer (if applicable) and closing body and html tags.
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()
def main(): db = settings.get_db() base.begin() base.header(title='{0}: tests'.format(db)) base.top(db) print_test_info_table(db) print '<br><br>' print_testtype_form(db) print_card_info_table(db) print '<br><br>' print_cardinfotype_form(db) base.bottom()
def main(): # Arguments: db = settings.get_db() # Basic: base.begin() base.header(title='{0}: summary'.format(db)) base.top(db) # Modules table: print_stat_table(db) print_tests_table(db) print_modules_table(db) # End: base.bottom()
def main(): # Arguments form = cgi.FieldStorage() cardid = base.cleanCGInumber(form.getvalue('card_id')) suggested_test = base.cleanCGInumber(form.getvalue('suggested')) db = settings.get_db() sn = module.fetch_sn_from_cardid(db, cardid) # Basic: base.begin() base.header(title='{0}: test'.format(db)) base.top(db) # Test form: print_test_form(db, cardid, sn, suggested_test) base.bottom()
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()
def main(): # Arguments: form = cgi.FieldStorage() sn = form.getvalue("serial_number") db = settings.get_db() if sn: try: con = connect(True, db) cur = con.cursor() cur.execute("INSERT INTO Card SET sn = '{0}'; ".format(sn)) con.commit() con.close() except Exception as ex: base.begin() base.header(title='{0}: add module'.format(db)) base.top(db) print ex print '<center><h3 style="color:red"><i>Serial number "{0}" already exists! It was not added.</i></h3></center>'.format(sn) else: cardid = module.fetch_cardid_from_sn(db,sn) base.begin() base.header_redirect("module.py?db={0}&card_id={1}".format(db,cardid)) base.top(db) else: base.begin() base.header_redirect("home.py?db={0}".format(db),1) base.top(db) print '<center><h3 style="color:red"><i>Tried to input null serial number. Do not do that.</i></h3></center>'.format(sn) base.bottom()
def main(): form = cgi.FieldStorage() infoName = cgi.escape(form.getvalue("characteristic","no name found")) descShort = cgi.escape(form.getvalue("descShort","no description found")) descLong = cgi.escape(form.getvalue("descLong","no description found")) db = settings.get_db() base.begin() base.header_redirect('erudition.py?db={0}#cardInfoTable'.format(db),1) base.top(db) con = connect(True,db) cur = con.cursor(buffered=True) if infoName and descLong: cur.execute("INSERT INTO Card_Info_Types (Info_Name,Info_Desc_Short,Info_Desc_Long) VALUES ('{0}','{1}','{2}');".format(infoName,descShort,descLong)) con.commit() con.close() else: print '<center><h3 style="color:red"><i> ERROR: Null characteristic or characteristic info. Please input again. </i></h3></center>' base.bottom()
def main(): # Arguments: form = cgi.FieldStorage() person_id = base.cleanCGInumber(form.getvalue("person_id")) test_type = base.cleanCGInumber(form.getvalue("test_type")) card_id = base.cleanCGInumber(form.getvalue("card_id")) success = (False, True)[bool(form.getvalue("success"))] db = settings.get_db() ## Comments: comments = form.getvalue("comments") if comments: comments = cgi.escape(comments) if person_id != 0: # Basic: base.begin() base.header_redirect("module.py?db={0}&card_id={1}".format(db, card_id)) base.top(db) # Add the test to the DB: test_id = add_test_basic(db, person_id, test_type, card_id, success, comments) ## Attachments: for i in range(1, 4): afile = form['attach{0}'.format(i)] if (afile.filename): adesc= form.getvalue("attachdesc{0}".format(i)) if adesc: adesc = cgi.escape(adesc) acomment= form.getvalue("attachcomment{0}".format(i)) if acomment: acomment = cgi.escape(acomment) add_test_attachment(db, test_id, afile, adesc, acomment) base.bottom() else: base.error(db, "You must select a tester from the available list.") else: base.error(db, "You must input comments before the test can be added.")
def main(): db = settings.get_db() base.begin() base.header(title='{0}: testers'.format(db)) base.top(db) print '<div class="row">' print '<div class="col-md-12">' print '<table class="table" style="width:650px" align="center">' print '<tr>' print '<th > Name </th>' print '<th > ID </th>' print '</tr>' userInfo = fetch_user_info(db) for user in userInfo: print '<tr>' print u'<td align="left">{0}</td>'.format(user['name']).encode("utf-8") print '<td align="left">',user['id'],'</td>' print '</tr>' print '</table>' print '</div>' print '</div>' print '<br><br>' print '<form action="add_tester.py?db={0}" method="post" enctype="multipart/form-data">'.format(db) print '\t<div class="col-md-6">' print '\t\t<b>Add tester</b><br>' print '\t\ttester name:<br>' print '\t\t<textarea name="testerName" cols="35" rows="1"></textarea><br>' print '\t\t<input type="submit" value="Submit">' print '\t</div>' print '</form>' base.bottom()
def main(): # Arguments: form = cgi.FieldStorage() tester_name = form.getvalue("testerName") db = settings.get_db() # Begin: base.begin() base.header_redirect("testers.py?db={0}".format(db),1) base.top(db) # Connect to DB: con = connect(True, db) cur = con.cursor(buffered=True) #print "INSERT INTO people (person_name, person_id) VALUES ('{0}',{1})".format(testerName,testerID) if tester_name: cur.execute("INSERT INTO People (person_name) VALUES ('{0}')".format(tester_name)) con.commit() con.close() else: print "<center><h3 style='color:red'><i>ERROR: Null tester name submitted. Database not updated.</i></h3></center>" base.bottom()
import settings import os.path import sys form = cgi.FieldStorage() attach_id = base.cleanCGInumber(form.getvalue('attach_id')) db=connect(0) cur=db.cursor() cur.execute("SELECT test_id, attachmime, originalname FROM Attachments WHERE attach_id=%d" % (attach_id)); if not cur.with_rows: print "Content-type: text/html\n" base.header("Attachment Request Error") base.top() print "<h1>Attachment not available</h1>" base.bottom() else: thevals=cur.fetchall(); attpath=settings.getAttachmentPathFor(thevals[0][0],attach_id) if not os.path.isfile(attpath): print "Content-type: text/html\n" print print attpath base.header("Attachment Request Error") base.top() print "<h1>Attachment not found</h1>" base.bottom() else: statinfo = os.stat(attpath)
import cgi import base import home_page_list import cgitb cgitb.enable() #cgi header print "Content-type: text/html" print print "<html><head>" print "" print "</head><body>" base.header(title='ePortage Home Page') base.top() print '<div class="row">' print '<div class="col-md-3">' print '<h2>List of All Boards</h2>' print '<b><em>(Sorted by Serial Number)</em></b>' print '</div>' print '<div class="col-md-3">' print '<br><br>' print '<a href="add_module.py">' print '<button type="button">Add a New Board</button>' print '</a>' print '</div>' print '</div>' print '<br><br>'
# IMPORTS: import cgi import base import home_page_list import cgitb cgitb.enable() # /IMPORTS # FUNCTIONS: def print_home(): print'''\t\t<div class="row"> <div class="col-md-3"> <h2>All Boards:</h2> <strong><em>(Sorted by serial number)</em></strong> </div> <div class="col-md-3"> <br><br> <a href="add_module.py"><button type="button">Add a new board</button></a> </div> </div> <br><br>''' home_page_list.render_list_module() # /FUNCTIONS #cgi header base.begin() # Print the preamble and opening html tag. base.header(title='Acceptance Test Database') # Print the header. base.top() # Print the top portion of the body (title, buttons). This remains the same for every page. print_home() # Print what should appear on the home page. (Defined above.) base.bottom() # Print footer (if applicable) and closing body and html tags.
import os.path import sys form = cgi.FieldStorage() attach_id = base.cleanCGInumber(form.getvalue('attach_id')) db = settings.get_db() con = connect(True, db) cur = con.cursor() cur.execute("SELECT test_id, attachmime, originalname FROM Attachments WHERE attach_id=%d" % (attach_id)); if not cur.with_rows: print "Content-type: text/html\n" base.header("Attachment Request Error") base.top() print "<h1>Attachment not available</h1>" base.bottom() else: thevals=cur.fetchall(); #attpath=settings.getAttachmentPathFor(thevals[0][0],attach_id) # Kelvin (16/08/16) - this function is not in settings.py.... attpath=settings.get_attachment_path(db,thevals[0][0],attach_id) if not os.path.isfile(attpath): print "Content-type: text/html\n" print print attpath base.header("Attachment Request Error") base.top(db) print "<h1>Attachment not found</h1>" base.bottom() else:
def main(): base.begin() # Print the preamble and opening html tag. base.header(title="Acceptance Test Database") # Print the header. base.top() # Print the top portion of the body (title, buttons). This remains the same for every page. print get() base.bottom() # Print footer (if applicable) and closing body and html tags.