kintone ENV bugfix
This commit is contained in:
@@ -206,7 +206,7 @@ def analysprocess(excel,kintone):
|
|||||||
# return True
|
# return True
|
||||||
return diff
|
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"}
|
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"
|
url = f"{c.BASE_URL}{config.API_V1_STR}/preview/app/status.json"
|
||||||
data = {"app":app,"enable":True}
|
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))
|
r = httpx.put(url,headers=headers,data=json.dumps(data))
|
||||||
return r.json()
|
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}
|
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
|
||||||
url = f"{c.BASE_URL}/v1/users.json"
|
url = f"{c.BASE_URL}/v1/users.json"
|
||||||
r = httpx.get(url,headers=headers)
|
r = httpx.get(url,headers=headers)
|
||||||
return r.json()
|
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}
|
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
|
||||||
params = {"code":c.KINTONE_USER}
|
params = {"code":c.KINTONE_USER}
|
||||||
url = f"{c.BASE_URL}/v1/user/organizations.json"
|
url = f"{c.BASE_URL}/v1/user/organizations.json"
|
||||||
r = httpx.get(url,headers=headers,params=params)
|
r = httpx.get(url,headers=headers,params=params)
|
||||||
return r.json()
|
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')}
|
upload_files = {'file': open(file,'rb')}
|
||||||
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
|
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
|
||||||
data ={'name':'file','filename':os.path.basename(file)}
|
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)
|
r = httpx.post(url,headers=headers,data=data,files=upload_files)
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
def updateappjscss(app,uploads,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
def updateappjscss(app,uploads,c:config.KINTONE_ENV):
|
||||||
dsjs = []
|
dsjs = []
|
||||||
dscss = []
|
dscss = []
|
||||||
for upload in uploads:
|
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)
|
upload = uploadkintonefiles(fpath,env)
|
||||||
if upload.get('fileKey') != None:
|
if upload.get('fileKey') != None:
|
||||||
jscs.append({ file.filename:upload['fileKey']})
|
jscs.append({ file.filename:upload['fileKey']})
|
||||||
appjscs = updateappjscss(app,jscs)
|
appjscs = updateappjscss(app,jscs,env)
|
||||||
if appjscs.get("revision") != None:
|
if appjscs.get("revision") != None:
|
||||||
deoployappfromkintone(app,appjscs["revision"],env)
|
deoployappfromkintone(app,appjscs["revision"],env)
|
||||||
return appjscs
|
return appjscs
|
||||||
@@ -389,8 +389,8 @@ async def createappfromexcel(files:t.List[UploadFile] = File(...),env = Depends(
|
|||||||
desc = df.iloc[2,2]
|
desc = df.iloc[2,2]
|
||||||
result = {"app":0,"revision":0,"msg":""}
|
result = {"app":0,"revision":0,"msg":""}
|
||||||
fields = getfieldsfromexcel(df)
|
fields = getfieldsfromexcel(df)
|
||||||
users = getkintoneusers()
|
users = getkintoneusers(env)
|
||||||
orgs = getkintoneorgs()
|
orgs = getkintoneorgs(env)
|
||||||
processes = getprocessfromexcel(df,users["users"], orgs["organizationTitles"])
|
processes = getprocessfromexcel(df,users["users"], orgs["organizationTitles"])
|
||||||
app = createkintoneapp(appname,env)
|
app = createkintoneapp(appname,env)
|
||||||
if app.get("app") != None:
|
if app.get("app") != None:
|
||||||
@@ -400,7 +400,7 @@ async def createappfromexcel(files:t.List[UploadFile] = File(...),env = Depends(
|
|||||||
result["revision"] = app["revision"]
|
result["revision"] = app["revision"]
|
||||||
app = addfieldstokintone(result["app"],env,fields)
|
app = addfieldstokintone(result["app"],env,fields)
|
||||||
if len(processes)> 0:
|
if len(processes)> 0:
|
||||||
app = updateprocesstokintone(result["app"],processes)
|
app = updateprocesstokintone(result["app"],processes,env)
|
||||||
if app.get("revision") != None:
|
if app.get("revision") != None:
|
||||||
result["revision"] = app["revision"]
|
result["revision"] = app["revision"]
|
||||||
deoployappfromkintone(result["app"],result["revision"],env)
|
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)
|
settings = analysesettings(excel,kintone)
|
||||||
excel = getfieldsfromexcel(df)
|
excel = getfieldsfromexcel(df)
|
||||||
kintone = getfieldsfromkintone(app,env)
|
kintone = getfieldsfromkintone(app,env)
|
||||||
users = getkintoneusers()
|
users = getkintoneusers(env)
|
||||||
orgs = getkintoneorgs()
|
orgs = getkintoneorgs(env)
|
||||||
exp = getprocessfromexcel(df,users["users"], orgs["organizationTitles"])
|
exp = getprocessfromexcel(df,users["users"], orgs["organizationTitles"])
|
||||||
#exp = getprocessfromexcel(df)
|
#exp = getprocessfromexcel(df)
|
||||||
kinp = getprocessfromkintone(app,env)
|
kinp = getprocessfromkintone(app,env)
|
||||||
@@ -451,7 +451,7 @@ async def updateappfromexcel(app:str,files:t.List[UploadFile] = File(...),env =
|
|||||||
revision = result["revision"]
|
revision = result["revision"]
|
||||||
deploy = True
|
deploy = True
|
||||||
if len(process)>0:
|
if len(process)>0:
|
||||||
result = updateprocesstokintone(app,exp)
|
result = updateprocesstokintone(app,exp,env)
|
||||||
revision = result["revision"]
|
revision = result["revision"]
|
||||||
deploy = True
|
deploy = True
|
||||||
if deploy:
|
if deploy:
|
||||||
@@ -489,7 +489,7 @@ async def updateprocessfromexcel(app:str,env = Depends(getkintoneenv)):
|
|||||||
# result = updateappsettingstokintone(app,settings)
|
# result = updateappsettingstokintone(app,settings)
|
||||||
# revision = result["revision"]
|
# revision = result["revision"]
|
||||||
# deploy = True
|
# deploy = True
|
||||||
result = updateprocesstokintone(app,excel)
|
result = updateprocesstokintone(app,excel,env)
|
||||||
revision = result["revision"]
|
revision = result["revision"]
|
||||||
deploy = True
|
deploy = True
|
||||||
if deploy:
|
if deploy:
|
||||||
@@ -512,7 +512,7 @@ async def createjstokintone(app:str,env = Depends(getkintoneenv)):
|
|||||||
upload = uploadkintonefiles(file,env)
|
upload = uploadkintonefiles(file,env)
|
||||||
if upload.get('fileKey') != None:
|
if upload.get('fileKey') != None:
|
||||||
jscs.append({ app + '.js':upload['fileKey']})
|
jscs.append({ app + '.js':upload['fileKey']})
|
||||||
appjscs = updateappjscss(app,jscs)
|
appjscs = updateappjscss(app,jscs,env)
|
||||||
if appjscs.get("revision") != None:
|
if appjscs.get("revision") != None:
|
||||||
deoployappfromkintone(app,appjscs["revision"],env)
|
deoployappfromkintone(app,appjscs["revision"],env)
|
||||||
return appjscs
|
return appjscs
|
||||||
|
|||||||
Reference in New Issue
Block a user