Changeset 626 in tmcsimulator for branches/LCSv2/controllers/default.py.bak
- Timestamp:
- 08/30/2020 01:49:28 PM (6 years ago)
- File:
-
- 1 edited
-
branches/LCSv2/controllers/default.py.bak (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/LCSv2/controllers/default.py.bak
r622 r626 3 3 hwys = ['','1','5', '22', '55', '57', '73', '74', '91', '133', '142', '241', '261', '405', '605'] 4 4 hwyDirections = ['','NB', 'SB', 'NB/SB','EB','WB','EB/WB'] 5 # Names to appeaer in the username dropdown box 6 users = [] 5 7 # Show the login page 6 8 def index(): 7 form = FORM(LABEL('Username:',_for='username', _class="label username-label"), 8 INPUT(_name='username', _size='15', _style="font-size: 18px;"), BR(), 9 userfile = open('student_names.txt','r') 10 users = [line.strip() for line in userfile.readlines()] 11 users.insert(0,'') 12 form = FORM(LABEL('User:',_for='username', _class="label username-label"), 13 #INPUT(_name='username', _size='15', _style="font-size: 18px;"), BR(), 14 SELECT(users,_name='username',requires=IS_LENGTH(minsize=1,error_message='Must select a user from the list.')),BR(), 9 15 INPUT(_type='submit',_value="Log in", _class=" btn btn-primary", _style="margin-top: 3%;")) 10 16 if form.process().accepted: … … 92 98 count = len(hwy) 93 99 # Show the results in table format. Get the radio call number from supervisor name lookup 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.')))100 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/Lanes'),TH('Limits'),TH('Work'), TH('TMP:',BR(),'Cozeep/',BR(),'Detour'),TH('Requestor/',BR(),'Radio Call No.'))) 95 101 multiform = [] 96 102 # Iterates over all search results … … 103 109 INPUT(_type='submit',_name='btn2',_value='Show Status Form',_class="submit-button" ), 104 110 INPUT(_type='hidden',_name='row',_value=row.closureid))), 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) )) 111 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,HR(),row.closedlanes), 112 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) )) 106 113 107 114 session.chosenid = request.vars.row #Pass the hidden field containing the closure ID … … 207 214 supervisors.append(row.radiocallnum + ' ' + row.name) 208 215 crew = [''] # List of names for the dropdown box 216 crewlookup = [] 209 217 # Obtain all the crew names from the database 210 218 for row in db().select(db.crew.ALL): 211 219 crew.append(row.radiocallnum + ' ' + row.name) 220 crewlookup.append(row.radiocallnum + ' ' + row.name) 212 221 # Build the list of street locations and a hidden cross street lookup table 213 222 streets = [''] … … 248 257 TD(INPUT(_type='checkbox',_name='cozeep'),'CoZeep MaZeep/CHP',BR(), 249 258 INPUT(_type='checkbox', _name='detour'),'Detour Available')), 250 TR(TD(DIV(LABEL("Lanes closed"),DIV( _id='boxes'),_id='lanechooser',_style='display:none')),259 TR(TD(DIV(LABEL("Lanes closed"),DIV(INPUT(_type='checkbox', _name='lanes', _id='lanes', _value=' '), _id='boxes'),_id='lanechooser',_style='display:none')), 251 260 TD(INPUT(_type='hidden', _name='lanecount', _id='lanecount', _value='4')), 252 261 TD(), … … 256 265 TD(LABEL('Field Rep')) 257 266 ), 258 TR(TD(SELECT(supervisors,_name='supervisor', requires=IS_LENGTH(minsize=1,error_message='supervisor cannot be empty'))),259 TD(SELECT(crew,_name='fieldrep' )),267 TR(TD(SELECT(supervisors,_name='supervisor', _id='supervisorcombo', _onchange='supervisorchanged()', requires=IS_LENGTH(minsize=1,error_message='supervisor cannot be empty'))), 268 TD(SELECT(crew,_name='fieldrep',_id='fieldrep')), 260 269 TD(XML(" ")), 261 270 TD('Is this an existing incident?', … … 272 281 TR(TD(INPUT(_name='meeting', _size='25')),TD(INPUT(_name='reason',_size='25')),TD(INPUT(_name='remarks',_size='25'))) ), BR(), 273 282 INPUT(_type='submit',_value='Submit Closure', _class="btn btn-primary btn-default", _style="margin: 2% 45% 2% 40%;"), 274 XML('\n'),SELECT(streetlookup,_name='stlookup', _id='stlookup', _class='hideme')) 283 XML('\n'),SELECT(streetlookup,_name='stlookup', _id='stlookup', _class='hideme'), 284 SELECT(crewlookup,_name='crewlookup', _id='crewlookup', _class='hideme')) 275 285 276 286 if form.process(onvalidation=validate_existing_id).accepted: … … 282 292 supervisor_name = form.vars.supervisor[3:] 283 293 fieldrep_name = form.vars.fieldrep[5:] 294 selectedlanes = buildLanesClosedString(form.vars.lanes,form.vars.lanecount) 284 295 # Insert the record into the database 285 newrec = db.closures.insert(closureid=newID, lognum=newLognum, route=form.vars.route, direction=form.vars.direction, facility=form.vars.facility, startcounty=form.vars.startcounty, endcounty=form.vars.endcounty, startlocation=form.vars.startlocation, endlocation=form.vars.endlocation, startdate=form.vars.startdate, enddate=form.vars.enddate, starttime=form.vars.starttime+form.vars.starttimemin, endtime=form.vars.endtime+form.vars.endtimemin, closuretype=form.vars.closuretype, worktype=form.vars.worktype, estdelay=form.vars.estdelay, tmpcozeep=getCheckbox(form.vars.cozeep), tmpdetour=getCheckbox(form.vars.detour), supervisor=supervisor_name, fieldrep=fieldrep_name, s1097date='', s1098date='', s1022date='' ) 286 session.flash = 'New lane closure added: ' + newID + ' ' + newLognum + ', ' + buildLanesClosedString(form.vars.lanes) + ':' + form.vars.lanecount 296 newrec = db.closures.insert(closureid=newID, lognum=newLognum, route=form.vars.route, direction=form.vars.direction, facility=form.vars.facility, startcounty=form.vars.startcounty, endcounty=form.vars.endcounty, startlocation=form.vars.startlocation, endlocation=form.vars.endlocation, startdate=form.vars.startdate, enddate=form.vars.enddate, starttime=form.vars.starttime+form.vars.starttimemin, endtime=form.vars.endtime+form.vars.endtimemin, closuretype=form.vars.closuretype, closedlanes=selectedlanes, worktype=form.vars.worktype, estdelay=form.vars.estdelay, tmpcozeep=getCheckbox(form.vars.cozeep), tmpdetour=getCheckbox(form.vars.detour), supervisor=supervisor_name, fieldrep=fieldrep_name, s1097date='', s1098date='', s1022date='' ) 297 session.flash = 'New lane closure added: ' + newID + ' ' + newLognum + ': ' + selectedlanes 298 redirect(URL('search.html')) 299 return dict(form=form) 300 301 # An unlinked page to allow admin to reset the database to simulation start state 302 def resetdb(): 303 form = FORM("Press this button to reset the closure database to its original state at the start of a simulation.",BR(), 304 "Warning: this will delete all the current closures.",BR(), 305 INPUT(_value="Reset Database", _type='submit', _class="btn btn-primary btn-default")) 306 if form.process().accepted: 307 db(db.closures.id > 0).delete() # remove all current records 308 with open('db_closures_start.csv', 'rb') as dumpfile: 309 db.closures.import_from_csv_file(dumpfile) # import from starting state 287 310 redirect(URL('search.html')) 288 311 return dict(form=form) … … 296 319 # Calculate the closure id to assign to the new closure 297 320 def calcNextClosureID(routeNum): 298 # Retrieve any existing closures on this route 299 item = db(db.closures.closureid.startswith('T'+routeNum)).select().last() # Might need to sort these 321 # Retrieve the last existing closure on this route 322 #item = db(db.closures.closureid.startswith('T'+routeNum)).select().last() # defective 323 item = db(db.closures.route == routeNum).select().last() 300 324 if (item != None): 301 325 currID = item.closureid … … 328 352 # E.g. #1 #3 of 4 329 353 # Note: ckBoxGroup parameter contains only checked items 330 def buildLanesClosedString(ckBoxGroup ):331 result = " >"354 def buildLanesClosedString(ckBoxGroup,lanecount): 355 result = "" 332 356 if ckBoxGroup is not None: 333 357 # Append each checked value to a string 334 358 for item in ckBoxGroup: 335 result = result + item + " " 359 result = result + "#"+item + " " 360 result = result + "of " + lanecount 336 361 return result
Note: See TracChangeset
for help on using the changeset viewer.
