• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.check_cheating函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中r2.lib.utils.check_cheating函数的典型用法代码示例。如果您正苦于以下问题:Python check_cheating函数的具体用法?Python check_cheating怎么用?Python check_cheating使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_cheating函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: GET_listing

    def GET_listing(self, where, vuser, sort, time, **env):
        self.where = where
        self.sort = sort
        self.time = time

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        if self.sort in ("hot", "new"):
            self.time = "all"

        # hide spammers profile pages
        if (not c.user_is_loggedin or (c.user._id != vuser._id and not c.user_is_admin)) and vuser._spam:
            return self.abort404()

        if where not in ("overview", "submitted", "comments") and not votes_visible(vuser):
            return self.abort404()

        check_cheating("user")

        self.vuser = vuser
        self.render_params = {"user": vuser}
        c.profilepage = True

        if vuser.pref_hide_from_robots:
            self.robots = "noindex,nofollow"

        return ListingController.GET_listing(self, **env)
开发者ID:Roj,项目名称:reddit,代码行数:29,代码来源:listingcontroller.py


示例2: GET_listing

    def GET_listing(self, where, vuser, sort, time, **env):
        self.where = where
        self.sort = sort
        self.time = time

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        if self.sort in  ('hot', 'new'):
            self.time = 'all'


        # hide spammers profile pages
        if (not c.user_is_loggedin or
            (c.user._id != vuser._id and not c.user_is_admin)) \
               and vuser._spam:
            return self.abort404()

        if (where not in ('overview', 'submitted', 'comments')
            and not votes_visible(vuser)):
            return self.abort404()

        check_cheating('user')

        self.vuser = vuser
        self.render_params = {'user' : vuser}
        c.profilepage = True

        return ListingController.GET_listing(self, **env)
开发者ID:donslice,项目名称:reddit,代码行数:30,代码来源:listingcontroller.py


示例3: GET_listing

    def GET_listing(self, where, vuser, **env):
        self.where = where
        self.vuser = vuser
        self.render_params = {'user' : vuser}
        c.profilepage = True

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        # pretend deleted users don't exist (although they are in the db still)
        if vuser._deleted:
            return self.abort404()

        # hide spammers profile pages
        if (not c.user_is_loggedin or
            (c.user._id != vuser._id and not c.user_is_admin)) \
               and vuser._spam:
            return self.abort404()

        if (where not in ('profile', 'overview', 'submitted', 'comments')
            and not votes_visible(vuser)):
            return self.abort404()

        check_cheating('user')

        if where == 'profile':
            url = self.check_wiki_maybe_redirect_url()
            if url is not None:
                return self.redirect(url, 303)

        return ListingController.GET_listing(self, **env)
开发者ID:EeroHeikkinen,项目名称:ikaros,代码行数:32,代码来源:listingcontroller.py


示例4: GET_listing

    def GET_listing(self, where, vuser, sort, time, show, **env):
        self.where = where
        self.sort = sort
        self.time = time
        self.show = show

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        if self.sort in  ('hot', 'new'):
            self.time = 'all'


        # hide spammers profile pages
        if (not c.user_is_loggedin or
            (c.user._id != vuser._id and not c.user_is_admin)) \
               and vuser._spam:
            return self.abort404()

        if where in ('liked', 'disliked') and not votes_visible(vuser):
            return self.abort403()

        if ((where in ('saved', 'hidden') or 
                (where == 'gilded' and show == 'given')) and
                not (c.user_is_loggedin and c.user._id == vuser._id) and
                not c.user_is_admin):
            return self.abort403()

        if where == 'saved':
            self.show_chooser = True
            category = VSavedCategory('category').run(env.get('category'))
            srname = request.GET.get('sr')
            if srname and c.user.gold:
                try:
                    sr = Subreddit._by_name(srname)
                except NotFound:
                    sr = None
            else:
                sr = None
            if category and not c.user.gold:
                category = None
            self.savedsr = sr
            self.savedcategory = category

        check_cheating('user')

        self.vuser = vuser
        self.render_params = {'user' : vuser}
        c.profilepage = True

        if vuser.pref_hide_from_robots:
            self.robots = 'noindex,nofollow'

        return ListingController.GET_listing(self, **env)
开发者ID:Dakta,项目名称:reddit,代码行数:55,代码来源:listingcontroller.py


示例5: GET_listing

    def GET_listing(self, where, vuser, sort, time, show, **env):
        self.where = where
        self.sort = sort
        self.time = time
        self.show = show

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        if self.sort in ("hot", "new"):
            self.time = "all"

        # hide spammers profile pages
        if (not c.user_is_loggedin or (c.user._id != vuser._id and not c.user_is_admin)) and vuser._spam:
            return self.abort404()

        if where in ("liked", "disliked") and not votes_visible(vuser):
            return self.abort403()

        if (
            (where in ("saved", "hidden") or (where == "gilded" and show == "given"))
            and not (c.user_is_loggedin and c.user._id == vuser._id)
            and not c.user_is_admin
        ):
            return self.abort403()

        if where == "saved":
            self.show_chooser = True
            category = VSavedCategory("category").run(env.get("category"))
            srname = request.GET.get("sr")
            if srname and c.user.gold:
                try:
                    sr = Subreddit._by_name(srname)
                except NotFound:
                    sr = None
            else:
                sr = None
            if category and not c.user.gold:
                category = None
            self.savedsr = sr
            self.savedcategory = category

        check_cheating("user")

        self.vuser = vuser
        self.render_params = {"user": vuser}
        c.profilepage = True

        if vuser.pref_hide_from_robots:
            self.robots = "noindex,nofollow"

        return ListingController.GET_listing(self, **env)
开发者ID:kcchristianson,项目名称:reddit,代码行数:53,代码来源:listingcontroller.py


示例6: GET_comments

    def GET_comments(self, article, comment, context, sort, num_comments):
        """Comment page for a given 'article'."""
        if not c.default_sr and c.site._id != article.sr_id: 
            return self.abort404()

        # if there is a focal comment, communicate down to comment_skeleton.html who
        # that will be
        if comment:
            c.focal_comment = comment._id36

        # check if we just came from the submit page
        infotext = None
        if request.get.get('already_submitted'):
            infotext = strings.already_submitted % article.resubmit_link()

        check_cheating('comments')

        # figure out number to show based on the menu
        user_num = c.user.pref_num_comments or g.num_comments
        num = g.max_comments if num_comments == 'true' else user_num

        builder = CommentBuilder(article, CommentSortMenu.operator(sort), 
                                 comment, context)
        listing = NestedListing(builder, num = num,
                                parent_name = article._fullname)
        
        displayPane = PaneStack()

        # if permalink page, add that message first to the content
        if comment:
            displayPane.append(PermalinkMessage(article.permalink))

        # insert reply box only for logged in user
        if c.user_is_loggedin and article.subreddit_slow.can_submit(c.user):
            displayPane.append(CommentReplyBox())
            #no comment box for permalinks
            if not comment:
                displayPane.append(CommentReplyBox(link_name = 
                                                   article._fullname))
        # finally add the comment listing
        displayPane.append(listing.listing())

        loc = None if c.focal_comment or context is not None else 'comments'
        
        res = LinkInfoPage(link = article, 
                           content = displayPane, 
                           nav_menus = [CommentSortMenu(default = sort), 
                                        NumCommentsMenu(article.num_comments,
                                                        default=num_comments)],
                           infotext = infotext).render()
        return res
开发者ID:cmak,项目名称:reddit,代码行数:51,代码来源:front.py


示例7: GET_listing

    def GET_listing(self, where, vuser, sort, time, show, **env):
        self.where = where
        self.sort = sort
        self.time = time
        self.show = show

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        if self.sort in  ('hot', 'new'):
            self.time = 'all'


        # hide spammers profile pages
        if (not c.user_is_loggedin or
            (c.user._id != vuser._id and not c.user_is_admin)) \
               and vuser._spam:
            return self.abort404()

        if where in ('liked', 'disliked') and not votes_visible(vuser):
            return self.abort403()

        if ((where in ('saved', 'hidden') or 
                (where == 'gilded' and show == 'given')) and
                not (c.user_is_loggedin and c.user._id == vuser._id) and
                not c.user_is_admin):
            return self.abort403()

        if where == 'saved':
            self.show_chooser = True

        check_cheating('user')

        self.vuser = vuser
        self.render_params = {'user' : vuser}
        c.profilepage = True

        if vuser.pref_hide_from_robots:
            self.robots = 'noindex,nofollow'

        return ListingController.GET_listing(self, **env)
开发者ID:aburan28,项目名称:reddit,代码行数:42,代码来源:listingcontroller.py


示例8: GET_listing

    def GET_listing(self, where, vuser, **env):
        self.where = where

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        # hide spammers profile pages
        if (not c.user_is_loggedin or (c.user._id != vuser._id and not c.user_is_admin)) and vuser._spam:
            return self.abort404()

        if where not in ("overview", "submitted", "comments") and not votes_visible(vuser):
            return self.abort404()

        check_cheating("user")

        self.vuser = vuser
        self.render_params = {"user": vuser}
        c.profilepage = True

        return ListingController.GET_listing(self, **env)
开发者ID:kevinrose,项目名称:diggit,代码行数:21,代码来源:listingcontroller.py


示例9: GET_listing

    def GET_listing(self, where, vuser, sort, time, show, **env):
        self.where = where
        self.sort = sort
        self.time = time
        self.show = show

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        if self.sort in ("hot", "new"):
            self.time = "all"

        # hide spammers profile pages
        if (not c.user_is_loggedin or (c.user._id != vuser._id and not c.user_is_admin)) and vuser._spam:
            return self.abort404()

        if where in ("liked", "disliked") and not votes_visible(vuser):
            return self.abort403()

        if (
            (where in ("saved", "hidden") or (where == "gilded" and show == "given"))
            and not (c.user_is_loggedin and c.user._id == vuser._id)
            and not c.user_is_admin
        ):
            return self.abort403()

        if where == "saved":
            self.show_chooser = True

        check_cheating("user")

        self.vuser = vuser
        self.render_params = {"user": vuser}
        c.profilepage = True

        if vuser.pref_hide_from_robots:
            self.robots = "noindex,nofollow"

        return ListingController.GET_listing(self, **env)
开发者ID:vladimirus,项目名称:reddit,代码行数:40,代码来源:listingcontroller.py


示例10: GET_comments

    def GET_comments(self, article, comment, context, sort, limit, depth):
        """Comment page for a given 'article'."""
        if comment and comment.link_id != article._id:
            return self.abort404()

        sr = Subreddit._byID(article.sr_id, True)

        if sr.name == g.takedown_sr:
            request.environ['REDDIT_TAKEDOWN'] = article._fullname
            return self.abort404()

        if not c.default_sr and c.site._id != sr._id:
            return self.abort404()

        if not can_view_link_comments(article):
            abort(403, 'forbidden')

        #check for 304
        self.check_modified(article, 'comments')

        # If there is a focal comment, communicate down to
        # comment_skeleton.html who that will be. Also, skip
        # comment_visits check
        previous_visits = None
        if comment:
            c.focal_comment = comment._id36
        elif (c.user_is_loggedin and c.user.gold and
              c.user.pref_highlight_new_comments):
            #TODO: remove this profiling if load seems okay
            from datetime import datetime
            before = datetime.now(g.tz)
            previous_visits = self._comment_visits(article, c.user, c.start_time)
            after = datetime.now(g.tz)
            delta = (after - before)
            msec = (delta.seconds * 1000 + delta.microseconds / 1000)
            if msec >= 100:
                g.log.warning("previous_visits code took %d msec" % msec)

        # check if we just came from the submit page
        infotext = None
        if request.get.get('already_submitted'):
            infotext = strings.already_submitted % article.resubmit_link()

        check_cheating('comments')

        if not c.user.pref_num_comments:
            num = g.num_comments
        elif c.user.gold:
            num = min(c.user.pref_num_comments, g.max_comments_gold)
        else:
            num = min(c.user.pref_num_comments, g.max_comments)

        kw = {}
        # allow depth to be reset (I suspect I'll turn the VInt into a
        # validator on my next pass of .compact)
        if depth is not None and 0 < depth < MAX_RECURSION:
            kw['max_depth'] = depth
        elif c.render_style == "compact":
            kw['max_depth'] = 5

        displayPane = PaneStack()

        # allow the user's total count preferences to be overwritten
        # (think of .embed as the use case together with depth=1)

        if limit and limit > 0:
            num = limit

        if c.user_is_loggedin and c.user.gold:
            if num > g.max_comments_gold:
                displayPane.append(InfoBar(message =
                                           strings.over_comment_limit_gold
                                           % max(0, g.max_comments_gold)))
                num = g.max_comments_gold
        elif num > g.max_comments:
            if limit:
                displayPane.append(InfoBar(message =
                                       strings.over_comment_limit
                                       % dict(max=max(0, g.max_comments),
                                              goldmax=max(0,
                                                   g.max_comments_gold))))
            num = g.max_comments

        # if permalink page, add that message first to the content
        if comment:
            displayPane.append(PermalinkMessage(article.make_permalink_slow()))

        displayPane.append(LinkCommentSep())

        # insert reply box only for logged in user
        if c.user_is_loggedin and can_comment_link(article) and not is_api():
            #no comment box for permalinks
            display = False
            if not comment:
                age = c.start_time - article._date
                if age.days < g.REPLY_AGE_LIMIT:
                    display = True
            displayPane.append(UserText(item = article, creating = True,
                                        post_form = 'comment',
                                        display = display,
#.........这里部分代码省略.........
开发者ID:NkL4,项目名称:reddit,代码行数:101,代码来源:front.py


示例11: GET_comments

    def GET_comments(self, article, comment, context, sort, num_comments):
        """Comment page for a given 'article'."""
        if comment and comment.link_id != article._id:
            return self.abort404()

        if not c.default_sr and c.site._id != article.sr_id:
            return self.abort404()

        if not article.subreddit_slow.can_view(c.user):
            abort(403, "forbidden")

        # check for 304
        self.check_modified(article, "comments")

        # if there is a focal comment, communicate down to
        # comment_skeleton.html who that will be
        if comment:
            c.focal_comment = comment._id36

        # check if we just came from the submit page
        infotext = None
        if request.get.get("already_submitted"):
            infotext = strings.already_submitted % article.resubmit_link()

        check_cheating("comments")

        # figure out number to show based on the menu (when num_comments
        # is 'true', the user wants to temporarily override their
        # comments limit pref
        user_num = c.user.pref_num_comments or g.num_comments
        num = g.max_comments if num_comments == "true" else user_num

        builder = CommentBuilder(article, CommentSortMenu.operator(sort), comment, context)
        listing = NestedListing(builder, num=num, parent_name=article._fullname)

        displayPane = PaneStack()

        # if permalink page, add that message first to the content
        if comment:
            displayPane.append(PermalinkMessage(article.make_permalink_slow()))

        # insert reply box only for logged in user
        if c.user_is_loggedin and article.subreddit_slow.can_comment(c.user) and not is_api():
            # no comment box for permalinks
            displayPane.append(
                UserText(item=article, creating=True, post_form="comment", display=not bool(comment), cloneable=True)
            )

        # finally add the comment listing
        displayPane.append(listing.listing())

        loc = None if c.focal_comment or context is not None else "comments"

        res = LinkInfoPage(
            link=article,
            comment=comment,
            content=displayPane,
            subtitle=_("comments"),
            nav_menus=[CommentSortMenu(default=sort), NumCommentsMenu(article.num_comments, default=num_comments)],
            infotext=infotext,
        ).render()
        return res
开发者ID:rajbot,项目名称:tikical,代码行数:62,代码来源:front.py


示例12: GET_comments

    def GET_comments(self, article, comment, context, sort, num_comments):
        """Comment page for a given 'article'."""
        if comment and comment.link_id != article._id:
            return self.abort404()

        if not c.default_sr and c.site._id != article.sr_id:
            return self.redirect(article.make_permalink_slow(), 301)

        # moderator is either reddit's moderator or an admin
        is_moderator = c.user_is_loggedin and c.site.is_moderator(c.user) or c.user_is_admin
        if article._spam and not is_moderator:
            return self.abort404()

        if not article.subreddit_slow.can_view(c.user):
            abort(403, 'forbidden')

        #check for 304
        self.check_modified(article, 'comments')

        # if there is a focal comment, communicate down to comment_skeleton.html who
        # that will be
        if comment:
            c.focal_comment = comment._id36

        # check if we just came from the submit page
        infotext = None
        if request.get.get('already_submitted'):
            infotext = strings.already_submitted % article.resubmit_link()

        check_cheating('comments')

        # figure out number to show based on the menu
        user_num = c.user.pref_num_comments or g.num_comments
        num = g.max_comments if num_comments == 'true' else user_num

        # Override sort if the link has a default set
        if hasattr(article, 'comment_sort_order'):
            sort = article.comment_sort_order

        builder = CommentBuilder(article, CommentSortMenu.operator(sort),
                                 comment, context)
        listing = NestedListing(builder, num = num,
                                parent_name = article._fullname)

        displayPane = PaneStack()

        # if permalink page, add that message first to the content
        if comment:
            permamessage = PermalinkMessage(
                comment.make_anchored_permalink(
                    context = context + 1 if context else 1,
                    anchor  = 'comments'
                ),
                has_more_comments = hasattr(comment, 'parent_id')
            )
            displayPane.append(permamessage)

        # insert reply box only for logged in user
        if c.user_is_loggedin and article.subreddit_slow.can_comment(c.user):
            displayPane.append(CommentReplyBox())
            #no comment box for permalinks
            if not comment:
                displayPane.append(CommentReplyBox(link_name =
                                                   article._fullname))
        # finally add the comment listing
        displayPane.append(listing.listing())

        loc = None if c.focal_comment or context is not None else 'comments'

        if article.comments_enabled:
            sort_menu = CommentSortMenu(default = sort, type='dropdown2')
            if hasattr(article, 'comment_sort_order'):
                sort_menu.enabled = False
            nav_menus = [sort_menu,
                         NumCommentsMenu(article.num_comments,
                                         default=num_comments)]

            content = CommentListing(
                content = displayPane,
                num_comments = article.num_comments,
                nav_menus = nav_menus,
            )
        else:
            content = PaneStack()

        is_canonical = article.canonical_url.endswith(_force_unicode(request.path)) and not request.GET

        res = LinkInfoPage(link = article, comment = comment,
                           content = content,
                           infotext = infotext,
                           is_canonical = is_canonical).render()

        if c.user_is_loggedin:
            article._click(c.user)

        return res
开发者ID:JoshuaDavid,项目名称:lesswrong-1,代码行数:96,代码来源:front.py


示例13: GET_comments

    def GET_comments(self, article, comment, context, sort, num_comments):
        """Comment page for a given 'article'."""
        if comment and comment.link_id != article._id:
            return self.abort404()

        if not c.default_sr and c.site._id != article.sr_id:
            return self.abort404()

        if not article.subreddit_slow.can_view(c.user):
            abort(403, "forbidden")

        # check for 304
        self.check_modified(article, "comments")

        # if there is a focal comment, communicate down to comment_skeleton.html who
        # that will be
        if comment:
            c.focal_comment = comment._id36

        # check if we just came from the submit page
        infotext = None
        if request.get.get("already_submitted"):
            infotext = strings.already_submitted % article.resubmit_link()

        check_cheating("comments")

        # figure out number to show based on the menu
        user_num = c.user.pref_num_comments or g.num_comments
        num = g.max_comments if num_comments == "true" else user_num

        builder = CommentBuilder(article, CommentSortMenu.operator(sort), comment, context)
        listing = NestedListing(builder, num=num, parent_name=article._fullname)

        displayPane = PaneStack()

        # if permalink page, add that message first to the content
        if comment:
            permamessage = PermalinkMessage(
                comment.make_anchored_permalink(context=context + 1 if context else 1, anchor="comments"),
                has_more_comments=hasattr(comment, "parent_id"),
            )
            displayPane.append(permamessage)

        # insert reply box only for logged in user
        if c.user_is_loggedin and article.subreddit_slow.can_comment(c.user):
            displayPane.append(CommentReplyBox())
            # no comment box for permalinks
            if not comment:
                displayPane.append(CommentReplyBox(link_name=article._fullname))
        # finally add the comment listing
        displayPane.append(listing.listing())

        loc = None if c.focal_comment or context is not None else "comments"

        if article.comments_enabled:
            content = CommentListing(
                content=displayPane,
                num_comments=article.num_comments,
                nav_menus=[CommentSortMenu(default=sort), NumCommentsMenu(article.num_comments, default=num_comments)],
            )
        else:
            content = PaneStack()

        res = LinkInfoPage(link=article, comment=comment, content=content, infotext=infotext).render()
        return res
开发者ID:jsomers,项目名称:lesswrong,代码行数:65,代码来源:front.py


示例14: GET_comments

    def GET_comments(self, article, comment, context, sort, num_comments,
                     limit, depth):
        """Comment page for a given 'article'."""
        if comment and comment.link_id != article._id:
            return self.abort404()

        sr = Subreddit._byID(article.sr_id, True)

        if sr.name == g.takedown_sr:
            request.environ['REDDIT_TAKEDOWN'] = article._fullname
            return self.abort404()

        if not c.default_sr and c.site._id != sr._id:
            return self.abort404()

        if not can_view_link_comments(article):
            abort(403, 'forbidden')

        #check for 304
        self.check_modified(article, 'comments')

        # if there is a focal comment, communicate down to
        # comment_skeleton.html who that will be
        if comment:
            c.focal_comment = comment._id36

        # check if we just came from the submit page
        infotext = None
        if request.get.get('already_submitted'):
            infotext = strings.already_submitted % article.resubmit_link()

        check_cheating('comments')

        # figure out number to show based on the menu (when num_comments
        # is 'true', the user wants to temporarily override their
        # comments limit pref
        user_num = c.user.pref_num_comments or g.num_comments
        num = g.max_comments if num_comments == 'true' else user_num

        kw = {}
        # allow depth to be reset (I suspect I'll turn the VInt into a
        # validator on my next pass of .compact)
        if depth is not None and 0 < depth < MAX_RECURSION:
            kw['max_depth'] = depth
        elif c.render_style == "compact":
            kw['max_depth'] = 5
        # allow the user's total count preferences to be overwritten
        # (think of .embed as the use case together with depth=1)x
        if limit is not None and 0 < limit < g.max_comments:
            num = limit

        displayPane = PaneStack()

        # if permalink page, add that message first to the content
        if comment:
            displayPane.append(PermalinkMessage(article.make_permalink_slow()))

        # insert reply box only for logged in user
        if c.user_is_loggedin and can_comment_link(article) and not is_api():
            #no comment box for permalinks
            display = False
            if not comment:
                age = c.start_time - article._date
                if age.days < g.REPLY_AGE_LIMIT:
                    display = True
            displayPane.append(UserText(item = article, creating = True,
                                        post_form = 'comment',
                                        display = display,
                                        cloneable = True))

        # finally add the comment listing
        displayPane.append(CommentPane(article, CommentSortMenu.operator(sort),
                                       comment, context, num, **kw))

        loc = None if c.focal_comment or context is not None else 'comments'

        res = LinkInfoPage(link = article, comment = comment,
                           content = displayPane, 
                           subtitle = _("comments"),
                           nav_menus = [CommentSortMenu(default = sort), 
                                        NumCommentsMenu(article.num_comments,
                                                        default=num_comments)],
                           infotext = infotext).render()
        return res
开发者ID:JediWatchman,项目名称:reddit,代码行数:84,代码来源:front.py


示例15: GET_user

    def GET_user(self, num, vuser, sort, time, after, reverse, count, location, **env):
        """user profile pages"""

        # the validator will ensure that vuser is a valid account
        if not vuser:
            return self.abort404()

        # hide spammers profile pages
        if (not c.user_is_loggedin or 
            (c.user._id != vuser._id and not c.user_is_admin)) \
               and vuser._spam:
            return self.abort404()

        check_cheating('user')
        
        content_pane = PaneStack()

        # enable comments displaying with their titles when rendering
        c.profilepage = True
        listing = None

        db_sort = SortMenu.operator(sort)
        db_time = TimeMenu.operator(time)

        # function for extracting the proper thing if query is a relation (see liked)
        prewrap_fn = None

        # default (nonexistent) query to trip an error on if location is unhandles
        query      = None
        
        # build the sort menus for the space above the content
        sortbar = [SortMenu(default = sort), TimeMenu(default = time)]

        # overview page is a merge of comments and links
        if location == 'overview':
            links = Link._query(Link.c.author_id == vuser._id,
                                Link.c._spam == (True, False))
            comments = Comment._query(Comment.c.author_id == vuser._id,
                                      Comment.c._spam == (True, False))
            query = thing.Merge((links, comments), sort = db_sort, data = True)

        elif location == 'comments':
            query = Comment._query(Comment.c.author_id == vuser._id,
                                   Comment.c._spam == (True, False),
                                   sort = db_sort)

        elif location == 'submitted':
            query = Link._query(Link.c.author_id == vuser._id,
                                Link.c._spam == (True, False),
                                sort = db_sort)

        # (dis)liked page: pull votes and extract thing2
        elif ((location == 'liked' or location == 'disliked') and
              votes_visible(vuser)):
            rel = Vote.rel(vuser, Link)
            query = rel._query(rel.c._thing1_id == vuser._id,
                               rel.c._t2_deleted == False)
            query._eager(True, True)
            
            if location == 'liked':
                query._filter(rel.c._name == '1')
            else:
                query._filter(rel.c._name == '-1')
            sortbar = []
            query._sort = desc('_date')
            prewrap_fn = lambda x: x._thing2

        # TODO: this should be handled with '' above once merges work
        elif location == 'hidden' and votes_visible(vuser):
            db_time = None
            query = SaveHide._query(SaveHide.c._thing1_id == vuser._id,
                                    SaveHide.c._name == 'hide',
                                    eager_load = True,
                                    thing_data = True)
            sortbar = []
            query._sort = desc('_date')
            prewrap_fn = lambda x: x._thing2

        # any admin pages live here.
        elif c.user_is_admin:
            db_time = None
            query, prewrap_fn = admin_profile_query(vuser, location, db_sort)

        if query is None:
            return self.abort404()

        if db_time:
            query._filter(db_time)


        builder = QueryBuilder(query, num = num, prewrap_fn = prewrap_fn,
                               after = after, count = count, reverse = reverse,
                               wrap = ListingController.builder_wrapper)
        listing = LinkListing(builder)

        if listing:
            content_pane.append(listing.listing())

        titles = {'':          _("overview for %(user)s on %(site)s"),
                  'comments':  _("comments by %(user)s on %(site)s"),
#.........这里部分代码省略.........
开发者ID:cmak,项目名称:reddit,代码行数:101,代码来源:front.py



注:本文中的r2.lib.utils.check_cheating函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.constant_time_compare函数代码示例发布时间:2022-05-26
下一篇:
Python utils.canonicalize_email函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap