Skip to content

Sync #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 10, 2019
Prev Previous commit
add functions.get_apijson_table
  • Loading branch information
zhangchunlin committed May 9, 2019
commit f6133f8a97e9158877aaf7057e99b363a208979b
26 changes: 26 additions & 0 deletions uliweb_apijson/apijson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,29 @@ def get_apijson_tables(role="UNKNOWN"):
editable = role in roles
c["editable"] = editable
return apijson_tables

def get_apijson_table(role="UNKNOWN",name=None):
from uliweb import settings

if not name:
return {}
s = settings.APIJSON_TABLES
if s:
apijson_tables = dict(s.iteritems())
else:
return {}

c = apijson_tables.get(name)
if not c:
return {}
editable = c.get("editable",False)
_model_name = c.get("@model_name") or n
if editable=="auto":
editable = False
POST = settings.APIJSON_MODELS.get(_model_name,{}).get("POST")
if POST:
roles = POST["roles"]
if roles:
editable = role in roles
c["editable"] = editable
return c
1 change: 1 addition & 0 deletions uliweb_apijson/apijson/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ user = {

[FUNCTIONS]
get_apijson_tables = "uliweb_apijson.apijson.get_apijson_tables"
get_apijson_table = "uliweb_apijson.apijson.get_apijson_table"