コード例 #1
0
def patch_best_answer(request, thread, value):
    try:
        post_id = int(value)
    except (TypeError, ValueError):
        raise PermissionDenied(_("A valid integer is required."))

    allow_mark_best_answer(request.user, thread)

    post = get_object_or_404(thread.post_set, id=post_id)
    post.category = thread.category
    post.thread = thread

    allow_see_post(request.user, post)
    allow_mark_as_best_answer(request.user, post)

    if post.is_best_answer:
        raise PermissionDenied(
            _("This post is already marked as thread's best answer."))

    if thread.has_best_answer:
        allow_change_best_answer(request.user, thread)

    thread.set_best_answer(request.user, post)
    thread.save()

    return {
        'best_answer': thread.best_answer_id,
        'best_answer_is_protected': thread.best_answer_is_protected,
        'best_answer_marked_on': thread.best_answer_marked_on,
        'best_answer_marked_by': thread.best_answer_marked_by_id,
        'best_answer_marked_by_name': thread.best_answer_marked_by_name,
        'best_answer_marked_by_slug': thread.best_answer_marked_by_slug,
    }
コード例 #2
0
ファイル: base.py プロジェクト: jinchaoh/Misago
    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)
コード例 #3
0
ファイル: base.py プロジェクト: David1119/Misago
    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)
コード例 #4
0
ファイル: base.py プロジェクト: vfoss-org/Misago
    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)
コード例 #5
0
ファイル: base.py プロジェクト: Backenkoehler/Misago
    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)
コード例 #6
0
 def check_post_permissions(self, request, post):
     add_acl(request.user, post)
     allow_see_post(request.user, post)
コード例 #7
0
ファイル: base.py プロジェクト: nikescar/Misago
 def check_post_permissions(self, request, post):
     add_acl(request.user, post)
     allow_see_post(request.user, post)