diff --git a/backend/app/api/api_v1/routers/kintone.py b/backend/app/api/api_v1/routers/kintone.py index 06ea410..3e4aef0 100644 --- a/backend/app/api/api_v1/routers/kintone.py +++ b/backend/app/api/api_v1/routers/kintone.py @@ -206,7 +206,7 @@ def analysprocess(excel,kintone): # return True return diff -def updateprocesstokintone(app:str,process:dict,c:config.KINTONE_ENV=Depends(getkintoneenv)): +def updateprocesstokintone(app:str,process:dict,c:config.KINTONE_ENV): headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE,"Content-Type": "application/json"} url = f"{c.BASE_URL}{config.API_V1_STR}/preview/app/status.json" data = {"app":app,"enable":True} @@ -214,20 +214,20 @@ def updateprocesstokintone(app:str,process:dict,c:config.KINTONE_ENV=Depends(get r = httpx.put(url,headers=headers,data=json.dumps(data)) return r.json() -def getkintoneusers(c:config.KINTONE_ENV=Depends(getkintoneenv)): +def getkintoneusers(c:config.KINTONE_ENV): headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE} url = f"{c.BASE_URL}/v1/users.json" r = httpx.get(url,headers=headers) return r.json() -def getkintoneorgs(c:config.KINTONE_ENV=Depends(getkintoneenv)): +def getkintoneorgs(c:config.KINTONE_ENV): headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE} params = {"code":c.KINTONE_USER} url = f"{c.BASE_URL}/v1/user/organizations.json" r = httpx.get(url,headers=headers,params=params) return r.json() -def uploadkintonefiles(file,c:config.KINTONE_ENV=Depends(getkintoneenv)): +def uploadkintonefiles(file,c:config.KINTONE_ENV): upload_files = {'file': open(file,'rb')} headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE} data ={'name':'file','filename':os.path.basename(file)} @@ -235,7 +235,7 @@ def uploadkintonefiles(file,c:config.KINTONE_ENV=Depends(getkintoneenv)): r = httpx.post(url,headers=headers,data=data,files=upload_files) return r.json() -def updateappjscss(app,uploads,c:config.KINTONE_ENV=Depends(getkintoneenv)): +def updateappjscss(app,uploads,c:config.KINTONE_ENV): dsjs = [] dscss = [] for upload in uploads: @@ -331,7 +331,7 @@ async def jscss(app:str,files:t.List[UploadFile] = File(...),env = Depends(getki upload = uploadkintonefiles(fpath,env) if upload.get('fileKey') != None: jscs.append({ file.filename:upload['fileKey']}) - appjscs = updateappjscss(app,jscs) + appjscs = updateappjscss(app,jscs,env) if appjscs.get("revision") != None: deoployappfromkintone(app,appjscs["revision"],env) return appjscs @@ -389,8 +389,8 @@ async def createappfromexcel(files:t.List[UploadFile] = File(...),env = Depends( desc = df.iloc[2,2] result = {"app":0,"revision":0,"msg":""} fields = getfieldsfromexcel(df) - users = getkintoneusers() - orgs = getkintoneorgs() + users = getkintoneusers(env) + orgs = getkintoneorgs(env) processes = getprocessfromexcel(df,users["users"], orgs["organizationTitles"]) app = createkintoneapp(appname,env) if app.get("app") != None: @@ -400,7 +400,7 @@ async def createappfromexcel(files:t.List[UploadFile] = File(...),env = Depends( result["revision"] = app["revision"] app = addfieldstokintone(result["app"],env,fields) if len(processes)> 0: - app = updateprocesstokintone(result["app"],processes) + app = updateprocesstokintone(result["app"],processes,env) if app.get("revision") != None: result["revision"] = app["revision"] deoployappfromkintone(result["app"],result["revision"],env) @@ -424,8 +424,8 @@ async def updateappfromexcel(app:str,files:t.List[UploadFile] = File(...),env = settings = analysesettings(excel,kintone) excel = getfieldsfromexcel(df) kintone = getfieldsfromkintone(app,env) - users = getkintoneusers() - orgs = getkintoneorgs() + users = getkintoneusers(env) + orgs = getkintoneorgs(env) exp = getprocessfromexcel(df,users["users"], orgs["organizationTitles"]) #exp = getprocessfromexcel(df) kinp = getprocessfromkintone(app,env) @@ -451,7 +451,7 @@ async def updateappfromexcel(app:str,files:t.List[UploadFile] = File(...),env = revision = result["revision"] deploy = True if len(process)>0: - result = updateprocesstokintone(app,exp) + result = updateprocesstokintone(app,exp,env) revision = result["revision"] deploy = True if deploy: @@ -489,7 +489,7 @@ async def updateprocessfromexcel(app:str,env = Depends(getkintoneenv)): # result = updateappsettingstokintone(app,settings) # revision = result["revision"] # deploy = True - result = updateprocesstokintone(app,excel) + result = updateprocesstokintone(app,excel,env) revision = result["revision"] deploy = True if deploy: @@ -512,7 +512,7 @@ async def createjstokintone(app:str,env = Depends(getkintoneenv)): upload = uploadkintonefiles(file,env) if upload.get('fileKey') != None: jscs.append({ app + '.js':upload['fileKey']}) - appjscs = updateappjscss(app,jscs) + appjscs = updateappjscss(app,jscs,env) if appjscs.get("revision") != None: deoployappfromkintone(app,appjscs["revision"],env) return appjscs