Beispiel #1
0
    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))
Beispiel #2
0
    def get(self):

        # New CheckLogin code built in tarsusaRequestHandler 
        if self.chk_login():
            CurrentUser = self.get_user_db()
            
            cachedUserFriendsActivities = memcache.get_item("friendstats", CurrentUser.key().id())
            if cachedUserFriendsActivities is not None:
                template_values = {
                                'UserLoggedIn': 'Logged In',
                                'UserFriendsActivities': cachedUserFriendsActivities,
                }
            else:
                
                ## SHOW YOUR FRIENDs Recent Activities
                ## Show only 9 items because we don't want to see a very long frontpage.
                UserFriendsItem_List = tarsusaCore.get_UserFriendStats(CurrentUser.key().id(),"","",9)
                
                template_values = {
                    'UserLoggedIn': 'Logged In',
                    'UserFriendsActivities': UserFriendsItem_List,
                }
                
                if not memcache.set_item("friendstats" ,UserFriendsItem_List, CurrentUser.key().id()):
                    logging.error('Cache set failed: Users_FriendStats')

            #Manupilating Templates 
            path = os.path.join(os.path.dirname(__file__), 'pages/ajaxpage_friendstats.html')
            self.response.out.write(template.render(path, template_values))
Beispiel #3
0
    def get(self):
    
        # New CheckLogin code built in tarsusaRequestHandler 
        if self.chk_login():
            CurrentUser = self.get_user_db()

            ## SHOW YOUR FRIENDs Recent Activities
            UserFriendsItem_List = tarsusaCore.get_UserFriendStats(CurrentUser.key().id())

            tarsusaLatestPeople = tarsusaCore.get_LatestUser()
            
            tarsusaUserFriendCollection = map(lambda each_FriendKey: db.get(each_FriendKey), CurrentUser.friends)
            
            template_values = {
                    'UserLoggedIn': 'Logged In',
                    
                    'UserNickName': cgi.escape(CurrentUser.dispname),
                    'UserID': CurrentUser.key().id(),
                    'UserFriends': tarsusaUserFriendCollection, 
                    'singlePageTitle': "查找朋友.",
                    'singlePageContent': "",
                    
                    'UserFriendsActivities': UserFriendsItem_List,
                    'tarsusaPeopleCollection': tarsusaLatestPeople,
            }
        
            path = os.path.join(os.path.dirname(__file__), 'pages/addfriend.html')
            self.response.out.write(template.render(path, template_values))

        else:
            ##if users.get_current_user() is None 
            #TODO   
            template_values = {
                    'UserLoggedIn': 'Logged In',
                    
                    'UserNickName': '', #cgi.escape(self.login_user.nickname()),
                    'UserID': '', #CurrentUser.key().id(),
                    'UserFriends': '', #UserFriends,    
                    'singlePageTitle': "查找朋友.",
                    'singlePageContent': "",

                    'tarsusaPeopleCollection': '', #tarsusaPeopleCollection,
            }   
            path = os.path.join(os.path.dirname(__file__), 'pages/welcome_friends.html')
            self.response.out.write(template.render(path, template_values))
 def test_tarsusaCore_getUserFriendStats(self):
     UserFriendStats = tarsusaCore.get_UserFriendStats(userid=1)
	def test_tarsusaCore_getUserFriendStats(self):
		UserFriendStats = tarsusaCore.get_UserFriendStats(userid=1)