コード例 #1
0
    def GET(self, arg, p=1):
        node = nodeModel.getNodeByNodeId(arg)
        if node:
            timestrf = misc.timestrf
            page = int(p)
            perpage = 10
            offset = (page - 1) * perpage

            node_author_info = users.get_user_by_id(node.node_author)
            postList = postModel.getPostListByNodeIdSortByScore(arg, offset, perpage).list()

            a = []
            for post in postList:
                a += str(post.postAuthor).split()

            authors = []
            for i in xrange(len(a)):
                authors += users.get_users_by_id(a[i])

            #得到权限
            if user.is_logged:
                per = users.get_permission_by_douid(user.douban_id)
                rights = per[0].rights

                #得到提醒
                notification_results, notification_num = notification.get_unread_notification(user.id)
                #得到@提醒
                notification_mention_results, mention_num= notification.get_unread_metion_notifition(user.id)
                #链表 得到提醒的详细id\名称等
                ntf_posts = []
                ntf_users = []
                mtf_posts = []
                mtf_users = []

                ntf_list = notification_results.list()
                mtf_list = notification_mention_results.list()
                for x in xrange(len(ntf_list)):
                    ntf_posts += postModel.getPostsByPostId(ntf_list[x].pid)
                    ntf_users += users.get_users_by_id(ntf_list[x].uid)

                for x in xrange(len(mtf_list)):
                    mtf_posts += postModel.getPostsByPostId(mtf_list[x].pid)
                    mtf_users += users.get_users_by_id(mtf_list[x].uid)

                ntf_list = ntf_list + mtf_list
                ntf_posts = ntf_posts + mtf_posts
                ntf_users = ntf_users + mtf_users
                notification_num = notification_num+mention_num

            else:
                rights = 0
                notification_results = None
                notification_num = None
                ntf_list = None
                ntf_posts = None
                ntf_users = None

            return view.base(view.node_show(timestrf, rights, node, postList, node_author_info, user, authors, sort='interesting'), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
        else:
            raise web.notfound()
コード例 #2
0
ファイル: node.py プロジェクト: liutaihua/emotion-gallery
    def GET(self, arg, p=1):
        node = nodeModel.getNodeByNodeId(arg)
        if node:
            timestrf = misc.timestrf
            page = int(p)
            perpage = 10
            offset = (page - 1) * perpage

            node_author_info = users.get_user_by_id(node.node_author)
            postList = postModel.getPostListByNodeIdSortByScore(arg, offset, perpage).list()

            a = []
            for post in postList:
                a += str(post.postAuthor).split()

            authors = []
            for i in xrange(len(a)):
                authors += users.get_users_by_id(a[i])

            #得到权限
            if user.is_logged:
                per = users.get_permission_by_douid(user.douban_id)
                rights = per[0].rights

                #得到提醒
                notification_results, notification_num = notification.get_unread_notification(user.id)
                #得到@提醒
                notification_mention_results, mention_num= notification.get_unread_metion_notifition(user.id)
                #链表 得到提醒的详细id\名称等
                ntf_posts = []
                ntf_users = []
                mtf_posts = []
                mtf_users = []

                ntf_list = notification_results.list()
                mtf_list = notification_mention_results.list()
                for x in xrange(len(ntf_list)):
                    ntf_posts += postModel.getPostsByPostId(ntf_list[x].pid)
                    ntf_users += users.get_users_by_id(ntf_list[x].uid)

                for x in xrange(len(mtf_list)):
                    mtf_posts += postModel.getPostsByPostId(mtf_list[x].pid)
                    mtf_users += users.get_users_by_id(mtf_list[x].uid)

                ntf_list = ntf_list + mtf_list
                ntf_posts = ntf_posts + mtf_posts
                ntf_users = ntf_users + mtf_users
                notification_num = notification_num+mention_num

            else:
                rights = 0
                notification_results = None
                notification_num = None
                ntf_list = None
                ntf_posts = None
                ntf_users = None

            return view.base(view.node_show(timestrf, rights, node, postList, node_author_info, user, authors, sort='interesting'), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
        else:
            raise web.notfound()
コード例 #3
0
ファイル: node.py プロジェクト: naoyeye/rhinoceros
    def GET(self, arg, page_num):
        page = int(page_num)
        perpage = 10
        offset = (page - 1) * perpage

        url = web.ctx.get('path')
        if int(url.count('recent')) == 0:
            postList = postModel.getPostListByNodeIdSortByScore(
                arg, offset, perpage).list()
        else:
            postList = postModel.getPostListByNodeIdSortByID(
                arg, offset, perpage).list()

        a = []
        for post in postList:
            a += str(post.postAuthor).split()

        authors = []
        for i in xrange(len(a)):
            authors += users.get_users_by_id(a[i])

        if int(url.count('recent')) == 0:
            return view.post_list(postList, authors)
        else:
            return view.post_list(postList, authors)
コード例 #4
0
ファイル: node.py プロジェクト: liutaihua/emotion-gallery
    def GET(self, arg, page_num):
        page = int(page_num)
        perpage = 10
        offset = (page - 1) * perpage

        url = web.ctx.get('path')
        if int(url.count('recent')) == 0:
            postList = postModel.getPostListByNodeIdSortByScore(arg, offset, perpage).list()
        else:
            postList = postModel.getPostListByNodeIdSortByID(arg, offset, perpage).list()

        a = []
        for post in postList:
            a += str(post.postAuthor).split()

        authors = []
        for i in xrange(len(a)):
            authors += users.get_users_by_id(a[i])

        if int(url.count('recent')) == 0:
            return view.post_list(postList, authors, re)
        else:
            return view.post_list(postList, authors, re)