예제 #1
0
 def test_comment(self, is_author, is_thread_author, is_privileged):
     comment = Comment(user_id="5" if is_author else "6")
     context = _get_context(
         requester_id="5",
         is_requester_privileged=is_privileged,
         thread=Thread(user_id="5" if is_thread_author else "6")
     )
     self.assertEqual(can_delete(comment, context), is_author or is_privileged)
예제 #2
0
 def test_comment(self, is_author, is_thread_author, is_privileged):
     comment = Comment(user_id="5" if is_author else "6")
     context = _get_context(
         requester_id="5",
         is_requester_privileged=is_privileged,
         thread=Thread(user_id="5" if is_thread_author else "6"))
     self.assertEqual(can_delete(comment, context), is_author
                      or is_privileged)
예제 #3
0
파일: api.py 프로젝트: redukyo/edx-platform
def delete_comment(request, comment_id):
    """
    Delete a comment.

    Parameters:

        request: The django request object used for build_absolute_uri and
          determining the requesting user.

        comment_id: The id of the comment to delete

    Raises:

        PermissionDenied: if user does not have permission to delete thread

    """
    cc_comment, context = _get_comment_and_context(request, comment_id)
    if can_delete(cc_comment, context):
        cc_comment.delete()
    else:
        raise PermissionDenied
예제 #4
0
파일: api.py 프로젝트: redukyo/edx-platform
def delete_thread(request, thread_id):
    """
    Delete a thread.

    Parameters:

        request: The django request object used for build_absolute_uri and
          determining the requesting user.

        thread_id: The id for the thread to delete

    Raises:

        PermissionDenied: if user does not have permission to delete thread

    """
    cc_thread, context = _get_thread_and_context(request, thread_id)
    if can_delete(cc_thread, context):
        cc_thread.delete()
    else:
        raise PermissionDenied
예제 #5
0
def delete_comment(request, comment_id):
    """
    Delete a comment.

    Arguments:

        request: The django request object used for build_absolute_uri and
          determining the requesting user.

        comment_id: The id of the comment to delete

    Raises:

        PermissionDenied: if user does not have permission to delete thread

    """
    cc_comment, context = _get_comment_and_context(request, comment_id)
    if can_delete(cc_comment, context):
        cc_comment.delete()
    else:
        raise PermissionDenied
예제 #6
0
def delete_thread(request, thread_id):
    """
    Delete a thread.

    Arguments:

        request: The django request object used for build_absolute_uri and
          determining the requesting user.

        thread_id: The id for the thread to delete

    Raises:

        PermissionDenied: if user does not have permission to delete thread

    """
    cc_thread, context = _get_thread_and_context(request, thread_id)
    if can_delete(cc_thread, context):
        cc_thread.delete()
    else:
        raise PermissionDenied
예제 #7
0
파일: api.py 프로젝트: chauhanhardik/populo
def delete_thread(request, thread_id):
    """
    Delete a thread.

    Arguments:

        request: The django request object used for build_absolute_uri and
          determining the requesting user.

        thread_id: The id for the thread to delete

    Raises:

        PermissionDenied: if user does not have permission to delete thread

    """
    cc_thread, context = _get_thread_and_context(request, thread_id)
    if can_delete(cc_thread, context):
        cc_thread.delete()
        thread_deleted.send(sender=None, user=request.user, post=cc_thread)
    else:
        raise PermissionDenied
예제 #8
0
 def test_thread(self, is_author, is_privileged):
     thread = Thread(user_id="5" if is_author else "6")
     context = _get_context(requester_id="5", is_requester_privileged=is_privileged)
     self.assertEqual(can_delete(thread, context), is_author or is_privileged)
예제 #9
0
 def test_thread(self, is_author, is_privileged):
     thread = Thread(user_id="5" if is_author else "6")
     context = _get_context(requester_id="5",
                            is_requester_privileged=is_privileged)
     self.assertEqual(can_delete(thread, context), is_author
                      or is_privileged)