コード例 #1
0
ファイル: views.py プロジェクト: ofAlpaca/RecommendSite
def delete_own_comment(request, id):
    comment = get_object_or_404(Comment, id=id)
    if comment.user.id != request.user.id:
        raise Http404
    perform_delete(request, comment)
    pk = comment.object_pk
    return redirect('post_article', pk=pk)
コード例 #2
0
def delete_own_comment(request, comment_id):
    comment = get_object_or_404(Comment, pk=comment_id)
    if comment.user.id != request.user.id:
        raise Http404
    perform_delete(request, comment)
    return HttpResponseRedirect(comment.content_object.get_absolute_url())
    comment.save()
コード例 #3
0
def comments_delete(request, comment_id):
    """Delete comment view."""
    comment = get_object_or_404(django_comments.get_model(),
                                pk=comment_id,
                                site__pk=settings.SITE_ID)
    context = {
        'next': request.GET.get('next'),
        'comment': comment,
        'is_popup': "_popup" in request.REQUEST
    }

    if request.method == 'POST':
        perform_delete(request, comment)
        if context['is_popup']:
            return render_to_response('admin/close_popup.html', context,
                                      RequestContext(request))
        else:
            return next_redirect(request,
                                 fallback=request.GET.get('next')
                                 or 'comments-delete-done',
                                 c=comment.pk)

    else:
        return render_to_response('comments/delete.html', context,
                                  RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: parksandwildlife/sdis
def comments_delete(request, comment_id):
    """Delete comment view."""
    comment = get_object_or_404(django_comments.get_model(),
                                pk=comment_id,
                                site__pk=settings.SITE_ID)
    context = {
        'next': request.GET.get('next'),
        'comment': comment,
        'is_popup': "_popup" in request.REQUEST
        }

    if request.method == 'POST':
        perform_delete(request, comment)
        if context['is_popup']:
            return render_to_response(
                'admin/close_popup.html', context, RequestContext(request))
        else:
            return next_redirect(
                request,
                fallback=request.GET.get('next') or 'comments-delete-done',
                c=comment.pk)

    else:
        return render_to_response(
            'comments/delete.html', context, RequestContext(request))
コード例 #5
0
def delete_resource_comment(request, id):
    comment = get_object_or_404(Comment, id=id)
    if comment.user.id == request.user.id or \
            request.user.is_superuser or \
            comment.content_object.raccess.owners.filter(pk=request.user.pk).exists():
        perform_delete(request, comment)
    else:
        raise HttpResponseForbidden()
    return HttpResponseRedirect(comment.content_object.get_absolute_url())
コード例 #6
0
ファイル: views.py プロジェクト: aramais/phoenixcs
def delete_my_comment(request, comment_id):
	comment = get_object_or_404(comments.get_model(), pk=comment_id)
	if comment.user == request.user:
		if request.method == "POST":
			pass
		else:
			pass
		perform_delete(request, comment)
		return HttpResponse('Delete comment ok')
	else:
		raise Http404
コード例 #7
0
ファイル: views.py プロジェクト: cmwaura/Newspade
def delete_own_comment(request, id):
	'''
	here we will allow users to delete their own comments based on the 
	logic that if they submitted it they should be able to take it delete_own_comment
	this view takes in
	id: the comment id that was submitted by the user now up for review and deletion
	by the user
	'''
	comment = get_object_or_404(Comment, id=id)
	if comment.user.id != request.user.id:
		raise Http404
	perform_delete(request, comment)
	return HttpResponseRedirect(comment.content_object.get_absolute_url())
コード例 #8
0
ファイル: views.py プロジェクト: artjoman/Nitrate
    def post(self, request):
        comments = django_comments.get_model().objects.filter(
            pk__in=request.POST.getlist('comment_id'),
            site__pk=settings.SITE_ID,
            is_removed=False,
            user_id=request.user.id)

        if not comments:
            return JsonResponseBadRequest(
                {'message': 'No incoming comment id exists.'})

        # Flag the comment as deleted instead of actually deleting it.
        for comment in comments:
            perform_delete(request, comment)

        return JsonResponse({})
コード例 #9
0
def remove_photo_comment(request, comment_id, next=None):

	comment = get_object_or_404(django_comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID)

	try:
		photo = comment.content_object
		photoset = photo.photoset
	except AttributeError:
		raise

	if request.user != photoset.owner:
		raise PermissionDenied

	perform_delete(request, comment)

	messages.add_message(request, messages.SUCCESS, "Comment removed.")

	return redirect(photo if not next else next)
コード例 #10
0
def remove_photo_comment(request, comment_id, next=None):

    comment = get_object_or_404(django_comments.get_model(),
                                pk=comment_id,
                                site__pk=settings.SITE_ID)

    try:
        photo = comment.content_object
        photoset = photo.photoset
    except AttributeError:
        raise

    if request.user != photoset.owner:
        raise PermissionDenied

    perform_delete(request, comment)

    messages.add_message(request, messages.SUCCESS, "Comment removed.")

    return redirect(photo if not next else next)
コード例 #11
0
ファイル: views.py プロジェクト: happinesstaker/more-website
def delete(request, comment_id, next=None):
    """
    This is an ajax view to delete a comment
    """
    comment = get_object_or_404(django_comments.get_model(),
                                pk=comment_id,
                                site__pk=settings.SITE_ID)

    if request.is_ajax():
        # comment can only be deleted by the owner or a moderator
        if not (comment.user.id == request.user.id
                or request.user.has_perm('django_comments.can_moderate')):
            raise Http404("User not allowed to delete this comment!")

        # Flag the comment as deleted instead of actually deleting it.
        perform_delete(request, comment)
        return JsonResponse({
            'comment_id': comment_id,
            'is_removed': comment.is_removed
        })

    # Render a form on GET
    else:
        raise Http404()
コード例 #12
0
def delete_own_comment(request, id):
    comment = get_object_or_404(RatedComment, id=id)
    if comment.user.id != request.user.id and not request.user.is_superuser:
        raise http.Http404('Permission denied')
    perform_delete(request, comment)
    return http.HttpResponseRedirect(comment.content_object.get_absolute_url())