コード例 #1
0
ファイル: views.py プロジェクト: UmSenhorQualquer/opencsp
def upload_delete(request, filename):
    success = True
    try:
        storage = AVAILABLE_STORAGES.get(request.user)
        success = storage.delete(filename)
    except:
        success = False
    return JFUResponse(request, success)
コード例 #2
0
ファイル: views.py プロジェクト: ir4y/django-jfu
def upload_delete(request, pk):
    success = True
    try:
        instance = Photo.objects.get(pk=pk)
        os.unlink(instance.file.file.name)
        instance.delete()
    except Photo.DoesNotExist:
        success = False

    return JFUResponse(request, success)
コード例 #3
0
def upload_delete(request, pk):
    success = True
    try:
        instance = Image.objects.get(pk=pk)
        os.unlink(instance.image.path)
        instance.delete()
    except Survey.DoesNotExist:
        success = False

    return JFUResponse(request, success)
コード例 #4
0
ファイル: notas.py プロジェクト: rogernina/cliv
def upload_delete(request, pk):
    success = True
    try:
        instance = ArchivosAdjuntos.objects.get(pk=pk)
        os.unlink(instance.file.path)
        instance.delete()
    except ArchivosAdjuntos.DoesNotExist:
        success = False

    return JFUResponse(request, success)
コード例 #5
0
ファイル: views.py プロジェクト: siadyhr/web
def upload_delete(request, pk):
    success = True
    try:
        instance = Image.objects.get(pk=pk)
        instance.image.delete(save=False)
        instance.delete()
    except Image.DoesNotExist:
        success = False

    return JFUResponse(request, success)
コード例 #6
0
def upload_delete( request, pk ):
    # An example implementation.
    success = True
    try:
        instance = YourUploadModel.objects.get( pk = pk )
        os.unlink( instance.file_field.file.name )
        instance.delete()
    except YourUploadModel.DoesNotExist:
        success = False

    return JFUResponse( request, success )
コード例 #7
0
ファイル: views.py プロジェクト: StuJ/rua-1
def upload_delete(request, book_id, file_pk):
    success = True
    try:
        instance = core_models.File.objects.get(pk=file_pk)
        os.unlink('%s/%s/%s' %
                  (settings.BOOK_DIR, book_id, instance.uuid_filename))
        instance.delete()
    except core_models.File.DoesNotExist:
        success = False

    return JFUResponse(request, success)
コード例 #8
0
def upload_delete(request, pk):

    success = True
    try:
        model = Image.objects.get(pk=pk)
        os.unlink(model.image.path)
        os.unlink(model.resized_image.path)
        model.delete()
        AOI.objects.filter(image=pk).delete()
    except Image.DoesNotExist:
        success = False

    return JFUResponse(request, success)
コード例 #9
0
def upload_delete(request, assignment_type, assignment_id, file_pk):
    assignment = logic.get_assignment(assignment_type, assignment_id)
    book = assignment.book
    success = True

    try:
        instance = models.File.objects.get(pk=file_pk)
        os.unlink(
            '%s/%s/%s' % (settings.BOOK_DIR, book.id, instance.uuid_filename)
        )
        instance.delete()
    except models.File.DoesNotExist:
        success = False

    return JFUResponse(request, success)
コード例 #10
0
ファイル: documents.py プロジェクト: cedadev/datamad2
def delete_file(request, pk):
    """
    Delete specified file
    :param request: WSGI Request
    :param pk: Document ID
    :return:
    """
    if request.POST:
        success = True
        try:
            instance = Document.objects.get(pk=pk)
            instance.delete_file()
        except Document.DoesNotExist:
            success = False

        return JFUResponse(request, success)

    document = Document.objects.get(pk=pk)
    document.delete_file()
    return redirect(reverse('grant_detail', kwargs={'pk': document.grant.pk}))
コード例 #11
0
def upload_delete( request, pk ):
	try:
		instance = TaskAttachment.objects.get( pk = pk )
		task = instance.task

		if ACL.canUpdateTask(request.user, task):
			#instance = TaskAttachment.objects.get( pk = pk )
			#task = instance.task
			if task.hasPermissions(request.user):
				os.unlink( instance.task_attachment_file.path )
				instance.delete()
				success = True
			else:
				success = False
		else:
			raise Exception('Permission denied')

	except TaskAttachment.DoesNotExist:
		success = False

	return JFUResponse( request, success )
コード例 #12
0
ファイル: views.py プロジェクト: agepoly/polyclassifiedads
def jfu_delete(request, pk):
    success = True

    key = request.GET.get('key')

    if int(pk) not in request.session['pca_files_%s' % (key, )]:
        raise Http404()

    try:
        instance = AdPhoto.objects.get(pk=pk)

        if not instance.ad:  # Deleted later
            os.unlink(instance.file.path)
            instance.delete()

        file_list = request.session['pca_files_%s' % (key, )]
        file_list.remove(int(pk))
        request.session['pca_files_%s' % (key, )] = file_list

    except AdPhoto.DoesNotExist:
        success = False

    return JFUResponse(request, success)