Exemple #1
0
    def GET(self, username, p=1):
        u = users.get_user_by_username(username)
        profile = users.get_profile_by_user_id(u.id)

        page = int(p)
        perpage = 10
        offset = (page - 1) * perpage

        posts = postModel.groupGetCreatedPostsByUserId(u.id, offset, perpage).list()
        nodeids = []
        for i in xrange(len(posts)):
            nodeids += str(posts[i].nodeId).split()

        nodeList = []
        for i in xrange(len(nodeids)):
            nodeList += nodeModel.getNodesByNodeId(nodeids[i])

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

        #是否登录,
        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
            is_voted = None
            notification_results = None
            notification_num = None
            ntf_list = None
            ntf_posts = None
            ntf_users = None

        return view.base(view.member_node_contributed(u, profile, nodeList, authors),user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
Exemple #2
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()
Exemple #3
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()
Exemple #4
0
    def GET(self, username, p=1):
        u = users.get_user_by_username(username)
        print user

        if u:
            page = int(p)
            perpage = 5
            offset = (page - 1) * perpage

            created_posts = postModel.getCreatedPostsByUserId(u.id, offset, perpage).list()

            nodes = []
            for i in xrange(len(created_posts)):
                nodes += nodeModel.getNodesByNodeId(created_posts[i].nodeId)

            #得到资料
            profile = users.get_profile_by_user_id(u.id)

            #是否登录,
            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
                is_voted = None
                notification_results = None
                notification_num = None
                ntf_list = None
                ntf_posts = None
                ntf_users = None
                
            return view.base(view.member_home(u, profile, created_posts, nodes, user), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
        else:
            raise web.notfound()
Exemple #5
0
    def GET(self, username, p=1):
        u = users.get_user_by_username(username)
        profile = users.get_profile_by_user_id(u.id)

        page = int(p)
        perpage = 10
        offset = (page - 1) * perpage

        nodeList = nodeModel.getCreatedNodesByUserId(u.id, offset,
                                                     perpage).list()

        #是否登录,
        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
            is_voted = None
            notification_results = None
            notification_num = None
            ntf_list = None
            ntf_posts = None
            ntf_users = None

        return view.base(view.member_node(u, profile, nodeList,
                                          user), user, siteName, rights,
                         ntf_list, notification_num, ntf_posts, ntf_users)
Exemple #6
0
    def GET(self, img_id):
        img = image.get_img_by_imgid(img_id)
        author = web.listget(users.get_users_by_id(img.userID) , 0, {})

        fav_user = image.GetFavImageByImageId(img_id).list()
        fav_user_ids = []
        for i in xrange(len(fav_user)):
            fav_user_ids += str(fav_user[i].user_id).split()

        usernnames = []
        for i in xrange(len(fav_user_ids)):
            usernnames += users.get_users_by_id(fav_user_ids[i])

        return view.base03(view.photo_fans(img_id, img, usernnames, author), user, siteName, 2)
Exemple #7
0
    def GET(self):
        # u = users.get_user_by_id(session.get_user_id())
        # ut = u.nicknameChangeTime #得到上次修改昵称的时间
        # c = datetime.datetime.now()#得到当前时间

        # if (c - ut).days < 30: #时间差
        #     can_change_nickname = False
        # else:
        #     can_change_nickname = True

        #得到权限
        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

        #得到资料设置
        profile = users.get_profile_by_user_id(user.id)
        #得到邮箱验证状态
        confirm = users.get_confirm_email_by_douban_id(user.douban_id)

        return view.base(view.member_setting_profile(user, profile, confirm),
                         user, siteName, rights, ntf_list, notification_num,
                         ntf_posts, ntf_users)
Exemple #8
0
    def GET(self, img_id):
        img = image.get_img_by_imgid(img_id)
        author = web.listget(users.get_users_by_id(img.userID), 0, {})

        fav_user = image.GetFavImageByImageId(img_id).list()
        fav_user_ids = []
        for i in xrange(len(fav_user)):
            fav_user_ids += str(fav_user[i].user_id).split()

        usernnames = []
        for i in xrange(len(fav_user_ids)):
            usernnames += users.get_users_by_id(fav_user_ids[i])

        return view.base(view.photo_fans(img_id, img, usernnames, author),
                         user, siteName)
Exemple #9
0
    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)
Exemple #10
0
    def GET(self, nodeId):
        date = datetime.datetime.today().strftime(
            "%a, %d %b %Y %H:%M:%S +0200")
        node = nodeModel.getNodeByNodeId(nodeId)
        posts = list(
            db.select("_post",
                      order="id DESC",
                      limit=10,
                      vars=dict(nodeId=nodeId),
                      where='nodeId = $nodeId'))
        authors = []
        for i in xrange(len(posts)):
            authors += users.get_users_by_id(posts[i].postAuthor)

        nodes = []
        for i in xrange(len(posts)):
            nodes += nodeModel.getNodesByNodeId(posts[i].nodeId)

        feed_url = "http://www.biubiubiubiu.com/'+ nodeId +'feed"

        ishome = False

        web.header('Content-Type', 'application/xml')
        return view.feed_index(node, posts, date, authors, nodes, feed_url,
                               ishome)
Exemple #11
0
    def GET(self, id):
        img = image.get_img_by_imgid(id)
        if img:
            i = web.input(start=0, order=default_order, desc='desc', query='')
            start = int(i.start)
            user_id = session.is_logged() and session.get_user_id()
            author_id = img.userID
            results, num_results = image.query(author_id)
            pager = web.storage(paging.get_paging_results(start, num_results, 
                int(id), results, results_per_page))
            #tm = time.strftime('%Y年%m月%d日', time.localtime(img.creationTime))
            author = users.get_user_by_id(img.userID)
            results = list(results)
            is_favorite = image.IsFavorite(user_id, img.id)

            #得到被多少人喜欢
            #count = image.GetFavUserCount(img_id)

            #浏览人数加1
            if user_id and image.user_not_viewed_image(user_id, id):
                image.add_img_hit(id)
                image.add_user_to_img_viewed(user_id, id)

            #得到评论
            comments = image.get_comment_by_image_id(id).list()
            #得到评论者信息
            comments_authors_ids = []
            for i in xrange(len(comments)):
                #comments_authors_ids += str(comments[i].user_id).split()
                comments_authors_ids += users.get_users_by_id(comments[i].user_id).list()
            

            return view.base03(view.photo_single(img, pager, user_id, user, author, is_favorite, comments, comments_authors_ids), user, siteName, 2)
        else:
            raise web.notfound()
Exemple #12
0
    def GET(self):
        last_users = users.last_users().list()
        last_image = image.get_last_image().list()

        #得到最新图片的上传者ID
        authorsID = []
        for u in last_image:
            authorsID += str(u.userID).split()

        #根据ID去用户表查找
        authors = []
        for i in xrange(len(authorsID)):
            authors += users.get_users_by_id(authorsID[i])

        #得到最新图片ID
        # img_ids = []
        # for i in last_image:
        #     img_ids += str(i.id).split()

        #得到最新图片的被喜欢数
        # count = []
        # for i in xrange(len(img_ids)):
        #     count += str(image.GetFavUserCount(img_ids[i]))

        return view.base(view.explore(last_users, last_image, authors), user,
                         siteName)
Exemple #13
0
    def GET(self):
        last_users = users.last_users().list()
        last_image = image.get_last_image().list()

        #得到最新图片的上传者ID
        authorsID = []
        for u in last_image:
            authorsID += str(u.userID).split()

        #根据ID去用户表查找
        authors = []
        for i in xrange(len(authorsID)):
            authors += users.get_users_by_id(authorsID[i])

        #得到最新图片ID
        # img_ids = []
        # for i in last_image:
        #     img_ids += str(i.id).split()

        #得到最新图片的被喜欢数
        # count = []
        # for i in xrange(len(img_ids)):
        #     count += str(image.GetFavUserCount(img_ids[i]))

        return view.base(view.explore(last_users, last_image, authors), user, siteName)
Exemple #14
0
    def GET(self):
        last_users = users.last_users().list()
        last_image = image.get_last_image().list()

        #得到最新图片的上传者ID
        authorsID = []
        for u in last_image:
            authorsID += str(u.userID).split()

        #根据ID去用户表查找
        authors = []
        for i in xrange(len(authorsID)):
            authors += users.get_users_by_id(authorsID[i])

        #得到最新图片ID
        # img_ids = []
        # for i in last_image:
        #     img_ids += str(i.id).split()

        #得到最新图片的被喜欢数
        # count = []
        # for i in xrange(len(img_ids)):
        #     count += str(image.GetFavUserCount(img_ids[i]))
        rights = None
        notification_results = None
        notification_num = None
        ntf_list = None
        ntf_posts = None
        ntf_users = None
        apply_log = {}

        return view.base(view.explore(last_users, last_image,
                                      authors), user, siteName, rights,
                         ntf_list, notification_num, ntf_posts, ntf_users)
Exemple #15
0
    def GET(self):
        last_users = users.last_users().list()
        last_image = image.get_last_image().list()

        #得到最新图片的上传者ID
        authorsID = []
        for u in last_image:
            authorsID += str(u.userID).split()

        #根据ID去用户表查找
        authors = []
        for i in xrange(len(authorsID)):
            authors += users.get_users_by_id(authorsID[i])

        #得到最新图片ID
        # img_ids = []
        # for i in last_image:
        #     img_ids += str(i.id).split()

        #得到最新图片的被喜欢数
        # count = []
        # for i in xrange(len(img_ids)):
        #     count += str(image.GetFavUserCount(img_ids[i]))
        rights = None
        notification_results = None
        notification_num = None
        ntf_list = None
        ntf_posts = None
        ntf_users = None
        apply_log = {}

        return view.base(view.explore(last_users, last_image, authors), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users )
Exemple #16
0
    def GET(self):
        date = datetime.datetime.today().strftime(
            "%a, %d %b %Y %H:%M:%S +0200")
        rec_posts = list(
            db.select('_admin_rec_home', where='pid', order="pid_sort"))

        postList = []
        for i in xrange(len(rec_posts)):
            postList += postModel.getPostsByPostId(rec_posts[i].pid)

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

        nodes = []
        for i in xrange(len(postList)):
            nodes += nodeModel.getNodesByNodeId(postList[i].nodeId)

        feed_url = "http://www.biubiubiubiu.com/feed"

        ishome = True
        node = None

        web.header('Content-Type', 'application/xml')

        return view.feed_index(node, postList, date, authors, nodes, feed_url,
                               ishome)
Exemple #17
0
    def GET(self, result=''):
        per = users.get_permission_by_douid(user.douban_id)
        rights = per[0].rights

        if rights > 1:
            results_per_page = 8 #每页显示8条记录
            default_order = 'id'

            i = web.input(start=0, order=default_order, desc='desc', query='', result='')
            start = int(i.start)
            result = i.result

            results, num_results = users.get_applys(query=i.query, 
                offset=start, limit=results_per_page, order=i.order + ' ' + i.desc, user_id=None, result=result)

            pager = web.storage(paging.get_paging(start, num_results, 
                results_per_page=results_per_page, window_size=1))

            apply_list = list(results)

            admin_list = []
            for i in xrange(len(apply_list)):
                admin_list += users.get_users_by_id(apply_list[i].operator)

            user_list = []
            for i in xrange(len(apply_list)):
                user_list += users.get_douban_users_by_doubanid(apply_list[i].douban_id)

            return view.template_admin(view.admin_apply_for_permission(apply_list, pager, admin_list, user_list, result))
        else:
            raise web.notfound
Exemple #18
0
    def GET(self):
        per = users.get_permission_by_douid(user.douban_id)
        rights = per[0].rights
        if rights > 1 : #管理员权限
            #post
            rec_posts = admin.get_rec_posts()
            rec_nodes = admin.get_rec_nodes()

            #post
            postList = []
            for i in xrange(len(rec_posts)):
                postList += postModel.getPostsByPostId(rec_posts[i].pid)

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

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

            p= []
            for post in postList:
                p += str(post.nodeId).split()

            post_nodes = []
            for i in xrange(len(p)):
                post_nodes += nodeModel.getNodesByNodeId(p[i])

            #node
            nodeList = []
            for i in xrange(len(rec_nodes)):
                nodeList += nodeModel.getNodesByNodeId(rec_nodes[i].nid)

            n = []
            for node in nodeList:
                n += str(node.node_author).split()

            node_authors = []
            for i in xrange(len(n)):
                node_authors += users.get_users_by_id(n[i])
            
            # if rec_nodes or rec_posts:
            return view.template_admin(view.admin_home(postList, post_authors, post_nodes,  nodeList, node_authors))
        else:
            raise web.notfound()
Exemple #19
0
    def GET(self):
        # u = users.get_user_by_id(session.get_user_id())
        # ut = u.nicknameChangeTime #得到上次修改昵称的时间
        # c = datetime.datetime.now()#得到当前时间

        # if (c - ut).days < 30: #时间差
        #     can_change_nickname = False
        # else:
        #     can_change_nickname = True

        #得到权限
        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

        #得到资料设置
        profile = users.get_profile_by_user_id(user.id)
        #得到邮箱验证状态
        confirm = users.get_confirm_email_by_douban_id(user.douban_id)

        return view.base(view.member_setting_profile(user, profile, confirm), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
Exemple #20
0
 def GET(self):
     per = users.get_permission_by_douid(user.douban_id)
     rights = per[0].rights
     if rights > 1:
         nodeList = nodeModel.getLastNodes().list()
         authors = []
         for i in xrange(len(nodeList)):
             authors += users.get_users_by_id(nodeList[i].node_author)
         return view.base(view.node_all(nodeList, authors), user, siteName, rights, ntf_list=None, notification_num=None, ntf_posts=None, ntf_users=None)
     else:
         return web.notfound()
Exemple #21
0
 def GET(self):
     per = users.get_permission_by_douid(user.douban_id)
     rights = per[0].rights
     if rights > 1:
         nodeList = nodeModel.getLastNodes().list()
         authors = []
         for i in xrange(len(nodeList)):
             authors += users.get_users_by_id(nodeList[i].node_author)
         return view.base(view.node_all(nodeList, authors), user, siteName, rights, ntf_list=None, notification_num=None, ntf_posts=None, ntf_users=None)
     else:
         return web.notfound()
Exemple #22
0
    def GET(self, nodeId):
        date = datetime.datetime.today().strftime("%a, %d %b %Y %H:%M:%S +0200")
        node = nodeModel.getNodeByNodeId(nodeId)
        posts = list(db.select("_post", order="id DESC", limit=10, vars=dict(nodeId=nodeId), where='nodeId = $nodeId'))
        authors = []
        for i in xrange(len(posts)):
            authors += users.get_users_by_id(posts[i].postAuthor)

        nodes = []
        for i in xrange(len(posts)):
            nodes += nodeModel.getNodesByNodeId(posts[i].nodeId)

        feed_url="http://www.biubiubiubiu.com/'+ nodeId +'feed"

        ishome = False

        web.header('Content-Type', 'application/xml')
        return view.feed_index(node, posts, date, authors, nodes, feed_url, ishome)
Exemple #23
0
    def GET(self):
        #得到当前用户的权限
        per = users.get_permission_by_douid(user.douban_id)
        rights = per[0].rights
        if rights > 1:
            results_per_page = 8 #每页显示8个用户
            default_order = 'id'

            i = web.input(start=0, order=default_order, desc='desc', query='')
            start = int(i.start)
            # context = context or 'all'
            # user_id = session.is_logged() and session.get_user_id()

            results, num_results = admin.query(query=i.query, 
                offset=start, limit=results_per_page, order=i.order + ' ' + i.desc, user_id=None)

            pager = web.storage(paging.get_paging(start, num_results, 
                results_per_page=results_per_page, window_size=1))

            u = user

            #查询用户权限表
            douban_id_list = []
            users_list = list(results)
            for i in xrange(len(users_list)):
                douban_id_list += users_list[i].douban_id.split()

            permissions = []
            for i in xrange(len(douban_id_list)):
                permissions += users.get_permission_by_douid(douban_id_list[i])

            admin_list = []
            for i in xrange(len(permissions)):
                if permissions[i].operator:
                    admin_list += users.get_users_by_id(permissions[i].operator)
                else:
                    admin_list += "s"

            timestrf = misc.timestrf

            return view.template_admin(view.admin_users(users_list, pager, u, permissions, rights, timestrf, admin_list))
        else:
            raise web.notfound()
Exemple #24
0
    def GET(self, username, page_num):
        u = users.get_user_by_username(username)
        page = int(page_num)
        perpage = 10
        offset = (page - 1) * perpage

        posts = postModel.groupGetCreatedPostsByUserId(u.id, offset, perpage).list()
        nodeids = []
        for i in xrange(len(posts)):
            nodeids += str(posts[i].nodeId).split()

        nodeList = []
        for i in xrange(len(nodeids)):
            nodeList += nodeModel.getNodesByNodeId(nodeids[i])

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

        return view.node_list_contributed_more(nodeList, authors)
Exemple #25
0
    def GET(self, username, page_num):
        u = users.get_user_by_username(username)
        page = int(page_num)
        perpage = 10
        offset = (page - 1) * perpage

        posts = postModel.groupGetCreatedPostsByUserId(u.id, offset,
                                                       perpage).list()
        nodeids = []
        for i in xrange(len(posts)):
            nodeids += str(posts[i].nodeId).split()

        nodeList = []
        for i in xrange(len(nodeids)):
            nodeList += nodeModel.getNodesByNodeId(nodeids[i])

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

        return view.node_list_contributed_more(nodeList, authors)
Exemple #26
0
    def GET(self, username, page_num):
        u = users.get_user_by_username(username)
        page = int(page_num)
        perpage = 5
        offset = (page - 1) * perpage

        liked_pids = postModel.getLikedPostsByUserId(u.id, offset, perpage).list()

        liked_posts = []
        for i in xrange(len(liked_pids)):
            liked_posts += postModel.getPostsByPostId(liked_pids[i].pid)

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

        nodes = []
        for i in xrange(len(liked_posts)):
            nodes += nodeModel.getNodesByNodeId(liked_posts[i].nodeId)

        return view.post_list_member_like_more(u, liked_posts, nodes, authors)
Exemple #27
0
    def GET(self, username, page_num):
        u = users.get_user_by_username(username)
        page = int(page_num)
        perpage = 5
        offset = (page - 1) * perpage

        liked_pids = postModel.getLikedPostsByUserId(u.id, offset,
                                                     perpage).list()

        liked_posts = []
        for i in xrange(len(liked_pids)):
            liked_posts += postModel.getPostsByPostId(liked_pids[i].pid)

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

        nodes = []
        for i in xrange(len(liked_posts)):
            nodes += nodeModel.getNodesByNodeId(liked_posts[i].nodeId)

        return view.post_list_member_like_more(u, liked_posts, nodes, authors)
Exemple #28
0
    def GET(self, id):
        img = image.get_img_by_imgid(id)
        if img:
            i = web.input(start=0, order=default_order, desc='desc', query='')
            start = int(i.start)
            user_id = session.is_logged() and session.get_user_id()
            author_id = img.userID
            results, num_results = image.query(author_id)
            pager = web.storage(
                paging.get_paging_results(start, num_results, int(id), results,
                                          results_per_page))
            #tm = time.strftime('%Y年%m月%d日', time.localtime(img.creationTime))
            author = users.get_user_by_id(img.userID)
            results = list(results)
            is_favorite = image.IsFavorite(user_id, img.id)

            #得到被多少人喜欢
            #count = image.GetFavUserCount(img_id)

            #浏览人数加1
            if user_id and image.user_not_viewed_image(user_id, id):
                image.add_img_hit(id)
                image.add_user_to_img_viewed(user_id, id)

            #得到评论
            comments = image.get_comment_by_image_id(id).list()
            #得到评论者信息
            comments_authors_ids = []
            for i in xrange(len(comments)):
                #comments_authors_ids += str(comments[i].user_id).split()
                comments_authors_ids += users.get_users_by_id(
                    comments[i].user_id).list()

            return view.base(
                view.photo_single(img, pager, user_id, user, author,
                                  is_favorite, comments, comments_authors_ids),
                user, siteName)
        else:
            raise web.notfound()
Exemple #29
0
    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)
Exemple #30
0
    def GET(self):
        date = datetime.datetime.today().strftime("%a, %d %b %Y %H:%M:%S +0200")
        rec_posts = list(db.select('_admin_rec_home', where='pid', order="pid_sort"))

        postList = []
        for i in xrange(len(rec_posts)):
            postList += postModel.getPostsByPostId(rec_posts[i].pid)

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

        nodes = []
        for i in xrange(len(postList)):
            nodes += nodeModel.getNodesByNodeId(postList[i].nodeId)

        feed_url="http://www.biubiubiubiu.com/feed"

        ishome = True
        node = None

        web.header('Content-Type', 'application/xml')

        return view.feed_index(node, postList, date, authors, nodes, feed_url, ishome)
Exemple #31
0
    def GET(self):
        # if user.is_logged:

        rec_posts = admin.get_rec_posts()
        # if rec_posts:
        postList = []
        for i in xrange(len(rec_posts)):
            postList += postModel.getPostsByPostId(rec_posts[i].pid)

        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])

        n = []
        for post in postList:
            n += str(post.nodeId).split()

        nodes = []
        for i in xrange(len(n)):
            nodes += nodeModel.getNodesByNodeId(n[i])

        if user.is_logged:
            per = users.get_permission_by_douid(user.douban_id)
            rights = per[0].rights

            if users.is_user_exist_in_apply_log(
                    user.douban_id):  #如果申请记录表中有此用户记录:
                apply_log = users.get_log_result(user.douban_id)
            else:
                apply_log = {}

            #得到提醒
            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 = None
            apply_log = None
            ntf_list = None
            notification_num = None
            ntf_posts = None
            ntf_users = None

        return view.base(
            view.recommend_posts(postList, authors, nodes, user, rights,
                                 apply_log), user, siteName, rights, ntf_list,
            notification_num, ntf_posts, ntf_users)
Exemple #32
0
    def GET(self):
        rec_nodes = admin.get_rec_nodes()

        nodeList = []
        
        for node in rec_nodes:
            nodeList.extend(nodeModel.getNodesByNodeId(node.nid))

        authors = []
        for node in nodeList:
            authors.extend(users.get_users_by_id(node.node_author))

        #得到最新的那个post
        lastest_posts = []
        for node in nodeList:
            recent_post_in_node = postModel.getRecentOnePostsInNode(node.id)
            if recent_post_in_node:
                lastest_posts.extend(recent_post_in_node.creation_ts.timetuple())

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

            if users.is_user_exist_in_apply_log(user.douban_id): #如果申请记录表中有此用户记录:
                apply_log = users.get_log_result(user.douban_id)
            else:
                apply_log = {}

            #得到提醒
            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 notify in ntf_list:
                ntf_posts.extend(postModel.getPostsByPostId(notify.pid))
                ntf_users.extend(users.get_users_by_id(notify.uid))

            for notify in mtf_list:
                mtf_posts.extend(postModel.getPostsByPostId(notify.pid))
                mtf_users.extend(users.get_users_by_id(notify.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 = None
            notification_results = None
            notification_num = None
            ntf_list = None
            ntf_posts = None
            ntf_users = None
            apply_log = {}
        return view.base(view.recommend_nodes(nodeList, authors, user, rights, apply_log, lastest_posts, datetime), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
Exemple #33
0
    def GET(self):
        # foo = web.cookies(cookieName=defaultValue)
        # foo.age
        #if user.is_logged:
        if True: # 全部开放
            rec_posts = admin.get_rec_posts()
            postList = []
            # if len(rec_posts) > 20:
            #     map(lambda x:postList.extend(postModel.getPostsByPostId(x.pid)), rec_posts)
            # else:
            #     postList = list(postModel.getRecent20Posts())
            map(lambda x:postList.extend(postModel.getPostsByPostId(x.pid)), rec_posts)

            #postList = sort_dict_by_multi_key(postList, ['magnitude', 'creation_ts'], reverse=True)
            #postList = sorted(postList, key=lambda x:x.creation_ts, reverse=True)
                

            authors = []
            map(lambda x:authors.extend(users.get_users_by_id(x)), [x.postAuthor for x in postList])

            nodes = []
            map(lambda x:nodes.extend(nodeModel.getNodesByNodeId(x)), [x.nodeId for x in postList])

            if user.is_logged:
                rights = users.get_permission_by_douid(user.douban_id)[0].rights

                if users.is_user_exist_in_apply_log(user.douban_id): #如果申请记录表中有此用户记录:
                    apply_log = users.get_log_result(user.douban_id)
                else:
                    apply_log = {}

                #得到提醒
                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 notify in ntf_list:
                    ntf_posts.extend(postModel.getPostsByPostId(notify.pid))
                    ntf_users.extend(users.get_users_by_id(notify.uid))

                for notify in mtf_list:
                    mtf_posts.extend(postModel.getPostsByPostId(notify.pid))
                    mtf_users.extend(users.get_users_by_id(notify.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 = None
                apply_log = None
                ntf_list = None
                notification_num = None
                ntf_posts = None
                ntf_users = None

            return view.base(view.recommend_posts(postList, authors, nodes, user, rights, apply_log, filter_tags), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)

        else:
            from config import db
            #得到上线时间距今多少天
            t = time.strptime('2013-03-15 02:15:57', "%Y-%m-%d %X")
            ts = datetime.datetime(* t[:6])
            delta = (datetime.datetime.now() - ts).days 

            #得到用户数
            user_count = int(db.select('users', what='count(distinct id) as c')[0].c)
            #得到话题数
            node_count = int(db.select('_node', what='count(distinct id) as c')[0].c)
            #得到片段数
            post_count = int(db.select('_post', what='count(distinct id) as c')[0].c)
            #得到喜欢数
            vote_count = int(db.select('_post_vote_user', what='count(distinct id) as c')[0].c)
            #得到评论数
            comm_count = int(db.select('_post_comments', what='count(distinct id) as c')[0].c)

            r = str(random.randint(1, 17))

            return view.base01(view.landing(r, delta, user_count, node_count, post_count, vote_count, comm_count), siteName)
Exemple #34
0
    def GET(self, username, p=1):
        u = users.get_user_by_username(username)
        if u:
            page = int(p)
            perpage = 5
            offset = (page - 1) * perpage

            created_posts = postModel.getCreatedPostsByUserId(u.id, offset, perpage).list()
            nodes = []
            for i in xrange(len(created_posts)):
                nodes += nodeModel.getNodesByNodeId(created_posts[i].nodeId)
            #得到资料
            profile = users.get_profile_by_user_id(u.id)
            #note 跳转到豆瓣
            # raise web.seeother('http://www.douban.com/people/'+ username)
            

            # pf = users.get_profile_by_user_id(u.id)
            # #得到上传的图片数
            # results,num_results = image.query(u.id)
            # #得到喜欢的图片数
            # fav_count = image.GetUserFavCount(u.id)

            # #得到用户上传的图片路径
            # imagePath = image.get_paths_by_id(u.id).list()
            # paths = []
            # for p in imagePath:
            #     paths += p.path.split()
            # #得到图片id
            # imageIDs = image.get_imageID_by_id(u.id).list()
            # img_ids = []
            # for i in imageIDs:
            #     img_ids += str(i.id).split()
            # return view.base(view.member_home(u, pf, paths, img_ids, num_results, fav_count), user, siteName)

            #是否登录,
            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
                is_voted = None
                notification_results = None
                notification_num = None
                ntf_list = None
                ntf_posts = None
                ntf_users = None
            return view.base(view.member_home(u, profile, created_posts, nodes, user, replace_breaks), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
        else:
            raise web.notfound()
Exemple #35
0
    def GET(self, arg, ntf_type=''):
        #ntf_type为提醒类型,用来让用户从提醒页面访问片段页面时可以看到对应提醒

        post = postModel.getPostByPostId(arg)
        if post:
            post_author_info = users.get_user_by_id(post.postAuthor)
            node = nodeModel.getNodeByNodeId(post.nodeId)
            timestrf = misc.timestrf

            likers = postModel.get_voters_by_pid(post.id)
            likers_list = []
            for i in xrange(len(likers)):
                likers_list += users.get_users_by_id(likers[i].uid)

            comments = postModel.get_comments_by_pid(post.id).list()
            commenters = []
            for i in xrange(len(comments)):
                commenters += users.get_users_by_id(comments[i].uid)

            #是否登录,
            if user.is_logged:
                per = users.get_permission_by_douid(user.douban_id)
                rights = per[0].rights
                #是否投过票
                is_voted = postModel.is_voted(arg, user.id)
                #得到提醒
                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_type = web.input(ntf_type='').ntf_type

                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
                is_voted = None
                notification_results = None
                notification_num = None
                ntf_list = None
                ntf_posts = None
                ntf_users = None

            return view.base(view.post_single(rights, node, post, post_author_info, user, timestrf, likers_list, comments, commenters, ntf_type, is_voted, misc), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
        else:
            raise web.notfound()
Exemple #36
0
    def GET(self, username, p=1):
        u = users.get_user_by_username(username)
        if u:
            page = int(p)
            perpage = 5
            offset = (page - 1) * perpage

            liked_pids = postModel.getLikedPostsByUserId(
                u.id, offset, perpage).list()

            liked_posts = []
            for i in xrange(len(liked_pids)):
                liked_posts += postModel.getPostsByPostId(liked_pids[i].pid)

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

            nodes = []
            for i in xrange(len(liked_posts)):
                nodes += nodeModel.getNodesByNodeId(liked_posts[i].nodeId)

            #得到资料
            profile = users.get_profile_by_user_id(u.id)

            #是否登录,
            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
                is_voted = None
                notification_results = None
                notification_num = None
                ntf_list = None
                ntf_posts = None
                ntf_users = None
            return view.base(
                view.member_favorite(u, profile, liked_posts, nodes, authors,
                                     user), user, siteName, rights, ntf_list,
                notification_num, ntf_posts, ntf_users)
        else:
            raise web.notfound()
Exemple #37
0
    def GET(self):
        # if user.is_logged:

        rec_posts = admin.get_rec_posts()
        # if rec_posts:
        postList = []
        for i in xrange(len(rec_posts)):
            postList += postModel.getPostsByPostId(rec_posts[i].pid)

        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])

        n= []
        for post in postList:
            n += str(post.nodeId).split()

        nodes = []
        for i in xrange(len(n)):
            nodes += nodeModel.getNodesByNodeId(n[i])
        
        if user.is_logged:
            per = users.get_permission_by_douid(user.douban_id)
            rights = per[0].rights

            if users.is_user_exist_in_apply_log(user.douban_id): #如果申请记录表中有此用户记录:
                apply_log = users.get_log_result(user.douban_id)
            else:
                apply_log = {}

            #得到提醒
            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 = None
            apply_log = None
            ntf_list = None
            notification_num = None
            ntf_posts = None
            ntf_users = None



        return view.base(view.recommend_posts(postList, authors, nodes, user, rights, apply_log), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
Exemple #38
0
    def GET(self):
        rec_nodes = admin.get_rec_nodes()

        nodeList = []
        
        for i in xrange(len(rec_nodes)):
            nodeList += nodeModel.getNodesByNodeId(rec_nodes[i].nid)

        a = []
        for node in nodeList:
            a += str(node.node_author).split()

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

        #得到最新的那个post
        lastest_posts = []
        for i in xrange(len(nodeList)):
            #如果没有,去取node的创建时间
            if postModel.getRecentOnePostsInNode(nodeList[i].id):
                lastest_posts += str(time.mktime(postModel.getRecentOnePostsInNode(nodeList[i].id).creation_ts.timetuple())).split()
            else:
                lastest_posts += str(time.mktime(nodeModel.getNodeByNodeId(nodeList[i].id).creation_ts.timetuple())).split()

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

            if users.is_user_exist_in_apply_log(user.douban_id): #如果申请记录表中有此用户记录:
                apply_log = users.get_log_result(user.douban_id)
            else:
                apply_log = {}

            #得到提醒
            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 = None
            notification_results = None
            notification_num = None
            ntf_list = None
            ntf_posts = None
            ntf_users = None
            apply_log = {}
        return view.base(view.recommend_nodes(nodeList, authors, user, rights, apply_log, lastest_posts, datetime), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
Exemple #39
0
    def GET(self, arg, ntf_type=''):
        #ntf_type为提醒类型,用来让用户从提醒页面访问片段页面时可以看到对应提醒

        post = postModel.getPostByPostId(arg)
        if post:
            post_author_info = users.get_user_by_id(post.postAuthor)
            node = nodeModel.getNodeByNodeId(post.nodeId)
            timestrf = misc.timestrf

            likers = postModel.get_voters_by_pid(post.id)
            likers_list = []
            for i in xrange(len(likers)):
                likers_list += users.get_users_by_id(likers[i].uid)

            comments = postModel.get_comments_by_pid(post.id).list()
            commenters = []
            for i in xrange(len(comments)):
                commenters += users.get_users_by_id(comments[i].uid)

            #是否登录,
            if user.is_logged:
                per = users.get_permission_by_douid(user.douban_id)
                rights = per[0].rights
                #是否投过票
                is_voted = postModel.is_voted(arg, user.id)
                #得到提醒
                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_type = web.input(ntf_type='').ntf_type

                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
                is_voted = None
                notification_results = None
                notification_num = None
                ntf_list = None
                ntf_posts = None
                ntf_users = None

            return view.base(
                view.post_single(rights, node, post, post_author_info, user,
                                 timestrf, likers_list, comments, commenters,
                                 ntf_type, is_voted, misc), user, siteName,
                rights, ntf_list, notification_num, ntf_posts, ntf_users)
        else:
            raise web.notfound()
Exemple #40
0
    def GET(self):
        rec_nodes = admin.get_rec_nodes()

        nodeList = []

        for i in xrange(len(rec_nodes)):
            nodeList += nodeModel.getNodesByNodeId(rec_nodes[i].nid)

        a = []
        for node in nodeList:
            a += str(node.node_author).split()

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

        #得到最新的那个post
        lastest_posts = []
        for i in xrange(len(nodeList)):
            #如果没有,去取node的创建时间
            if postModel.getRecentOnePostsInNode(nodeList[i].id):
                lastest_posts += str(
                    time.mktime(
                        postModel.getRecentOnePostsInNode(
                            nodeList[i].id).creation_ts.timetuple())).split()
            else:
                lastest_posts += str(
                    time.mktime(
                        nodeModel.getNodeByNodeId(
                            nodeList[i].id).creation_ts.timetuple())).split()

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

            if users.is_user_exist_in_apply_log(
                    user.douban_id):  #如果申请记录表中有此用户记录:
                apply_log = users.get_log_result(user.douban_id)
            else:
                apply_log = {}

            #得到提醒
            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 = None
            notification_results = None
            notification_num = None
            ntf_list = None
            ntf_posts = None
            ntf_users = None
            apply_log = {}
        return view.base(
            view.recommend_nodes(nodeList, authors, user, rights, apply_log,
                                 lastest_posts, datetime), user, siteName,
            rights, ntf_list, notification_num, ntf_posts, ntf_users)