Changeset 612 in tmcsimulator
- Timestamp:
- 04/02/2020 09:36:50 AM (6 years ago)
- Location:
- branches/LCSv1/controllers
- Files:
-
- 2 edited
-
default.py (modified) (2 diffs)
-
default.py.bak (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/LCSv1/controllers/default.py
r610 r612 43 43 INPUT(_name='enddate',_class='date'),BR(), 44 44 INPUT(_value="Search", _type='submit', _class="btn btn-primary btn-default", _style="margin: 7% 45% 2% 40%;")) 45 if form.process( ).accepted:45 if form.process(onvalidation=special_validation).accepted: 46 46 # Put the form fields into the session variables 47 47 session.closureid = form.vars.closureid … … 53 53 redirect(URL('results')) 54 54 return dict(form=form) 55 # Search Form: Special validation check to reject lognum without closureID 56 def special_validation(form): 57 # Error if a lognum was given and no closure id 58 if (len(form.vars.lognum) > 0 and len(form.vars.closureid) == 0): 59 form.errors.lognum = 'Must provide a closureID when specifying a log number' 55 60 # Show the item that was found in the search 56 61 def results(): -
branches/LCSv1/controllers/default.py.bak
r593 r612 1 # added comments for testing 1 2 # Constants 2 3 hwys = ['','1','5', '22', '55', '57', '73', '74', '91', '133', '142', '241', '261', '405', '605'] … … 4 5 # Show the login page 5 6 def index(): 6 form = FORM(LABEL('Username:',_for='username', _class="label "),7 INPUT(_name='username', _size='10'),BR(),8 INPUT(_type='submit', _class="submit-button btn btn-primary"))7 form = FORM(LABEL('Username:',_for='username', _class="label username-label"), 8 INPUT(_name='username', _size='15', _style="font-size: 18px;"), BR(), 9 INPUT(_type='submit',_value="Log in", _class=" btn btn-primary", _style="margin-top: 3%;")) 9 10 if form.process().accepted: 10 11 # Put the username entry into the session variable … … 28 29 # Display a search form 29 30 def search(): 30 form = FORM(LABEL('ClosureID/Log:',_for='closureid', _class="label"), INPUT(_name='closureid',_size='7'),INPUT(_name='lognum',_size='3'),XML(' '), LABEL('Route: ',_for='route', _class="label"), SELECT(hwys,_name='route'), XML(' '), LABEL('Direction: ',_for='direction', _class="label"), SELECT(hwyDirections,_name='direction'), BR(),BR(),LABEL('Dates:',_for='startdate', _class="label") ,INPUT(_name='startdate',_class='date'), XML(' '), LABEL(' to:',_for='enddate', _class="label"), INPUT(_name='enddate'),'(MMDDYYYY)',BR(),BR(),INPUT(_type='submit', _class="submit-button btn btn-primary")) 31 if form.process().accepted: 31 form = FORM(LABEL('ClosureID/Log:',_for='closureid', _class="label"), 32 INPUT(_name='closureid',_size='7', _style="margin-right: 5px;"), 33 INPUT(_name='lognum',_size='3'), 34 XML(' '), 35 LABEL('Route: ',_for='route', _class="label"), 36 SELECT(hwys,_name='route'), XML(' '), 37 LABEL('Direction: ',_for='direction', _class="label"), 38 SELECT(hwyDirections,_name='direction'), BR(),BR(), 39 LABEL('Dates:',_for='startdate', _class="label"), 40 INPUT(_name='startdate',_class='date'), 41 XML(' '), 42 LABEL(' to:',_for='enddate', _class="label"), 43 INPUT(_name='enddate',_class='date'),BR(), 44 INPUT(_value="Search", _type='submit', _class="btn btn-primary btn-default", _style="margin: 7% 45% 2% 40%;")) 45 if form.process(onvalidation=special_validation).accepted: 32 46 # Put the form fields into the session variables 33 47 session.closureid = form.vars.closureid … … 39 53 redirect(URL('results')) 40 54 return dict(form=form) 55 # Search Form: Special validation check to reject lognum without closureID 56 def special_validation(form): 57 # Error if a lognum was given and no closure id 58 if (len(form.vars.lognum) > 0 and len(form.vars.closureid = 0)): 59 form.errors.lognum = 'Must provide a closureID when specifying a log number' 41 60 # Show the item that was found in the search 42 61 def results(): 62 # query object is equivalent to the where clause in query 63 query = True 64 msg = "" 43 65 if (len(session.closureid) != 0): 44 hwy = db(db.closures.closureid == session.closureid).select() 45 msg = "Closure ID = " + session.closureid 46 elif (len(session.route) != 0): 47 hwy = db(db.closures.route == session.route).select() 48 msg = "route = " + session.route 49 elif (len(session.startdate) == 10): 50 hwy = db(db.closures.startdate >= session.startdate).select() 51 msg = "Start Date >= " + session.startdate 52 else: 66 query = (db.closures.closureid == session.closureid) 67 msg += " Closure ID = " + session.closureid 68 if (len(session.lognum) != 0): 69 query = query & (db.closures.lognum == session.lognum) 70 msg += " Log number = " + session.lognum 71 if (len(session.route) != 0): 72 query = query & (db.closures.route == session.route) 73 msg += " Route = " + session.route 74 if (len(session.direction) != 0): 75 query = query & (db.closures.direction == session.direction) 76 msg += " Route = " + session.route 77 if (len(session.startdate) != 0): 78 query = query & (db.closures.startdate >= session.startdate) 79 msg += "Start date = " + session.startdate 80 if (len(session.enddate) != 0): 81 query = query & (db.closures.startdate <= session.enddate) 82 msg += "End date = " + session.enddate 83 84 # if no restrictions entered then get all entries 85 if query == True : 53 86 hwy = db().select(db.closures.ALL) 54 87 msg = "ALL" 88 else: 89 # get entries with the matching requirements 90 hwy = db(query).select() 91 55 92 count = len(hwy) 56 93 # Show the results in table format. Get the radio call number from supervisor name lookup 57 94 header = THEAD(TR(TH(''), TH('DTM',BR(),'Area'), TH('Closure ID/',BR(),'Log No.'),TH('Route & Dir/',BR(),'Type of Closure'),TH('Start Date/',BR(),'End Date/',BR(),'Est. Delay'),TH('Facility'),TH('Limits'),TH('Work'), TH('TMP:',BR(),'Cozeep/',BR(),'Detour'),TH('Requestor/',BR(),'Radio Call No.'))) 58 95 multiform = [] 96 # Iterates over all search results 59 97 for row in hwy: 60 98 statusfields = row.closureid +','+ row.lognum + ',1097,' + str(row.s1097user) +','+ str(row.startdate) + ',' + formatTime(row.starttime) +','+str(row.s1097date)+','+ formatTime(row.s1097time) + ',1098,' + str(row.s1098user) +','+ str(row.s1098date)+','+ formatTime(row.s1098time)+ ',1022,' + str(row.s1022user) +','+ str(row.s1022date)+','+ formatTime(row.s1022time) 61 99 # Each row contains a form with two buttons and columns with fields from database 62 100 multiform.append(TR(TD( 63 XML("<button onclick=showPopup(\'"),statusfields,XML("\')>View History</button>"),BR(),101 XML("<button class='submit-button' onclick=showPopup(\'"),statusfields,XML("\')>View History</button>"),BR(), 64 102 FORM( 65 INPUT(_type='submit',_name='btn2',_value='Show Status Form' ),103 INPUT(_type='submit',_name='btn2',_value='Show Status Form',_class="submit-button" ), 66 104 INPUT(_type='hidden',_name='row',_value=row.closureid))), 67 105 TD(row.closureid[0]),TD(row.closureid,HR(),row.lognum), TD(row.route,' ',row.direction,HR(),row.closuretype), TD(row.startdate,' ',formatTime(row.starttime),HR(),row.enddate,' ',formatTime(row.endtime),HR(),row.estdelay), TD(row.facility),TD(row.startlocation,HR(),row.endlocation), TD(row.worktype), TD(row.tmpcozeep,BR(),row.tmpdetour), TD(row.supervisor,HR(),db(db.supervisors.name == row.supervisor).select().first().radiocallnum) )) … … 70 108 if request.vars.btn2: 71 109 redirect(URL('statuslist')) 72 73 110 return dict(msg=msg, count=count, highways=hwy, table=header, multiform=multiform) 74 111 … … 87 124 88 125 form = FORM(BR(), 89 TABLE(THEAD(TR(TH('Closure ID/',BR(),'Log No.'), TH('Route & Dir',BR(),'Type of Closure'),TH('Start Date/',BR(),'End Date/',BR(),'Est. Delay'),TH('Requestor/',BR(),'Radio Call No.'),TH('Status'))),126 TABLE(THEAD(TR(TH('Closure ID/',BR(),'Log No.'), TH('Route & Dir',BR(),'Type of Closure'),TH('Start Date/',BR(),'End Date/',BR(),'Est. Delay'),TH('Requestor/',BR(),'Radio Call No.'),TH('Status'))), 90 127 [TR(TD(row.closureid,HR(),row.lognum),TD(row.route,' ',row.direction,HR(),row.closuretype),TD(row.startdate,HR(),row.enddate,HR(),row.estdelay),TD(row.supervisor,BR(),db(db.supervisors.name == row.supervisor).select().first().radiocallnum),TD(LABEL('1097'), INPUT(_type='checkbox', _name='statustype', _value='1097'+row.closureid),LABEL('1098'), INPUT(_type='checkbox', _name='statustype', _value='1098'+row.closureid),LABEL('1022'), INPUT(_type='checkbox', _name='statustype', _value='1022'+row.closureid),BR(), LABEL('Statuser:'),INPUT(_name='statuser',_size='9'))) for row in closedItems], 91 _border='1', _cellpadding='5'),INPUT(_type='submit',_value="submit status form" ),)128 _border='1', _cellpadding='5'),INPUT(_type='submit',_value="submit status form",_class="submit-button"),) 92 129 93 130 else: … … 125 162 return dict(msg=msg) 126 163 # Utility functions for formatting 127 def formatDate(msg):128 if (msg):129 return msg[4:6]+"/"+msg[6:8]+"/"+msg[0:4]130 else:131 return ""132 164 def formatTime(msg): 133 165 if (msg): … … 157 189 LABEL('*Direction',_for='direction'), SELECT(hwyDirections,_name='direction', requires=IS_LENGTH(minsize=1,error_message='direction cannot be empty')), XML(' '), 158 190 LABEL('*Facility',_for='facility'), SELECT(facilities,_name='facility', requires=IS_LENGTH(minsize=1,error_message='facility cannot be empty')), BR(),BR(), 159 TABLE(TR(TD(),TD('*County'),TD('*Location')),TR(TD('BEGIN='),TD(SELECT('ORA',_name='startcounty')),TD(SELECT(streets,_name='startlocation',_id='startlocation')), 160 TR(TD('END='),TD(SELECT('ORA',_name='endcounty')),TD(SELECT(streets,_name='endlocation',_id='endlocation'))))),BR(), 161 'Date Range:',BR(), 191 TABLE(TR(TD(),TD(LABEL('*County')),TD(LABEL('*Location'))), 192 TR(TD(LABEL('BEGIN=')),TD(SELECT('ORA',_name='startcounty')), 193 TD(SELECT(streets,_name='startlocation',_id='startlocation')), 194 TR(TD(LABEL('END=')),TD(SELECT('ORA',_name='endcounty')),TD(SELECT(streets,_name='endlocation',_id='endlocation'))))),BR(), 195 LABEL('Date Range:'),BR(), 162 196 LABEL('From',_for='startdate'),INPUT(_name='startdate',_size='8',_class='date'), XML(' '), 163 LABEL('to:',_for='enddate'), INPUT(_name='enddate',_size='8',_class='date'), '(MMDDYYYY)',XML(' '),197 LABEL('to:',_for='enddate'), INPUT(_name='enddate',_size='8',_class='date'),XML(' '), 164 198 LABEL('Times',_for='starttime'),SELECT(hournames,_name='starttime'), 165 199 LABEL(':',_for='starttimemin'),SELECT('','00','15','30','45','59',_name='starttimemin'), XML(' '), 166 200 LABEL('to:',_for='endtime'),SELECT(hournames,_name='endtime'), 167 201 LABEL(':',_for='endtimemin'),SELECT('','00','15','30','45','59',_name='endtimemin'), BR(),BR(), 168 TABLE(TR(TD('*Type of Closure'),TD('*Type of Work'),TD('Estimated Delay'),TD('TMP Details')), 202 TABLE(TR(TD(LABEL('*Type of Closure') ), 203 TD(LABEL('*Type of Work')), 204 TD(LABEL('Estimated Delay')), 205 TD(LABEL('TMP Details'))), 169 206 TR(TD(SELECT(closuretypes,_name='closuretype',requires=IS_LENGTH(minsize=1,error_message='type of closure cannot be empty'))), 170 207 TD(SELECT(worktypes,_name='worktype', requires=IS_LENGTH(minsize=1,error_message='type of work cannot be empty'))), … … 173 210 INPUT(_type='checkbox', _name='detour'),'Detour Available')), 174 211 _width='100%' ), 175 TABLE(TR(TD('*Supervisor'),TD('Field Rep')), 212 TABLE(TR(TD(LABEL('*Supervisor')), 213 TD(LABEL('Field Rep'))), 176 214 TR(TD(SELECT(supervisors,_name='supervisor', requires=IS_LENGTH(minsize=1,error_message='supervisor cannot be empty'))), 177 215 TD(SELECT(supervisors,_name='fieldrep')))), 178 TABLE(TR(TD('Meeting Place/CHP Contact'),TD('Reason for Closure'),TD('Additional Remarks / Detour ')), 179 TR(TD(INPUT(_name='meeting')),TD(INPUT(_name='reason')),TD(INPUT(_name='remarks',_size='40'))) ), BR(), 180 INPUT(_type='submit',_value='Submit Closure'),XML('\n'),SELECT(streetlookup,_name='stlookup', _id='stlookup', _class='hideme')) 216 TABLE(TR(TD( LABEL('Meeting Place/CHP Contact')), 217 TD(LABEL('Reason for Closure')), 218 TD(LABEL('Additional Remarks / Detour '))), 219 TR(TD(INPUT(_name='meeting', _size='25')),TD(INPUT(_name='reason',_size='25')),TD(INPUT(_name='remarks',_size='25'))) ), BR(), 220 INPUT(_type='submit',_value='Submit Closure', _class="btn btn-primary btn-default", _style="margin: 2% 45% 2% 40%;"), 221 XML('\n'),SELECT(streetlookup,_name='stlookup', _id='stlookup', _class='hideme')) 222 181 223 if form.process().accepted: 182 224 newID = calcNextClosure(form.vars.route)
Note: See TracChangeset
for help on using the changeset viewer.
