78 lines
2.0 KiB
Plaintext
78 lines
2.0 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
for k,v in list(ns.items()):
|
|
if v == 'NaN' or v == 'null' or v == '' or v is None:
|
|
if k != 'id':
|
|
del ns[k]
|
|
else:
|
|
ns[k] = None if v in ('NaN', 'null') else v
|
|
|
|
|
|
userorgid = await get_userorgid()
|
|
if not userorgid:
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Authorization Error",
|
|
"timeout":3,
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"message":"Please login"
|
|
}
|
|
}
|
|
ns['org_id'] = userorgid
|
|
|
|
|
|
|
|
|
|
db = DBPools()
|
|
dbname = get_module_dbname('pipeline-sdlc')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
|
|
ns1 = {
|
|
|
|
"org_id": userorgid,
|
|
|
|
|
|
"id": params_kw.id
|
|
}
|
|
recs = await sor.R('sd_project_repos', ns1)
|
|
if len(recs) < 1:
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Update Error",
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"timeout":3,
|
|
"message":"Record no exist or with wrong ownership"
|
|
}
|
|
}
|
|
|
|
tblfields = [{"name":"id","title":"主键ID","type":"str","length":32,"nullable":"no"},{"name":"project_id","title":"项目ID","type":"str","length":32,"nullable":"no"},{"name":"repo_name","title":"仓库别名","type":"str","length":100,"nullable":"no"},{"name":"repo_url","title":"Git地址","type":"str","length":500,"nullable":"no"},{"name":"default_branch","title":"默认分支","type":"str","length":100,"nullable":"no","default":"'main'"},{"name":"local_path","title":"本地相对路径","type":"str","length":200},{"name":"org_id","title":"组织ID","type":"str","length":32,"nullable":"no","default":"'0'"},{"name":"created_at","title":"创建时间","type":"timestamp","nullable":"no"}]
|
|
tblfname = [ f['name'] for f in tblfields ]
|
|
other_keys = [ k for k in ns.keys() if k in tblfname and k != 'id' ]
|
|
if len(other_keys) > 0:
|
|
r = await sor.U('sd_project_repos', ns)
|
|
debug('update success');
|
|
return {
|
|
"widgettype":"Message",
|
|
"options":{
|
|
"title":"Update Success",
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"timeout":3,
|
|
"message":"ok"
|
|
}
|
|
}
|
|
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Update Error",
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"timeout":3,
|
|
"message":"failed"
|
|
}
|
|
} |