Esempio n. 1
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        relations = ['forum']
        thread = self.fetch_thread(request, select_related=relations, **kwargs)
        forum = thread.forum

        self.check_forum_permissions(request, forum)
        self.check_thread_permissions(request, thread)

        self.allow_action(thread)

        posts_qs = self.exclude_invisible_posts(
            thread.post_set, request.user, forum, thread)
        posts_qs = self.filter_posts_queryset(posts_qs)
        final_posts_qs = posts_qs.select_related('poster').order_by('-id')[:15]

        return self.render(request, {
            'forum': forum,
            'thread': thread,

            'posts_count': posts_qs.count(),
            'posts': final_posts_qs.iterator()
        })
Esempio n. 2
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        relations = ['forum']
        thread = self.fetch_thread(request, select_related=relations, **kwargs)
        forum = thread.forum

        self.check_forum_permissions(request, forum)
        self.check_thread_permissions(request, thread)

        self.allow_action(thread)

        posts_qs = self.exclude_invisible_posts(thread.post_set, request.user,
                                                forum, thread)
        posts_qs = self.filter_posts_queryset(posts_qs)
        final_posts_qs = posts_qs.select_related('poster').order_by('-id')[:15]

        return self.render(
            request, {
                'forum': forum,
                'thread': thread,
                'posts_count': posts_qs.count(),
                'posts': final_posts_qs.iterator()
            })
Esempio n. 3
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        if request.method == 'POST':
            with atomic():
                return self.real_dispatch(request, *args, **kwargs)
        else:
            return self.real_dispatch(request, *args, **kwargs)
Esempio n. 4
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        if request.method == 'POST':
            with atomic():
                return self.real_dispatch(request, *args, **kwargs)
        else:
            return self.real_dispatch(request, *args, **kwargs)
Esempio n. 5
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        if not request.method == "POST":
            raise AjaxError(_("Wrong action received."))

        thread = self.get_thread(request, lock=True, **kwargs)

        if not thread.participant or not thread.participant.is_owner:
            raise AjaxError(_("Only thread owner can add or "
                              "remove participants from thread."))

        return self.action(request, thread, kwargs)
Esempio n. 6
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        thread = self.get_thread(request, **kwargs)

        participants_qs = thread.threadparticipant_set
        participants_qs = participants_qs.select_related('user', 'user__rank')

        return self.render(request, {
            'forum': thread.forum,
            'thread': thread,
            'participants': participants_qs.order_by('-is_owner', 'user__slug')
        })
Esempio n. 7
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        if not request.method == "POST":
            raise AjaxError(_("Wrong action received."))

        thread = self.get_thread(request, lock=True, **kwargs)

        if not thread.participant or not thread.participant.is_owner:
            raise AjaxError(
                _("Only thread owner can add or "
                  "remove participants from thread."))

        return self.action(request, thread, kwargs)
Esempio n. 8
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        thread = self.get_thread(request, **kwargs)

        participants_qs = thread.threadparticipant_set
        participants_qs = participants_qs.select_related('user', 'user__rank')

        return self.render(
            request, {
                'forum': thread.forum,
                'thread': thread,
                'participants': participants_qs.order_by(
                    '-is_owner', 'user__slug')
            })
Esempio n. 9
0
    def dispatch(self, request, *args, **kwargs):
        if self.require_post and request.method != "POST":
            return not_allowed(request)

        post = None
        response = None

        if self.is_atomic:
            with atomic():
                post = self.get_post(request, True, **kwargs)
                response = self.real_dispatch(request, post)
        else:
            post = self.get_post(request, **kwargs)
            response = self.real_dispatch(request, post)

        if response:
            return response
        else:
            return self.redirect_to_post(request.user, post)
Esempio n. 10
0
def raise_misago_405(request):
    return errorpages.not_allowed(request)
Esempio n. 11
0
def raise_misago_405(request):
    return errorpages.not_allowed(request)
Esempio n. 12
0
    def dispatch(self, request, *args, **kwargs):
        if not request.is_ajax():
            return not_allowed(request)

        return super(ReportPostView, self).dispatch(request, *args, **kwargs)
Esempio n. 13
0
 def decorator(request, *args, **kwargs):
     if not request.is_ajax():
         return not_allowed(request)
     else:
         return f(request, *args, **kwargs)
Esempio n. 14
0
 def decorator(request, *args, **kwargs):
     if not request.method == 'POST':
         return not_allowed(request)
     else:
         return f(request, *args, **kwargs)