def get(self): ''' New Ajax Functions suites for multiple usage for new calit2 Template. ''' func = self.request.get("func") maxitems = self.request.get("maxitems") if maxitems != '': maxitems = int(maxitems) #template_name = self.request.get("template") template_name = "calit2" CurrentUser = self.get_user_db() template_values = { 'UserNickName': cgi.escape(CurrentUser.dispname), 'UserID': CurrentUser.key().id(), 'func': func, } if func == "done": tarsusaItemCollection_AjaxUserItems = tarsusaCore.get_tarsusaItemCollection(CurrentUser.key().id(), done=True, maxitems=maxitems) template_values['tarsusaItemCollection_AjaxUserItems'] = tarsusaItemCollection_AjaxUserItems elif func == "undone": tarsusaItemCollection_AjaxUserItems = tarsusaCore.get_tarsusaItemCollection(CurrentUser.key().id(), done=False, maxitems=maxitems) template_values['tarsusaItemCollection_AjaxUserItems'] = tarsusaItemCollection_AjaxUserItems elif func == "dailyroutine": tarsusaItemCollection_AjaxUserItems = tarsusaCore.get_dailyroutine(CurrentUser.key().id()) template_values['tarsusaItemCollection_AjaxUserItems'] = tarsusaItemCollection_AjaxUserItems elif func == "friends": UserFriendsItem_List = tarsusaCore.get_UserFriendStats(CurrentUser.key().id()) template_values['UserFriendsActivities'] = UserFriendsItem_List path = os.path.join(os.path.dirname(__file__), 'pages/%s/ajax_content_%s.html' % (template_name, "itemlist")) self.write(template.render(path, template_values))
def get(self): #Initialize tag_ViewFirstPage = True # New CheckLogin code built in tarsusaRequestHandler if self.chk_login(): CurrentUser = self.get_user_db() try: pageid = self.request.path[len('/m/todo/'):] if pageid[:2] == 'p/': tag_ViewPreviousPage = True pageid = pageid[2:] else: tag_ViewPreviousPage = False except: pass if pageid != None and len(self.request.path) > 8: tag_ViewFirstPage = False this_timestamp = datetime.datetime.fromtimestamp(int(pageid)) if tag_ViewPreviousPage == True: #Limitation sharding startpoint differed since recent GAE updates. #problem arouses around r118. #print this_timestamp #tarsusaItemCollection_UserTodoItems = db.GqlQuery("SELECT * FROM tarsusaItem WHERE user = :1 and routine = 'none' and done = False and date > :2 ORDER BY date ASC LIMIT 9", CurrentUser.user, this_timestamp) tarsusaItemCollection_UserTodoItems = tarsusaCore.get_tarsusaItemCollection( userid=CurrentUser.key().id(), done=False, startdate=this_timestamp) else: #tarsusaItemCollection_UserTodoItems = db.GqlQuery("SELECT * FROM tarsusaItem WHERE user = :1 and routine = 'none' and done = False and date <= :2 ORDER BY date DESC LIMIT 9", CurrentUser.user, this_timestamp) tarsusaItemCollection_UserTodoItems = tarsusaCore.get_tarsusaItemCollection( userid=CurrentUser.key().id(), done=False, enddate=this_timestamp) else: ## Below begins user todo items. for MOBILE page. #tarsusaItemCollection_UserTodoItems = db.GqlQuery("SELECT * FROM tarsusaItem WHERE user = :1 and routine = 'none' and done = False ORDER BY date DESC LIMIT 9", CurrentUser.user) # r120m test with new function in tarsusaCore. tarsusaItemCollection_UserTodoItems = tarsusaCore.get_tarsusaItemCollection( CurrentUser.key().id(), False) #Determine next page Find_Last_Index = 0 previous_timestamp = 0 next_timestamp = 0 Find_Last_Index = len(tarsusaItemCollection_UserTodoItems) #self.write(Find_Last_Index) #self.write(tarsusaItemCollection_UserTodoItems) try: previous_timestamp = int( time.mktime(tarsusaItemCollection_UserTodoItems[0] ['date'].timetuple())) next_timestamp = int( time.mktime(tarsusaItemCollection_UserTodoItems[ Find_Last_Index - 1]['date'].timetuple())) except: pass if Find_Last_Index == 1 and tag_ViewPreviousPage == True: self.redirect("/m/todo") #if next_timestamp == 0 and previous_timestamp == 0: # self.redirect("/m/todo") template_values = { 'MobilePageTag': 'ToDo', 'UserLoggedIn': 'Logged In', 'UserNickName': cgi.escape(CurrentUser.dispname), 'UserID': CurrentUser.key().id(), 'tarsusaItemCollection_UserToDoItems': tarsusaItemCollection_UserTodoItems, 'htmltag_today': datetime.datetime.date(datetime.datetime.now()), } # if users items are not so many, do not display the pagination if Find_Last_Index >= 1 and tag_ViewFirstPage != True: template_values['previouspagestamp'] = previous_timestamp if next_timestamp != 0 and Find_Last_Index >= 9 and pageid != None: template_values['nextpagestamp'] = next_timestamp #Manupilating Templates if utilities.get_UserAgent( os.environ['HTTP_USER_AGENT']) == 'iPod': path = os.path.join(os.path.dirname(__file__), 'pages/iPod/mobile_itodopage.html') self.response.out.write(template.render(path, template_values)) else: path = os.path.join(os.path.dirname(__file__), 'pages/mobile_todopage.html') self.response.out.write(template.render(path, template_values)) else: self.redirect("/m")
def test_tarsusaCore_gettarsusaItemCollection(self): #entity = model.MyEntity(name='Foo') #self.assertEqual('Foo', entity.name) tarsusaItemCollection_UserTodoItems = tarsusaCore.get_tarsusaItemCollection( userid=1, done=False)
def test_tarsusaCore_gettarsusaItemCollection(self): #entity = model.MyEntity(name='Foo') #self.assertEqual('Foo', entity.name) tarsusaItemCollection_UserTodoItems = tarsusaCore.get_tarsusaItemCollection(userid=1, done=False)
def get(self): #Initialize tag_ViewFirstPage = True # New CheckLogin code built in tarsusaRequestHandler if self.chk_login(): CurrentUser = self.get_user_db() try: pageid = self.request.path[len('/m/todo/'):] if pageid[:2] == 'p/': tag_ViewPreviousPage = True pageid = pageid[2:] else: tag_ViewPreviousPage = False except: pass if pageid != None and len(self.request.path) > 8: tag_ViewFirstPage = False this_timestamp = datetime.datetime.fromtimestamp(int(pageid)) if tag_ViewPreviousPage == True: #Limitation sharding startpoint differed since recent GAE updates. #problem arouses around r118. #print this_timestamp #tarsusaItemCollection_UserTodoItems = db.GqlQuery("SELECT * FROM tarsusaItem WHERE user = :1 and routine = 'none' and done = False and date > :2 ORDER BY date ASC LIMIT 9", CurrentUser.user, this_timestamp) tarsusaItemCollection_UserTodoItems = tarsusaCore.get_tarsusaItemCollection(userid=CurrentUser.key().id(), done=False, startdate=this_timestamp) else: #tarsusaItemCollection_UserTodoItems = db.GqlQuery("SELECT * FROM tarsusaItem WHERE user = :1 and routine = 'none' and done = False and date <= :2 ORDER BY date DESC LIMIT 9", CurrentUser.user, this_timestamp) tarsusaItemCollection_UserTodoItems = tarsusaCore.get_tarsusaItemCollection(userid=CurrentUser.key().id(), done=False, enddate=this_timestamp) else: ## Below begins user todo items. for MOBILE page. #tarsusaItemCollection_UserTodoItems = db.GqlQuery("SELECT * FROM tarsusaItem WHERE user = :1 and routine = 'none' and done = False ORDER BY date DESC LIMIT 9", CurrentUser.user) # r120m test with new function in tarsusaCore. tarsusaItemCollection_UserTodoItems = tarsusaCore.get_tarsusaItemCollection(CurrentUser.key().id(), False) #Determine next page Find_Last_Index = 0 previous_timestamp = 0 next_timestamp = 0 Find_Last_Index = len(tarsusaItemCollection_UserTodoItems) #self.write(Find_Last_Index) #self.write(tarsusaItemCollection_UserTodoItems) try: previous_timestamp = int(time.mktime(tarsusaItemCollection_UserTodoItems[0]['date'].timetuple())) next_timestamp = int(time.mktime(tarsusaItemCollection_UserTodoItems[Find_Last_Index -1 ]['date'].timetuple())) except: pass if Find_Last_Index == 1 and tag_ViewPreviousPage == True: self.redirect("/m/todo") #if next_timestamp == 0 and previous_timestamp == 0: # self.redirect("/m/todo") template_values = { 'MobilePageTag': 'ToDo', 'UserLoggedIn': 'Logged In', 'UserNickName': cgi.escape(CurrentUser.dispname), 'UserID': CurrentUser.key().id(), 'tarsusaItemCollection_UserToDoItems': tarsusaItemCollection_UserTodoItems, 'htmltag_today': datetime.datetime.date(datetime.datetime.now()), } # if users items are not so many, do not display the pagination if Find_Last_Index >= 1 and tag_ViewFirstPage != True: template_values['previouspagestamp'] = previous_timestamp if next_timestamp != 0 and Find_Last_Index >= 9 and pageid != None: template_values['nextpagestamp'] = next_timestamp #Manupilating Templates if utilities.get_UserAgent(os.environ['HTTP_USER_AGENT']) == 'iPod': path = os.path.join(os.path.dirname(__file__), 'pages/iPod/mobile_itodopage.html') self.response.out.write(template.render(path, template_values)) else: path = os.path.join(os.path.dirname(__file__), 'pages/mobile_todopage.html') self.response.out.write(template.render(path, template_values)) else: self.redirect("/m")
def post(self): apiappid = self.request.get('apiappid') apiservicekey = self.request.get('servicekey') apiuserid = self.request.get('apiuserid') apikey = self.request.get('apikey') userid = self.request.get('userid') done = self.request.get('done') #logging.info(done == True) #logging.info(done == 'True') #Confirmed it is 'True' in text if done == 'True': done = True elif done == 'False': done = False else: done = None logging.info(done) routine = self.request.get('routine') if routine == '': routine='none' #logging.info(routine) #!!!!! #Below Settings should be changed #When user can check other users ITEMs! # public = self.request.get('public') if public == '': public = 'none' #'none' means it doesn't matter, display all items. #logging.info(public) maxitems = self.request.get('maxitems') if maxitems == None or maxitems == '': count = 10 else: count = int(maxitems) if count > 100: count = 100 #logging.info(maxitems) #''' beforedate = self.request.get('beforedate') # enddate='', afterdate = self.request.get('afterdate') # startdate='', # startdonedate='' # enddonedate='' #''' if apiuserid == userid: #Get APIUser's Items #I think there are still problem concerning different paras. #for example, if you don't want sort by routine, then you should ignore it. #but for a get_tarsusaItemCollection with all para in it, you are not ignoring it. #It can only get todo or done items. tarsusaItemCollection_UserDoneItems = tarsusaCore.get_tarsusaItemCollection(userid, done=done, routine=routine, startdate=afterdate, enddate=beforedate, maxitems=count, public=public) logging.info(tarsusaItemCollection_UserDoneItems) self.write(tarsusaItemCollection_UserDoneItems) else: #trying to Get Other Users Items return self.response_status(403, '<h1>Currently You can\'t get other user\'s items.</h1>', False)
def post(self): apiappid = self.request.get('apiappid') apiservicekey = self.request.get('servicekey') apiuserid = self.request.get('apiuserid') apikey = self.request.get('apikey') userid = self.request.get('userid') done = self.request.get('done') #logging.info(done == True) #logging.info(done == 'True') #Confirmed it is 'True' in text if done == 'True': done = True elif done == 'False': done = False else: done = None logging.info(done) routine = self.request.get('routine') if routine == '': routine = 'none' #logging.info(routine) #!!!!! #Below Settings should be changed #When user can check other users ITEMs! # public = self.request.get('public') if public == '': public = 'none' #'none' means it doesn't matter, display all items. #logging.info(public) maxitems = self.request.get('maxitems') if maxitems == None or maxitems == '': count = 10 else: count = int(maxitems) if count > 100: count = 100 #logging.info(maxitems) #''' beforedate = self.request.get('beforedate') # enddate='', afterdate = self.request.get('afterdate') # startdate='', # startdonedate='' # enddonedate='' #''' if apiuserid == userid: #Get APIUser's Items #I think there are still problem concerning different paras. #for example, if you don't want sort by routine, then you should ignore it. #but for a get_tarsusaItemCollection with all para in it, you are not ignoring it. #It can only get todo or done items. tarsusaItemCollection_UserDoneItems = tarsusaCore.get_tarsusaItemCollection( userid, done=done, routine=routine, startdate=afterdate, enddate=beforedate, maxitems=count, public=public) logging.info(tarsusaItemCollection_UserDoneItems) self.write(tarsusaItemCollection_UserDoneItems) else: #trying to Get Other Users Items return self.response_status( 403, '<h1>Currently You can\'t get other user\'s items.</h1>', False)