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("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): 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 ): 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 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, 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 __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 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 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))