コード例 #1
0
ファイル: views.py プロジェクト: harikvpy/pybbm
    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, Forum.objects.all()), pk=kwargs['forum_id'])
            if not perms.may_access_forum(request, self.forum): # hari
                raise PermissionDenied
            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_access_topic(self.request, self.topic): # hari
                raise PermissionDenied
            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)
                    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)
コード例 #2
0
ファイル: views.py プロジェクト: harikvpy/pybbm
 def dispatch(self, request, *args, **kwargs):
     self.forum = self.get_forum(**kwargs)
     if not perms.may_access_forum(self.request, self.forum):
         raise PermissionDenied
     return super(ForumView, self).dispatch(request, *args, **kwargs)