bugfix
This commit is contained in:
parent
e384efe28e
commit
25a50f79f4
172
xls2ddl/tmpls.py
172
xls2ddl/tmpls.py
@ -1,8 +1,8 @@
|
|||||||
data_browser_tmpl = """
|
data_browser_tmpl = """
|
||||||
{
|
{
|
||||||
"id":"{{tblname}}_tbl",
|
"id":"{{tblname}}_tbl",
|
||||||
"widgettype":"Tabular",
|
"widgettype":"Tabular",
|
||||||
"options":{
|
"options":{
|
||||||
"width":"100%",
|
"width":"100%",
|
||||||
"height":"100%",
|
"height":"100%",
|
||||||
{% if not notitle %}
|
{% if not notitle %}
|
||||||
@ -44,7 +44,7 @@ data_browser_tmpl = """
|
|||||||
{% if get_data_url %}
|
{% if get_data_url %}
|
||||||
"data_url": "{{get_data_url}}",
|
"data_url": "{{get_data_url}}",
|
||||||
{% else %}
|
{% else %}
|
||||||
"data_url":"{%- raw -%}{{entire_url('./get_{%- endraw -%}{{summary[0].name}}{%- raw -%}.dspy')}}",{%- endraw %}
|
"data_url":"{%- raw -%}{{entire_url('./get_{%- endraw -%}{{summary[0].name}}{%- raw -%}.dspy')}}",{%- endraw %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
"data_method":"{{data_method or 'GET'}}",
|
"data_method":"{{data_method or 'GET'}}",
|
||||||
"data_params":{%- raw -%}{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},{%- endraw %}
|
"data_params":{%- raw -%}{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},{%- endraw %}
|
||||||
@ -62,7 +62,7 @@ data_browser_tmpl = """
|
|||||||
"editexclouded":{{json.dumps(editexclouded, indent=4, ensure_ascii=False)}},
|
"editexclouded":{{json.dumps(editexclouded, indent=4, ensure_ascii=False)}},
|
||||||
{% endif %}
|
{% endif %}
|
||||||
"fields":{{fieldliststr}}
|
"fields":{{fieldliststr}}
|
||||||
},
|
},
|
||||||
{% if subtables_condition %}
|
{% if subtables_condition %}
|
||||||
{%- raw -%}{% {%- endraw %}if {{subtables_condition}} {%- raw -%} %}{%- endraw -%}
|
{%- raw -%}{% {%- endraw %}if {{subtables_condition}} {%- raw -%} %}{%- endraw -%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -72,9 +72,9 @@ data_browser_tmpl = """
|
|||||||
{% if subtables_condition %}
|
{% if subtables_condition %}
|
||||||
{%- raw -%}{% endif %}{%- endraw %}
|
{%- raw -%}{% endif %}{%- endraw %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
"page_rows":160,
|
"page_rows":160,
|
||||||
"cache_limit":5
|
"cache_limit":5
|
||||||
}
|
}
|
||||||
{% if bindsstr %}
|
{% if bindsstr %}
|
||||||
,"binds":{{bindsstr}}
|
,"binds":{{bindsstr}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -116,11 +116,11 @@ ns['userorgid'] = userorgid
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
debug(f'get_{{tblname}}.dspy:{ns=}')
|
debug(f'get_{{tblname}}.dspy:{ns=}')
|
||||||
if not ns.get('page'):
|
if not ns.get('page'):
|
||||||
ns['page'] = 1
|
ns['page'] = 1
|
||||||
if not ns.get('sort'):
|
if not ns.get('sort'):
|
||||||
{% if sortby %}
|
{% if sortby %}
|
||||||
{% if type(sortby) == type("") %}
|
{% if type(sortby) == type("") %}
|
||||||
ns['sort'] = '{{sortby}}'
|
ns['sort'] = '{{sortby}}'
|
||||||
{% else %}
|
{% else %}
|
||||||
ns['sort'] = {{json.dumps(sortby)}}
|
ns['sort'] = {{json.dumps(sortby)}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -157,8 +157,8 @@ debug(f'{sql=}')
|
|||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('{{modulename}}')
|
dbname = get_module_dbname('{{modulename}}')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
r = await sor.sqlPaging(sql, ns)
|
r = await sor.sqlPaging(sql, ns)
|
||||||
return r
|
return r
|
||||||
return {
|
return {
|
||||||
"total":0,
|
"total":0,
|
||||||
"rows":[]
|
"rows":[]
|
||||||
@ -210,28 +210,28 @@ ns['{{logined_userorgid}}'] = userorgid
|
|||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('{{modulename}}')
|
dbname = get_module_dbname('{{modulename}}')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
r = await sor.C('{{summary[0].name}}', ns.copy())
|
r = await sor.C('{{summary[0].name}}', ns.copy())
|
||||||
return {
|
return {
|
||||||
"widgettype":"Message",
|
"widgettype":"Message",
|
||||||
"options":{
|
"options":{
|
||||||
"user_data":ns,
|
"user_data":ns,
|
||||||
"cwidth":16,
|
"cwidth":16,
|
||||||
"cheight":9,
|
"cheight":9,
|
||||||
"title":"Add Success",
|
"title":"Add Success",
|
||||||
"timeout":3,
|
"timeout":3,
|
||||||
"message":"ok"
|
"message":"ok"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"widgettype":"Error",
|
"widgettype":"Error",
|
||||||
"options":{
|
"options":{
|
||||||
"title":"Add Error",
|
"title":"Add Error",
|
||||||
"cwidth":16,
|
"cwidth":16,
|
||||||
"cheight":9,
|
"cheight":9,
|
||||||
"timeout":3,
|
"timeout":3,
|
||||||
"message":"failed"
|
"message":"failed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
data_update_tmpl = """
|
data_update_tmpl = """
|
||||||
@ -271,7 +271,7 @@ ns['{{logined_userorgid}}'] = userorgid
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% for f in confidential_fields or [] %}
|
{% for f in confidential_fields or [] %}
|
||||||
if params_kw.get('{{f}}'):
|
if params_kw.get('{{f}}'):
|
||||||
ns['{{f}}'] = password_encode(params_kw.get('{{f}}'))
|
ns['{{f}}'] = password_encode(params_kw.get('{{f}}'))
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
@ -300,33 +300,33 @@ async with db.sqlorContext(dbname) as sor:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
r = await sor.U('{{summary[0].name}}', ns)
|
r = await sor.U('{{summary[0].name}}', ns)
|
||||||
debug('update success');
|
debug('update success');
|
||||||
return {
|
return {
|
||||||
"widgettype":"Message",
|
"widgettype":"Message",
|
||||||
"options":{
|
"options":{
|
||||||
"title":"Update Success",
|
"title":"Update Success",
|
||||||
"cwidth":16,
|
"cwidth":16,
|
||||||
"cheight":9,
|
"cheight":9,
|
||||||
"timeout":3,
|
"timeout":3,
|
||||||
"message":"ok"
|
"message":"ok"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"widgettype":"Error",
|
"widgettype":"Error",
|
||||||
"options":{
|
"options":{
|
||||||
"title":"Update Error",
|
"title":"Update Error",
|
||||||
"cwidth":16,
|
"cwidth":16,
|
||||||
"cheight":9,
|
"cheight":9,
|
||||||
"timeout":3,
|
"timeout":3,
|
||||||
"message":"failed"
|
"message":"failed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
data_delete_tmpl = """
|
data_delete_tmpl = """
|
||||||
ns = {
|
ns = {
|
||||||
'id':params_kw['id'],
|
'id':params_kw['id'],
|
||||||
}
|
}
|
||||||
{% if logined_userid %}
|
{% if logined_userid %}
|
||||||
userid = await get_user()
|
userid = await get_user()
|
||||||
@ -361,29 +361,29 @@ ns['{{logined_userorgid}}'] = userorgid
|
|||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('{{modulename}}')
|
dbname = get_module_dbname('{{modulename}}')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
r = await sor.D('{{summary[0].name}}', ns)
|
r = await sor.D('{{summary[0].name}}', ns)
|
||||||
debug('delete success');
|
debug('delete success');
|
||||||
return {
|
return {
|
||||||
"widgettype":"Message",
|
"widgettype":"Message",
|
||||||
"options":{
|
"options":{
|
||||||
"title":"Delete Success",
|
"title":"Delete Success",
|
||||||
"timeout":3,
|
"timeout":3,
|
||||||
"cwidth":16,
|
"cwidth":16,
|
||||||
"cheight":9,
|
"cheight":9,
|
||||||
"message":"ok"
|
"message":"ok"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug('Delete failed');
|
debug('Delete failed');
|
||||||
return {
|
return {
|
||||||
"widgettype":"Error",
|
"widgettype":"Error",
|
||||||
"options":{
|
"options":{
|
||||||
"title":"Delete Error",
|
"title":"Delete Error",
|
||||||
"timeout":3,
|
"timeout":3,
|
||||||
"cwidth":16,
|
"cwidth":16,
|
||||||
"cheight":9,
|
"cheight":9,
|
||||||
"message":"failed"
|
"message":"failed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -392,39 +392,39 @@ is_checked = params_kw.get('has_{{relation.param_field}}')
|
|||||||
debug(f'{params_kw=}, {is_checked=}')
|
debug(f'{params_kw=}, {is_checked=}')
|
||||||
dbname = get_module_dbname('{{modulename}}')
|
dbname = get_module_dbname('{{modulename}}')
|
||||||
if is_checked == 'true':
|
if is_checked == 'true':
|
||||||
ns = {
|
ns = {
|
||||||
"id":uuid(),
|
"id":uuid(),
|
||||||
"{{relation.param_field}}":params_kw.{{relation.param_field}},
|
"{{relation.param_field}}":params_kw.{{relation.param_field}},
|
||||||
"{{relation.outter_field}}":params_kw.{{relation.outter_field}}
|
"{{relation.outter_field}}":params_kw.{{relation.outter_field}}
|
||||||
}
|
}
|
||||||
db = DBPools();
|
db = DBPools();
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.C('{{tblname}}', ns)
|
await sor.C('{{tblname}}', ns)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"widgettype":"Message",
|
"widgettype":"Message",
|
||||||
"options":{
|
"options":{
|
||||||
"title":"Success",
|
"title":"Success",
|
||||||
"message":"record add success",
|
"message":"record add success",
|
||||||
"timeout":2
|
"timeout":2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
ns = {
|
ns = {
|
||||||
"{{relation.param_field}}":params_kw.{{relation.param_field}},
|
"{{relation.param_field}}":params_kw.{{relation.param_field}},
|
||||||
"{{relation.outter_field}}":params_kw.{{relation.outter_field}}
|
"{{relation.outter_field}}":params_kw.{{relation.outter_field}}
|
||||||
}
|
}
|
||||||
sql = "delete from {{tblname}} where {{relation.param_field}}=" + "${" + "{{relation.param_field}}" + "}$" + " and {{relation.outter_field}}=" + "${" + "{{relation.outter_field}}" + "}$"
|
sql = "delete from {{tblname}} where {{relation.param_field}}=" + "${" + "{{relation.param_field}}" + "}$" + " and {{relation.outter_field}}=" + "${" + "{{relation.outter_field}}" + "}$"
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.sqlExe(sql, ns)
|
await sor.sqlExe(sql, ns)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"widgettype":"Message",
|
"widgettype":"Message",
|
||||||
"options":{
|
"options":{
|
||||||
"title":"Success",
|
"title":"Success",
|
||||||
"message":"delete record success",
|
"message":"delete record success",
|
||||||
"timeout":3
|
"timeout":3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user