示例#1
0
                order_content=request.POST.get('order_content'),
            )
        except Exception, ex:
            order.delete()
            logger.error(msg="文件上传失败: {ex}".format(ex=ex))
            return JsonResponse({
                'msg': "文件上传失败: {ex}".format(ex=ex),
                "code": 500
            })

        for files in request.FILES.getlist('order_files[]'):
            try:
                upFile = UploadFiles.objects.create(file_order=upload,
                                                    file_path=files)
                filePath = os.getcwd() + '/upload/' + str(upFile.file_path)
                upFile.file_type = base.getFileType(filePath)
                upFile.save()
            except Exception, ex:
                order.delete()
                upload.delete()
                logger.error(msg="文件上传失败: {ex}".format(ex=ex))
                return JsonResponse({
                    'msg': "文件上传失败: {ex}".format(ex=ex),
                    "code": 500
                })

    return JsonResponse({'msg': "文件上传成功", "code": 200, 'data': [], 'count': 0})


@login_required()
@permission_required('filemanage.can_read_filedownload_audit_order',
示例#2
0
文件: views.py 项目: amoyx/OpsManage
                                                           dest_path=request.POST.get('dest_path'),
                                                           dest_server=json.dumps(serverList),
                                                           chown_user=request.POST.get('chown_user'),
                                                           chown_rwx=request.POST.get('chown_rwx'),
                                                           order_content=request.POST.get('order_content'),
                                                           )
        except Exception, ex:
            order.delete()
            logger.error(msg="文件上传失败: {ex}".format(ex=ex))
            return JsonResponse({'msg':"文件上传失败: {ex}".format(ex=ex),"code":500})
                 
        for files in request.FILES.getlist('order_files[]'): 
            try:
                upFile = UploadFiles.objects.create(file_order=upload,file_path=files)
                filePath = os.getcwd() + '/upload/' + str(upFile.file_path)
                upFile.file_type = base.getFileType(filePath)
                upFile.save()
            except Exception,ex:
                order.delete()
                upload.delete()
                logger.error(msg="文件上传失败: {ex}".format(ex=ex))
                return JsonResponse({'msg':"文件上传失败: {ex}".format(ex=ex),"code":500}) 
         
    return JsonResponse({'msg':"文件上传成功","code":200,'data':[],'count':0})    


@login_required()
@permission_required('filemanage.can_read_filedownload_audit_order',login_url='/noperm/')
def file_download_list(request,page):
    if request.method == "GET":
        if request.user.is_superuser: