Esempio n. 1
0
def delete_file(request, project_number):
        project = Project.objects.get(project_number=project_number)
        file = ProjectFile.objects.get(id=request.POST['pk'])
        
        if user_has_write_access(project, request.user):
                project.files.remove(file)
                project.save()
                return HttpResponse( return_json_success() )
        else:
                return HttpResponse( handle_generic_error("Sorry - you don't have permission to delete this file"))
                r
def delete_file(request, project_number):
    project = Project.objects.get(project_number=project_number)
    file = ProjectFile.objects.get(id=request.POST['pk'])

    if user_has_write_access(project, request.user):
        project.files.remove(file)
        project.save()
        return HttpResponse(return_json_success())
    else:
        return HttpResponse(
            handle_generic_error(
                "Sorry - you don't have permission to delete this file"))
        r
Esempio n. 3
0
def delete_deliverable(request, project_number, deliverable_id):

    # Some security - only allow users to view objects they are allowed to via read_acl
    project = get_object_or_404(Project, project_number=project_number)
    check_project_read_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project

    if user_has_write_access(project, request.user):
        deliverable = Deliverable.objects.get(id=deliverable_id)
        project.deliverables.remove(deliverable)
        project.save()
        return HttpResponse(return_json_success())
    else:
        return HttpResponse(handle_generic_error("Sorry - you don't have sufficient access to update the project"))
def delete_deliverable(request, project_number, deliverable_id):

    # Some security - only allow users to view objects they are allowed to via read_acl
    project = get_object_or_404(Project, project_number=project_number)
    check_project_read_acl(
        project, request.user
    )  # Will return Http404 if user isn't allowed to view project

    if user_has_write_access(project, request.user):
        deliverable = Deliverable.objects.get(id=deliverable_id)
        project.deliverables.remove(deliverable)
        project.save()
        return HttpResponse(return_json_success())
    else:
        return HttpResponse(
            handle_generic_error(
                "Sorry - you don't have sufficient access to update the project"
            ))