本文整理汇总了Python中pybb.permissions.perms.filter_forums函数的典型用法代码示例。如果您正苦于以下问题:Python filter_forums函数的具体用法?Python filter_forums怎么用?Python filter_forums使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_forums函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_forum
def get_forum(self, **kwargs):
if 'pk' in kwargs:
forum = get_object_or_404(perms.filter_forums(self.request, Forum.objects.all()), pk=kwargs['pk'])
elif ('slug' and 'category_slug') in kwargs:
forum = get_object_or_404(perms.filter_forums(self.request, Forum.objects.all()), slug=kwargs['slug'], category__slug=kwargs['category_slug'])
else:
raise Http404(_('Forum does not exist'))
return forum
开发者ID:harikvpy,项目名称:pybbm,代码行数:8,代码来源:views.py
示例2: get_context_data
def get_context_data(self, **kwargs):
ctx = super(IndexView, self).get_context_data(**kwargs)
categories = ctx['categories']
for category in categories:
category.forums_accessed = perms.filter_forums(self.request.user, category.forums.filter(parent=None))
ctx['categories'] = categories
return ctx
开发者ID:pbiogy,项目名称:pybbm,代码行数:7,代码来源:views.py
示例3: dispatch
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated():
self.user = request.user
else:
if defaults.PYBB_ENABLE_ANONYMOUS_POST:
self.user, new = User.objects.get_or_create(**{username_field: defaults.PYBB_ANONYMOUS_USERNAME})
else:
from django.contrib.auth.views import redirect_to_login
return redirect_to_login(request.get_full_path())
self.forum = None
self.topic = None
if 'forum_id' in kwargs:
self.forum = get_object_or_404(perms.filter_forums(request.user, Forum.objects.all()), pk=kwargs['forum_id'])
if not perms.may_create_topic(self.user, self.forum):
raise PermissionDenied
elif 'topic_id' in kwargs:
self.topic = get_object_or_404(perms.filter_topics(request.user, Topic.objects.all()), pk=kwargs['topic_id'])
if not perms.may_create_post(self.user, self.topic):
raise PermissionDenied
self.quote = ''
if 'quote_id' in request.GET:
try:
quote_id = int(request.GET.get('quote_id'))
except TypeError:
raise Http404
else:
post = get_object_or_404(Post, pk=quote_id)
self.quote = defaults.PYBB_QUOTE_ENGINES[defaults.PYBB_MARKUP](post.body, getattr(post.user, username_field))
if self.quote and request.is_ajax():
return HttpResponse(self.quote)
return super(AddPostView, self).dispatch(request, *args, **kwargs)
开发者ID:pbiogy,项目名称:pybbm,代码行数:34,代码来源:views.py
示例4: get_context_data
def get_context_data(self, **kwargs):
ctx = super(CategoryView, self).get_context_data(**kwargs)
ctx["category"].forums_accessed = perms.filter_forums(
self.request.user, ctx["category"].forums.filter(parent=None)
)
ctx["categories"] = [ctx["category"]]
return ctx
开发者ID:JTLX,项目名称:pybbm,代码行数:7,代码来源:views.py
示例5: mark_all_as_read
def mark_all_as_read(request):
for forum in perms.filter_forums(request.user, Forum.objects.all()):
forum_mark, new = ForumReadTracker.objects.get_or_create_tracker(forum=forum, user=request.user)
forum_mark.save()
TopicReadTracker.objects.filter(user=request.user).delete()
msg = _('All forums marked as read')
messages.success(request, msg, fail_silently=True)
return redirect(reverse('pybb:index'))
开发者ID:pbiogy,项目名称:pybbm,代码行数:8,代码来源:views.py
示例6: get_context_data
def get_context_data(self, **kwargs):
ctx = super(IndexView, self).get_context_data(**kwargs)
ctx.update(get_intial_home_data(self.request))
categories = ctx['categories']
for category in categories:
category.forums_accessed = perms.filter_forums(self.request.user, category.forums.all())
ctx['categories'] = categories
return ctx
开发者ID:heraldmatias,项目名称:pybbm,代码行数:8,代码来源:views.py
示例7: get_queryset
def get_queryset(self):
self.forum = get_object_or_404(perms.filter_forums(self.request.user, Forum.objects.all()), pk=self.kwargs['pk'])
qs = self.forum.topics.order_by('-sticky', '-updated').select_related()
if not (self.request.user.is_superuser or self.request.user in self.forum.moderators.all()):
if self.request.user.is_authenticated():
qs = qs.filter(Q(user=self.request.user)|Q(on_moderation=False))
else:
qs = qs.filter(on_moderation=False)
return qs
开发者ID:mjahn86,项目名称:ultimate-league-app,代码行数:9,代码来源:views.py
示例8: get_context_data
def get_context_data(self, **kwargs):
ctx = super(ForumView, self).get_context_data(**kwargs)
ctx['forum'] = self.forum
if self.request.user.is_authenticated():
try:
ctx['subscription'] = ForumSubscription.objects.get(
user=self.request.user,
forum=self.forum
)
except ForumSubscription.DoesNotExist:
ctx['subscription'] = None
else:
ctx['subscription'] = None
ctx['forum'].forums_accessed = perms.filter_forums(self.request.user, self.forum.child_forums.all())
return ctx
开发者ID:fizista,项目名称:pybbm,代码行数:15,代码来源:views.py
示例9: dispatch
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated():
self.user = request.user
else:
if defaults.PYBB_ENABLE_ANONYMOUS_POST:
self.user, new = User.objects.get_or_create(**{username_field: defaults.PYBB_ANONYMOUS_USERNAME})
else:
from django.contrib.auth.views import redirect_to_login
return redirect_to_login(request.get_full_path())
self.forum = None
self.topic = None
if "forum_id" in kwargs:
self.forum = get_object_or_404(
perms.filter_forums(request.user, Forum.objects.all()), pk=kwargs["forum_id"]
)
if not perms.may_create_topic(self.user, self.forum):
raise PermissionDenied
elif "topic_id" in kwargs:
self.topic = get_object_or_404(
perms.filter_topics(request.user, Topic.objects.all()), pk=kwargs["topic_id"]
)
if not perms.may_create_post(self.user, self.topic):
raise PermissionDenied
self.quote = ""
if "quote_id" in request.GET:
try:
quote_id = int(request.GET.get("quote_id"))
except TypeError:
raise Http404
else:
post = get_object_or_404(Post, pk=quote_id)
if not perms.may_view_post(request.user, post):
raise PermissionDenied
profile = util.get_pybb_profile(post.user)
self.quote = util._get_markup_quoter(defaults.PYBB_MARKUP)(post.body, profile.get_display_name())
if self.quote and request.is_ajax():
return HttpResponse(self.quote)
return super(AddPostView, self).dispatch(request, *args, **kwargs)
开发者ID:JTLX,项目名称:pybbm,代码行数:42,代码来源:views.py
示例10: dispatch
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated():
self.user = request.user
else:
if defaults.PYBB_ENABLE_ANONYMOUS_POST:
self.user, new = User.objects.get_or_create(username=defaults.PYBB_ANONYMOUS_USERNAME)
else:
from django.contrib.auth.views import redirect_to_login
return redirect_to_login(request.get_full_path())
self.forum = None
self.topic = None
if 'forum_id' in kwargs:
self.forum = get_object_or_404(perms.filter_forums(request.user, Forum.objects.all()), pk=kwargs['forum_id'])
if not perms.may_create_topic(self.user, self.forum):
raise PermissionDenied
elif 'topic_id' in kwargs:
self.topic = get_object_or_404(perms.filter_topics(request.user, Topic.objects.all()), pk=kwargs['topic_id'])
if not perms.may_create_post(self.user, self.topic):
raise PermissionDenied
return super(AddPostView, self).dispatch(request, *args, **kwargs)
开发者ID:mjahn86,项目名称:ultimate-league-app,代码行数:21,代码来源:views.py
注:本文中的pybb.permissions.perms.filter_forums函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论