本文整理汇总了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
示例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
示例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
示例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
示例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
示例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
示例7: get_form_class
def get_form_class(self):
if perms.may_post_as_admin(self.request.user):
return AdminPostForm
else:
return PostForm
示例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()
示例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()
示例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