当前位置: 首页>>代码示例>>Python>>正文


Python perms.may_post_as_admin函数代码示例

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


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

示例1: get_context_data

    def get_context_data(self, **kwargs):
        ctx = super(TopicView, self).get_context_data(**kwargs)
        if self.request.user.is_authenticated():
            self.request.user.is_moderator = perms.may_moderate_topic(self.request.user, self.topic)
            self.request.user.is_subscribed = self.request.user in self.topic.subscribers.all()
            if perms.may_post_as_admin(self.request.user):
                ctx["form"] = AdminPostForm(
                    initial={"login": getattr(self.request.user, username_field)}, topic=self.topic
                )
            else:
                ctx["form"] = PostForm(topic=self.topic)
            self.mark_read(self.request.user, self.topic)
        elif defaults.PYBB_ENABLE_ANONYMOUS_POST:
            ctx["form"] = PostForm(topic=self.topic)
        else:
            ctx["form"] = None
        if defaults.PYBB_ATTACHMENT_ENABLE:
            aformset = AttachmentFormSet()
            ctx["aformset"] = aformset
        if defaults.PYBB_FREEZE_FIRST_POST:
            ctx["first_post"] = self.topic.head
        else:
            ctx["first_post"] = None
        ctx["topic"] = self.topic

        if (
            self.request.user.is_authenticated()
            and self.topic.poll_type != Topic.POLL_TYPE_NONE
            and pybb_topic_poll_not_voted(self.topic, self.request.user)
        ):
            ctx["poll_form"] = PollForm(self.topic)

        return ctx
开发者ID:uservidya,项目名称:pybbm,代码行数:33,代码来源:views.py

示例2: get_context_data

    def get_context_data(self, **kwargs):
        ctx = super(TopicView, self).get_context_data(**kwargs)

        if self.request.user.is_authenticated():
            self.request.user.is_moderator = perms.may_moderate_topic(self.request.user, self.topic)
            self.request.user.is_subscribed = self.request.user in self.topic.subscribers.all()
            if perms.may_post_as_admin(self.request.user):
                ctx['form'] = self.get_admin_post_form_class()(
                    initial={'login': getattr(self.request.user, username_field)},
                    topic=self.topic)
            else:
                ctx['form'] = self.get_post_form_class()(topic=self.topic)
            self.mark_read(self.request.user, self.topic)
        elif defaults.PYBB_ENABLE_ANONYMOUS_POST:
            ctx['form'] = self.get_post_form_class()(topic=self.topic)
        else:
            ctx['form'] = None
            ctx['next'] = self.get_login_redirect_url()
        if perms.may_attach_files(self.request.user):
            aformset = self.get_attachment_formset_class()()
            ctx['aformset'] = aformset
        if defaults.PYBB_FREEZE_FIRST_POST:
            ctx['first_post'] = self.topic.head
        else:
            ctx['first_post'] = None
        ctx['topic'] = self.topic

        if self.request.user.is_authenticated() and self.topic.poll_type != Topic.POLL_TYPE_NONE and \
           pybb_topic_poll_not_voted(self.topic, self.request.user):
            ctx['poll_form'] = self.get_poll_form_class()(self.topic)

        return ctx
开发者ID:pbiogy,项目名称:pybbm,代码行数:32,代码来源:views.py

示例3: get_context_data

    def get_context_data(self, **kwargs):
        ctx = super(TopicView, self).get_context_data(**kwargs)
        ctx.update(get_intial_home_data(self.request))
        if self.request.user.is_authenticated():
            self.request.user.is_moderator = self.request.user.is_superuser or (self.request.user in self.topic.forum.moderators.all())
            self.request.user.is_subscribed = self.request.user in self.topic.subscribers.all()
            if perms.may_post_as_admin(self.request.user):
                ctx['form'] = AdminPostForm(initial={'login': self.request.user.username}, topic=self.topic)
            else:
                ctx['form'] = PostForm(topic=self.topic)
            self.mark_read(self.request, self.topic)
        elif defaults.PYBB_ENABLE_ANONYMOUS_POST:
            ctx['form'] = PostForm(topic=self.topic)
        else:
            ctx['form'] = None
        if defaults.PYBB_ATTACHMENT_ENABLE:
            aformset = AttachmentFormSet()
            ctx['aformset'] = aformset
        if defaults.PYBB_FREEZE_FIRST_POST:
            ctx['first_post'] = self.topic.head
        else:
            ctx['first_post'] = None
        ctx['topic'] = self.topic

        if self.request.user.is_authenticated() and self.topic.poll_type != Topic.POLL_TYPE_NONE and \
           pybb_topic_poll_not_voted(self.topic, self.request.user):
            ctx['poll_form'] = PollForm(self.topic)

        return ctx
开发者ID:heraldmatias,项目名称:pybbm,代码行数:29,代码来源:views.py

示例4: get_context_data

    def get_context_data(self, **kwargs):
        ctx = super(TopicView, self).get_context_data(**kwargs)

        if self.request.user.is_authenticated():
            self.request.user.is_moderator = perms.may_moderate_topic(self.request.user, self.topic)
            self.request.user.is_subscribed = self.request.user in self.topic.subscribers.all()
            if perms.may_post_as_admin(self.request.user):
                ctx["form"] = self.get_admin_post_form_class()(
                    initial={"login": getattr(self.request.user, username_field)}, topic=self.topic
                )
            else:
                ctx["form"] = self.get_post_form_class()(topic=self.topic)
            self.mark_read(self.request.user, self.topic)
        elif defaults.PYBB_ENABLE_ANONYMOUS_POST:
            ctx["form"] = self.get_post_form_class()(topic=self.topic)
        else:
            ctx["form"] = None
            ctx["next"] = self.get_login_redirect_url()
        if perms.may_attach_files(self.request.user):
            aformset = self.get_attachment_formset_class()()
            ctx["aformset"] = aformset
        if defaults.PYBB_FREEZE_FIRST_POST:
            ctx["first_post"] = self.topic.head
        else:
            ctx["first_post"] = None
        ctx["topic"] = self.topic
        ctx["forum_id"] = self.topic.forum.id

        if perms.may_vote_in_topic(self.request.user, self.topic) and pybb_topic_poll_not_voted(
            self.topic, self.request.user
        ):
            ctx["poll_form"] = self.get_poll_form_class()(self.topic)

        return ctx
开发者ID:davoshack,项目名称:hub_health,代码行数:34,代码来源:views.py

示例5: get_form_kwargs

 def get_form_kwargs(self):
     ip = self.request.META.get("REMOTE_ADDR", "")
     form_kwargs = super(AddPostView, self).get_form_kwargs()
     form_kwargs.update(dict(topic=self.topic, forum=self.forum, user=self.user, ip=ip, initial={}))
     if getattr(self, "quote", None):
         form_kwargs["initial"]["body"] = self.quote
     if perms.may_post_as_admin(self.user):
         form_kwargs["initial"]["login"] = getattr(self.user, username_field)
     form_kwargs["may_create_poll"] = perms.may_create_poll(self.user)
     return form_kwargs
开发者ID:davoshack,项目名称:hub_health,代码行数:10,代码来源:views.py

示例6: get_form_kwargs

 def get_form_kwargs(self):
     ip = self.request.META.get('REMOTE_ADDR', '')
     form_kwargs = super(AddPostView, self).get_form_kwargs()
     form_kwargs.update(dict(topic=self.topic, forum=self.forum, user=self.user,
                        ip=ip, initial={}))
     if getattr(self, 'quote', None):
         form_kwargs['initial']['body'] = self.quote
     if perms.may_post_as_admin(self.user):
         form_kwargs['initial']['login'] = getattr(self.user, username_field)
     form_kwargs['may_create_poll'] = perms.may_create_poll(self.user)
     return form_kwargs
开发者ID:pbiogy,项目名称:pybbm,代码行数:11,代码来源:views.py

示例7: get_form_class

 def get_form_class(self):
     if perms.may_post_as_admin(self.request.user):
         return AdminPostForm
     else:
         return PostForm
开发者ID:pbiogy,项目名称:pybbm,代码行数:5,代码来源:views.py

示例8: get_form_class

 def get_form_class(self):
     if perms.may_post_as_admin(self.request.user):
         return self.get_admin_post_form_class()
     else:
         return self.get_post_form_class()
开发者ID:JTLX,项目名称:pybbm,代码行数:5,代码来源:views.py

示例9: get_form_class

 def get_form_class(self):
     if defaults.PYBB_ENABLE_ADMIN_POST_FORM and \
             perms.may_post_as_admin(self.request.user):
         return self.get_admin_post_form_class()
     else:
         return self.get_post_form_class()
开发者ID:fizista,项目名称:pybbm,代码行数:6,代码来源:views.py

示例10: get_form_class

 def get_form_class(self):
     if perms.may_post_as_admin(self.request.user):
         return defaults_forms.PYBB_ADMIN_POST_FORM
     else:
         return defaults_forms.PYBB_POST_FORM
开发者ID:sromero84,项目名称:pybbm,代码行数:5,代码来源:views.py


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