def post(self): print("DelCourtConfirmHandler") courtlist = [] try: keylist = self.request.get_all('keys') print("get keys") for key in keylist: c = Courts() # c.key = key # p = db.get(key) #Get the court by its unique key (key) print("db.get(key)") c.date = library.cday(p.start) c.weekday = p.weekday c.start = library.ctime(p.start) c.end = library.ctime(p.end) c.desc = p.desc c.courts = library.listconv(p.courts) c.location = library.location(p.location) c.key = key courtlist.append(c) print key except: print "EXCEPTION" # weekday, date, courts,location,start,desc template_values = {"CourtList": courtlist} path = os.path.join(os.path.dirname(__file__), 'templates', 'delcourtconfirm.html') self.response.out.write(template.render(path, template_values))
def get(self ): query="select __key__ from CourtTime order by date" keys = db.GqlQuery( query) courtlist=[] for k in keys: r = db.get(k) if( type(r.owner) is not types.NoneType): c = Court() c.weekday = r.weekday c.date = library.cday(r.date) c.start = library.ctime(r.start) c.end = library.ctime(r.end) c.courts = library.listconv(r.courts) g = datastore.Captain.get_by_key_name( r.owner ) c.captain = g.fname + " " + g.lname c.team = g.team courtlist.append( c) template_values = { 'Courts': courtlist } path = os.path.join(os.path.dirname(__file__), 'bydate.html') self.response.out.write(template.render(path, template_values))
def get(self ): Others=[] # Others is an array captains OtherTeams=[] # Others is an array of Reservation() query="select __key__ from Captain order by lname" keys = db.GqlQuery( query) captains = db.get(keys) for e in captains: keyname = e.key().name() # Skip if its the logged in captain if( keyname == capt_keyname ): continue Others.append( e ) query="select __key__ from CourtTime where owner= '" + keyname + "'" keys = db.GqlQuery( query) res = db.get(keys) # Get the courts courtlist=[] for r in res: c = Court() c.weekday = r.weekday c.date = library.cday(r.date) c.start = library.ctime(r.start) c.end = library.ctime(r.end) c.courts = library.listconv(r.courts) courtlist.append( c) teamreserve= Reservation() # make an instance teamreserve.fname = e.fname # Captan's name teamreserve.lname = e.lname teamreserve.team = e.team # Captain's team teamreserve.courts= courtlist # list of reserved courts OtherTeams.append( teamreserve )
def post(self): print("DelConfirmHandler") courtlist = [] try: keylist = self.request.get_all('keys') print("get keys") for key in keylist: print(key) p = db.get(key) #Get the court by its unique key (key) print("db.get(key)") continue c = Courts() c.date = library.cday(p.start) c.weekday = p.weekday c.start = library.ctime(p.start) c.end = library.ctime(p.end) c.desc = p.desc c.courts = library.listconv(p.courts) c.location = library.location(p.location) c.key = key courtlist.append(c) except Exception as e: print "EXCEPTION: " + str(e) # weekday, date, courts,location,start,desc template_values = {"CourtList": courtlist}
def get1(self): query = "select __key__ from CourtTime order by date" keys = db.GqlQuery(query) courtlist = [] for k in keys: r = db.get(k) if (type(r.owner) is not types.NoneType): c = Court() c.weekday = r.weekday c.date = library.cday(r.date) c.start = library.ctime(r.start) c.end = library.ctime(r.end) c.courts = library.listconv(r.courts) g = datastore.Captain.get_by_key_name(r.owner) c.captain = g.fname + " " + g.lname c.team = g.team courtlist.append(c) for t in courtlist: self.Writeln(t.date + " " + t.weekday + " " + t.start + "->" + t.end) self.Writeln(t.captain + " " + t.team) self.Writeln("<br>")
def get(self): print("get") query = "select __key__ from CourtTime order by date" keys = db.GqlQuery(query) courtlist = [] for k in keys: p = db.get(k) c = Courts() c.weekday = p.weekday c.date = library.cday(p.date) c.start = library.ctime(p.start) c.end = library.ctime(p.end) c.courts = library.listconv(p.courts) c.location = library.location(p.location) c.desc = p.desc c.key = k courtlist.append(c) print(c.date) template_values = {'CourtList': courtlist} path = os.path.join(os.path.dirname(__file__), 'templates', 'all.html') self.response.out.write(template.render(path, template_values))
def get(self, month, day, year): LoggedIn = False User = Team = "" path = os.environ['PATH_INFO'] if (self.session.get('user')): # (NEWSESSION) LoggedIn = True User = self.session['fname'] + " " + self.session['lname'] Team = " (" + self.session['team'] + ")" d = "DATETIME(" + year + "," + month + "," + day + ")" query = "select __key__ from CourtTime where date= " + d keys = db.GqlQuery(query) available = False courtlist = [] for k in keys: p = db.get(k) # c = Court_old( p.weekday,p.courts, p.start, p.end, p.desc , k ) # DONE REFACTORed to Court c = Court() c.day = library.cday(p.start) c.start = library.ctime(p.start) c.end = library.ctime(p.end) c.desc = p.desc c.key = k c.courts = library.listconv(p.courts) c.location = library.location(p.location) c.open = True if (type(p.owner) is not types.NoneType): g = datastore.Captain.get_by_key_name(p.owner) c.owner = g.fname c.open = False courtlist.append(c) if (c.open == True): available = True template_values = { 'month': month, 'day': day, 'year': year, 'LoggedIn': LoggedIn, 'User': User, 'Team': Team, 'path': path, 'Courtlist': courtlist, 'Available': available } path = os.path.join(os.path.dirname(__file__), 'templates', 'courts.html') self.response.out.write(template.render(path, template_values))
def get(self): dayofmonth = [] for d in range(1,32): _d = Days(d) if( d == 9 ) : _d.selected="selected" dayofmonth.append( _d ) m = ["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"] mon=[] for d in range(0,len(m)): mon.append( Months(d+1,m[d]) ) hlist = [] for d in range(8,23): hlist.append( Hours(d) ) p = datastore.OpenDate.get_by_key_name( "key_opendate" ) opendate = None opentime = None if( p ): opendate = p.openingdate opentime = library.ctime(p.openingdate) # Get all the Captains query="select __key__ from Captain order by team" clist=[] Captainkeys = db.GqlQuery( query) for key in Captainkeys: c = Captains() k = db.get(key) c.fname = k.fname c.lname = k.lname c.user = k.user c.team = k.team c.password = k.password c.key = k.key().name() c.count = k.count clist.append(c) # g.date= datetime.datetime(year=int(_year), month=int(_month), day=int(_day),hour=20,minute=0) site = library.Host() template_values = { 'Site': site, 'Hours': hlist, 'Days': dayofmonth, 'Months': mon, 'opendate': opendate, 'opentime': opentime, 'Captains' : clist } path = os.path.join(os.path.dirname(__file__), 'templates', 'administer.html') self.response.out.write(template.render(path, template_values))
def __init__(self, day, courts, start, end, desc, key): self.day = library.cday(start) self.start = library.ctime(start) self.end = library.ctime(end) self.courts = "" for e in courts: self.courts = self.courts + e + "," # TODO - more efficient way to rid of last (,) comma if (self.courts != ""): self.courts = self.courts.rstrip(",") self.desc = desc self.key = key
def get(self, month, day, year): pass d = "DATETIME(" + year + "," + month + "," + day + ")" query = "select __key__ from CourtTime where date= " + d keys = db.GqlQuery(query) courtlist = [] for k in keys: p = db.get(k) c = Courts() c.day = library.cday(p.start) c.start = library.ctime(p.start) c.end = library.ctime(p.end) c.desc = p.desc c.key = k c.courts = library.listconv(p.courts) c.location = library.location(p.location) c.open = True if (type(p.owner) is not types.NoneType): g = datastore.Captain.get_by_key_name(p.owner) c.owner = g.fname c.open = False courtlist.append(c) template_values = { 'month': month, 'day': day, 'year': year, 'Courtlist': courtlist, 'LoginForm': library.LoginForm(), # 'Site' : library.Host() + "/reserve", # 'Key' : k } path = os.path.join(os.path.dirname(__file__), 'delcourts.html') self.response.out.write(template.render(path, template_values))
def get4(self): self.Writeln(" get ") try: p = datastore.OpenDate.get_by_key_name("key_opendate2") if not p: self.Writeln("cant find < ------- ") except: self.Writeln(" nope") return if (type(p) is types.NoneType): opendate = None opentime = None else: opendate = p.openingdate opentime = library.ctime(p.openingdate)
def get(self ): capt_keyname="" LoggedIn = False User = Team = "" path = os.environ['PATH_INFO'] CaptainReservation = Reservation() if(self.session.get('user') ): # (NEWSESSION) LoggedIn = True User = self.session['fname'] + " " + self.session['lname'] Team = " (" + self.session['team'] + ")" capt_keyname = self.session['keyname'] CaptainReservation.fname = self.session['fname'] CaptainReservation.lname = self.session['lname'] CaptainReservation.team = self.session['team'] # TODO more efficient db grab query="select __key__ from CourtTime where owner='" + capt_keyname + "'" keys = db.GqlQuery( query) res = db.get(keys) courtlist = [] for r in res: c = Court() c.weekday = r.weekday c.date = library.cday(r.date) c.start = library.ctime(r.start) c.end = library.ctime(r.end) c.courts = library.listconv(r.courts) courtlist.append( c) CaptainReservation.courts = courtlist # --------------------------------------------------------------------------------- query="select __key__ from CourtTime order by date" keys = db.GqlQuery( query) bydate=[] for k in keys: r = db.get(k) if( type(r.owner) is not types.NoneType): c = Court() c.weekday = r.weekday c.date = library.cday(r.date) c.start = library.ctime(r.start) c.end = library.ctime(r.end) c.courts = library.listconv(r.courts) g = datastore.Captain.get_by_key_name( r.owner ) c.captain = g.fname + " " + g.lname c.team = g.team bydate.append( c) # --------------------------------------------------------------------------------- template_values = { 'LoggedIn': LoggedIn, 'User' : User, 'Team' : Team, 'path' : path, 'CaptainReservation': CaptainReservation, 'ByDate': bydate, # 'OtherTeams': OtherTeams } path = os.path.join(os.path.dirname(__file__),'templates', 'instructions.html') self.response.out.write(template.render(path, template_values))
def post(self): LoggedIn = False User = Team = "" path = os.environ['PATH_INFO'] if (self.session.get('user')): # (NEWSESSION) LoggedIn = True User = self.session['fname'] + " " + self.session['lname'] Team = " (" + self.session['team'] + ")" if (LoggedIn == False): self.Writeln("<p><br><p><br>") self.Writeln("<body bgcolor=d2d2ff>") self.Writeln("<center>") self.Writeln("<h1>Please Login </h1>") self.Writeln("</center>") return courts = self.request.get('courts') if (courts == ""): self.Writeln("<p><br><p><br>") self.Writeln("<body bgcolor=d2d2ff>") self.Writeln("<center>") self.Writeln("<h1>Please Select Courts </h1>") self.Writeln("</center>") return e = db.get(courts) # This shouldn't ever happen since reserved court can't be selected if (type(e.owner) is not types.NoneType): self.Writeln("<p><br><p><br>") self.Writeln("<body bgcolor=d2d2ff>") self.Writeln("<center>") self.Writeln("<h1>Courts already Selected </h1>") self.Writeln("</center>") return # ------------------------------------------------------------------- # By now, use has logged in and selected courts # (NEWSESSION) captain_keyname = self.session['keyname'] Captain = datastore.Captain.get_by_key_name(captain_keyname) CourtTime = "" g = datastore.OpenDate.get_by_key_name("key_opendate") if (g == None): self.Writeln("<p><br><p><br>") self.Writeln("<center>") self.Writeln("<body bgcolor=d2d2ff>") self.Writeln("WARNING! Set Opening Date For Reservations") return start = g.openingdate StartDate = library.getDate(g.openingdate) StartTime = library.ctime(g.openingdate) Today = library.getDate(datetime.datetime.utcnow() - datetime.timedelta(hours=8)) Today = Today + " @" + library.ctime(datetime.datetime.utcnow() - datetime.timedelta(hours=7)) delta = datetime.datetime.utcnow() - datetime.timedelta( hours=8) - start if (datetime.datetime.utcnow() - datetime.timedelta(hours=8) < start): self.Writeln("<p><br><p><br>") self.Writeln("<center>") self.Writeln("<body bgcolor=d2d2ff>") self.Writeln("<h1>Can't Reserve yet </h1>") self.Writeln("<h1>Today is " + Today + "</h1>") self.Writeln("<h1>Reservations start " + StartDate + "@" + StartTime + "</h1>") self.Writeln("</center>") return Allowed = 2 + 2 * delta.days sofar = Captain.count if (sofar >= Allowed): Exceeded = True template_values = { 'Host': library.Host(), 'StartDate': StartDate, 'StartTime': StartTime, 'Today': Today, 'Allowed': Allowed, 'Captain': Captain, 'Exceeded': True } path = os.path.join(os.path.dirname(__file__), 'display_request.html') self.response.out.write(template.render(path, template_values)) return # ---------------------------------------------------------------------------------- # Reserve the courts # courts is the Key to the court selected courts = cgi.escape(self.request.get('courts')) e = db.get(courts) CourtDate = library.getDate(e.date) CourtDay = e.weekday CourtStart = library.ctime(e.start) CourtEnd = library.ctime(e.end) Courts = library.listconv(e.courts) CourtDesc = e.desc Month = e.date.month Year = e.date.year e.owner = captain_keyname # either use session value or from Captain db db.put(e) Captain.count = Captain.count + 1 db.put(Captain) template_values = { 'Host': library.Host(), 'Month': Month, 'Year': Year, 'StartDate': StartDate, 'StartTime': StartTime, 'Today': Today, 'Allowed': Allowed, 'Captain': Captain, 'CourtDate': CourtDate, 'CourtDay': CourtDay, 'CourtStart': CourtStart, 'CourtEnd': CourtEnd, 'Courts': Courts, # 'CourtDesc' : CourtEnd, 'Exceeded': False } path = os.path.join(os.path.dirname(__file__), 'templates', 'reserve.html') self.response.out.write(template.render(path, template_values))
def get(self): capt_keyname = "" LoggedIn = False User = Team = "" path = os.environ['PATH_INFO'] CaptainReservation = Reservation() if (self.session.get('user')): LoggedIn = True User = self.session['fname'] + " " + self.session['lname'] Team = " (" + self.session['team'] + ")" capt_keyname = self.session['keyname'] CaptainReservation.fname = self.session['fname'] CaptainReservation.lname = self.session['lname'] CaptainReservation.team = self.session['team'] # TODO more efficient db grab query = "select __key__ from CourtTime where owner='" + capt_keyname + "'" keys = db.GqlQuery(query) res = db.get(keys) courtlist = [] for r in res: c = Court() c.weekday = r.weekday c.date = library.cday(r.date) c.start = library.ctime(r.start) c.end = library.ctime(r.end) c.courts = library.listconv(r.courts) # loc="LP" # if( re.search("Mg",r.location,re.IGNORECASE)): loc="Mango" c.location = library.location(r.location) courtlist.append(c) CaptainReservation.courts = courtlist # --------------------------------------------------------------------------------- query = "select __key__ from CourtTime order by date" keys = db.GqlQuery(query) Mango = [] Courts = [] for k in keys: r = db.get(k) if (type(r.owner) is not types.NoneType): c = Court() c.weekday = r.weekday c.date = library.cday(r.date) c.start = library.ctime(r.start) c.end = library.ctime(r.end) c.courts = library.listconv(r.courts) g = datastore.Captain.get_by_key_name(r.owner) c.captain = g.fname + " " + g.lname c.team = g.team c.location = library.location(r.location) print("location: " + c.location) if (c.location is not types.NoneType): Courts.append(c) # --------------------------------------------------------------------------------- template_values = { 'LoggedIn': LoggedIn, 'User': User, 'Team': Team, 'path': path, 'CaptainReservation': CaptainReservation, # 'Mango': Mango, 'Courts': Courts # 'OtherTeams': OtherTeams } path = os.path.join(os.path.dirname(__file__), 'templates', 'summary.html') self.response.out.write(template.render(path, template_values))
def post(self): # SESSION LoggedIn = False if (self.session.get('user')): # (NEWSESSION) LoggedIn = True User = self.session['fname'] + " " + self.session['lname'] Team = " (" + self.session['team'] + ")" if (LoggedIn == False): self.Writeln("<p><br><p><br>") self.Writeln("<center>") self.Writeln("<h1>Please Login </h1>") self.Writeln("</center>") return # Should only get to here is there's a session fname = self.session['fname'] lname = self.session['lname'] captain_keyname = self.session['keyname'] self.Writeln("<html>") try: keyname = self.request.get('keyname') if (len(keyname) == 0): self.Writeln("<body bgcolor=#d2d2ee>") self.Writeln("<center><p><br><p><br>") self.Writeln("<h2>Please make a selection</h2>") return except: self.Writeln("<h2>Please make a selection.</h2>") return # Get the court and set the owner to None e = datastore.CourtTime.get_by_key_name(keyname) if (type(e.owner) is types.NoneType): self.Writeln("<body bgcolor=#d2d2ee>") self.Writeln("<center>") self.Writeln("<h2> Can't delete reservation </h2>") self.Writeln("<h2> Please go back and refresh the page </h2>") return e.owner = None db.put(e) # use to return to calender month/year # TODO decide if to implement in captain_unreserve.html page Month = e.date.month Year = e.date.year g = datastore.Captain.get_by_key_name(captain_keyname) g.count = g.count - 1 count = g.count db.put(g) template_values = { # 'LoginForm' : library.LoginForm(), 'Host': library.Host(), 'Month': Month, 'Year': Year, 'Count': count, 'Weekday': e.weekday, 'Day': library.cday(e.start), 'Start': library.ctime(e.start), 'End': library.ctime(e.end), 'Desc ': e.desc } path = os.path.join(os.path.dirname(__file__), 'captain_unreserve.html') self.response.out.write(template.render(path, template_values))
def get(self): capt_keyname = "" # SESSION LoggedIn = False User = Team = "" path = os.environ['PATH_INFO'] if (self.session.get('user')): # (NEWSESSION) LoggedIn = True User = self.session['fname'] + " " + self.session['lname'] Team = " (" + self.session['team'] + ")" # SESSION # Get the list of captains query = "select __key__ from Captain order by team" keys = db.GqlQuery(query) res = db.get(keys) CaptainList = [] for r in res: c = Captain() c.fname = r.fname c.lname = r.lname c.user = r.user c.team = r.team CaptainList.append(c) # CaptainReservation = Reservation() user = self.session.get('user') #Captain name (that's all we need) if (user != None): LoggedIn = True capt_keyname = self.session['keyname'] CaptainReservation.fname = self.session['fname'] CaptainReservation.lname = self.session['lname'] CaptainReservation.team = self.session['team'] g = datastore.Captain.get_by_key_name(capt_keyname) CaptainReservation.count = g.count # TODO more efficient db grab query = "select __key__ from CourtTime where owner='" + capt_keyname + "'" + " order by date " keys = db.GqlQuery(query) res = db.get(keys) courtlist = [] for r in res: c = Court() c.weekday = r.weekday c.date = library.cday(r.date) c.start = library.ctime(r.start) c.end = library.ctime(r.end) c.courts = library.listconv(r.courts) c.location = library.location(r.location) c.desc = r.desc c.key = r.key().name() courtlist.append(c) CaptainReservation.courts = courtlist # --------------------------------------------------------------------------------- template_values = { 'Host': "/", 'LoggedIn': LoggedIn, 'User': User, 'Team': Team, 'path': path, 'CaptainList': CaptainList, 'CaptainReservation': CaptainReservation, 'Site': library.Host() + "/unreserve", } path = os.path.join(os.path.dirname(__file__), 'templates', 'captain.html') self.response.out.write(template.render(path, template_values))