Skip to content
Prev Previous commit
Next Next commit
fix DISALLOW and NECESSARY get wrongly problem
  • Loading branch information
zhangchunlin committed Apr 30, 2019
commit d1ff139dfa17fe8be449befac4384318530bf21c
12 changes: 6 additions & 6 deletions uliweb_apijson/apijson/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ def _post_one(self,key,tag):
params_role = ADD_role

permission_check_ok = False
POST = model_setting.get("POST")
if POST:
roles = POST.get("roles")
model_POST = model_setting.get("POST")
if model_POST:
roles = model_POST.get("roles")
if params_role:
if not params_role in roles:
return json({"code":400,"msg":"'%s' not accessible by role '%s'"%(modelname,params_role)})
Expand All @@ -409,17 +409,17 @@ def _post_one(self,key,tag):
if not permission_check_ok:
return json({"code":400,"msg":"no permission"})

DISALLOW = POST.get("DISALLOW")
DISALLOW = tag_POST.get("DISALLOW")
if DISALLOW:
for field in DISALLOW:
if field in params:
log.error("request '%s' disallow '%s'"%(tag,field))
return json({"code":400,"msg":"request '%s' disallow '%s'"%(tag,field)})

NECESSARY = POST.get("NECESSARY")
NECESSARY = tag_POST.get("NECESSARY")
if NECESSARY:
for field in NECESSARY:
if field not in params:
if field not in params or params.get(field)==None:
log.error("request '%s' don't have necessary field '%s'"%(tag,field))
return json({"code":400,"msg":"request '%s' don't have necessary field '%s'"%(tag,field)})

Expand Down