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)
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)
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)
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)
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)
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 )
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)
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)
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)
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}))
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 )
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)