def renameGroup(request, *args, **kwargs): """ * Common 0 : "SUCCESS", 1 : "파일을 찾을 수 없습니다", 2 : "변경하려는 대상이 존재합니다", 3 : "허용되지 않는 요청입니다", 4 : "오류가 발생하였습니다", 5 : "권한이 없습니다", * Additional dstGroup : New group path. Not valid in error. result : [ (ext, errno, dstPath), (ext, errno dstPath), ... ] """ srcGroup = request.POST.get('srcGroup'); srcExts = request.POST.getlist('srcExts[]'); dst = request.POST.get('dst'); dstGroup = os.path.normpath(srcGroup + os.path.sep + os.pardir + os.path.sep + dst) fileManager = CELLAR_FileManager(request) result = [] code = 0 for ext in srcExts : newPath = "" srcPath = srcGroup + ext dstPath = dstGroup + ext errno = fileManager.rename(srcPath, dstPath) if errno : code = errno else : newPath = dstPath result.append([ext, errno, newPath]) message = { 0 : "SUCCESS", 1 : "파일/경로를 찾을 수 없습니다", 2 : "변경하려는 대상이 존재합니다", 3 : "허용되지 않는 요청입니다", 4 : "오류가 발생하였습니다", 5 : "권한이 없습니다", } response = { "code" : code, "message" : message[code], "dstGroup" : dstGroup, "result" : result } return HttpResponse(json.dumps(response))
def rename(request, *args, **kwargs): """ * Common 0 : "SUCCESS", 1 : "파일/경로를 찾을 수 없습니다", 2 : "변경하려는 대상이 존재합니다", 3 : "허용되지 않는 요청입니다", 4 : "오류가 발생하였습니다", 5 : "권한이 없습니다", * Additional dst : New name. Not valid in error. dstPath : New path. Not valid in error. """ srcPath = request.POST.get('srcPath'); dst = request.POST.get('dst'); dstPath = os.path.normpath(srcPath + os.path.sep + os.pardir + os.path.sep + dst) fileManager = CELLAR_FileManager(request) code = fileManager.rename(srcPath, dstPath) if code == 0 and os.path.isdir(fileManager.getFullPath(dstPath)) : dstPath += "/" message = { 0 : "SUCCESS", 1 : "파일/경로를 찾을 수 없습니다", 2 : "변경하려는 대상이 존재합니다", 3 : "허용되지 않는 요청입니다", 4 : "오류가 발생하였습니다", 5 : "권한이 없습니다", } response = { "code" : code, "message" : message[code], "dst" : dst, "dstPath" : dstPath } return HttpResponse(json.dumps(response))