Example #1
0
    def clean(self):
        data = super(MovePostsForm, self).clean()

        new_thread_url = data.get('new_thread_url')
        try:
            if not new_thread_url:
                raise Http404()

            resolution = resolve(urlparse(new_thread_url).path)
            if not 'thread_id' in resolution.kwargs:
                raise Http404()

            queryset = Thread.objects.select_related('forum')
            self.new_thread = queryset.get(id=resolution.kwargs['thread_id'])

            add_acl(self.user, self.new_thread.forum)
            add_acl(self.user, self.new_thread)

            allow_see_forum(self.user, self.new_thread.forum)
            allow_browse_forum(self.user, self.new_thread.forum)
            allow_see_thread(self.user, self.new_thread)

        except (Http404, Thread.DoesNotExist):
            message = _("You have to enter valid link to thread.")
            raise forms.ValidationError(message)

        if self.thread == self.new_thread:
            message = _("New thread is same as current one.")
            raise forms.ValidationError(message)

        if self.new_thread.forum.special_role:
            message = _("You can't move posts to special threads.")
            raise forms.ValidationError(message)

        return data
Example #2
0
    def check_post_permissions(self, request, post):
        add_acl(request.user, post.forum)
        add_acl(request.user, post.thread)
        add_acl(request.user, post)

        allow_see_post(request.user, post)
        allow_see_thread(request.user, post.thread)
        allow_see_forum(request.user, post.forum)
Example #3
0
    def check_post_permissions(self, request, post):
        add_acl(request.user, post.forum)
        add_acl(request.user, post.thread)
        add_acl(request.user, post)

        allow_see_post(request.user, post)
        allow_see_thread(request.user, post.thread)
        allow_see_forum(request.user, post.forum)
Example #4
0
    def check_thread_permissions(self, request, thread):
        if thread.forum.special_role:
            raise Http404()

        add_acl(request.user, thread.forum)
        add_acl(request.user, thread)

        allow_see_thread(request.user, thread)
        allow_see_forum(request.user, thread.forum)
Example #5
0
    def check_thread_permissions(self, request, thread):
        if thread.forum.special_role:
            raise Http404()

        add_acl(request.user, thread.forum)
        add_acl(request.user, thread)

        allow_see_thread(request.user, thread)
        allow_see_forum(request.user, thread.forum)
Example #6
0
    def get_thread(self, request, pk, slug=None):
        thread = get_object_or_404(
            Thread.objects.select_related(*BASE_RELATIONS),
            pk=pk,
            category__tree_id=trees_map.get_tree_id_for_root(THREADS_ROOT_NAME),
        )

        allow_see_thread(request.user, thread)
        if slug:
            validate_slug(thread, slug)
        return thread
Example #7
0
    def check_post_permissions(self, request, post):
        if post.forum.special_role:
            raise Http404()

        add_acl(request.user, post.forum)
        add_acl(request.user, post.thread)
        add_acl(request.user, post)

        allow_see_post(request.user, post)
        allow_see_thread(request.user, post.thread)
        allow_see_forum(request.user, post.forum)
Example #8
0
    def check_post_permissions(self, request, post):
        if post.forum.special_role:
            raise Http404()

        add_acl(request.user, post.forum)
        add_acl(request.user, post.thread)
        add_acl(request.user, post)

        allow_see_post(request.user, post)
        allow_see_thread(request.user, post.thread)
        allow_see_forum(request.user, post.forum)
Example #9
0
 def check_thread_permissions(self, request, thread):
     add_acl(request.user, thread)
     allow_see_thread(request.user, thread)
Example #10
0
 def check_thread_permissions(self, request, thread):
     add_acl(request.user, thread)
     allow_see_thread(request.user, thread)