Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 56f00c8

Browse files
Merge pull request #30 from zhangchunlin/master
Sync
2 parents c33164d + 257b8e0 commit 56f00c8

File tree

7 files changed

+68
-9
lines changed

7 files changed

+68
-9
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ uliweb-apijson 是 APIJSON 的 Python 版后端实现,基于 uliweb 框架。
1313
APIJSON
1414
</h1>
1515

16-
<p align="center">码云最有价值开源项目<br />后端接口和文档自动化,前端(客户端) 定制返回JSON的数据和结构!</p>
16+
<p align="center">🏆码云最有价值开源项目<br />🚀后端接口和文档自动化,前端(客户端) 定制返回JSON的数据和结构!</p>
1717

1818
<p align="center" >
1919
<a href="https://github.com/TommyLemon/APIJSON/tree/master/MySQL"><img src="https://img.shields.io/badge/MySQL-5.7%2B-brightgreen.svg?style=flat"></a>

‎demo/apps/apijson_demo/views.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def index():
106106
"@column":"id,username,nickname,email",
107107
"@order":"id-",
108108
"@role":"ADMIN",
109-
"@expr":[["username$","&","email$"],"&",["!","nickname$"]],,
109+
"@expr":[["username$","&","email$"],"&",["!","nickname$"]],
110110
"username$":"%b%",
111111
"nickname$":"%Admin%",
112112
"email$":"%local%"

‎setup.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def grep(attrname):
3838
author_email=grep('__email__'),
3939
description='uliweb-apijson',
4040
long_description=desc(),
41+
long_description_content_type="text/markdown",
4142
packages = find_packages(),
4243
include_package_data=True,
4344
zip_safe=False,

‎uliweb_apijson/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.1.1'
1+
__version__ = '0.1.2'
22
__url__ = 'https://github.com/zhangchunlin/uliweb-apijson'
33
__author__ = 'Chunlin Zhang'
44
__email__ = 'zhangchunlin@gmail.com'

‎uliweb_apijson/apijson/README.md‎

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
uliweb-apijson is a subset and slightly different variation of [apijson](https://github.com/TommyLemon/APIJSON/blob/master/Document.md)
44

5+
# Difference with original apijson
6+
7+
| feature | apijson(java) | uliweb-apijson | comment |
8+
| -------- | ------------- | -------------- | ------------------------------------------------------------ |
9+
| @combine | ✔️ | ✖️ | Example: "@combine":"&key0,&key1,\|key2,key3" |
10+
| @expr | ✖️ | ✔️ | Example: "@expr":[["username$","&","email$"],"&",["!","nickname$"]] |
11+
12+
13+
514
# apijson model configuration
615

716
## example
@@ -13,9 +22,16 @@ user = {
1322
"secret_fields" : ["password"],
1423
"GET" : { "roles" : ["ADMIN","OWNER"] },
1524
"HEAD" : { "roles" : ["ADMIN","OWNER"] },
16-
"POST" : { "roles" : ["ADMIN","OWNER"] },
25+
"POST" : { "roles" : ["ADMIN"] },
1726
"PUT" : { "roles" : ["ADMIN","OWNER"] },
18-
"DELETE" : { "roles" : ["ADMIN","OWNER"] },
27+
"DELETE" : { "roles" : ["ADMIN"] },
28+
}
29+
usergroup = {
30+
"GET" : { "roles" : ["ADMIN","LOGIN"] },
31+
"HEAD" : { "roles" : ["ADMIN"] },
32+
"POST" : { "roles" : ["ADMIN"] },
33+
"PUT" : { "roles" : ["ADMIN"] },
34+
"DELETE" : { "roles" : ["ADMIN"] },
1935
}
2036
```
2137

@@ -58,6 +74,48 @@ request types currently support: POST, PUT
5874

5975
request configuration currently support: ADD,DISALLOW,NECESSARY (still not fully support [all the configuration items](https://github.com/TommyLemon/APIJSON/wiki#%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86))
6076

77+
# apijson table configuration
78+
79+
## example
80+
81+
```
82+
[APIJSON_TABLES]
83+
roles = {
84+
"@model_name" : "role",
85+
"editable" : "auto",
86+
"table_fields" : [
87+
{"title":"#","key":"id","width":80,"component":"id"},
88+
{"title":"Name","key":"name","component":"name_link"},
89+
{"title":"Description","key":"description"},
90+
{"title":"Is reserved","key":"reserve","component":"checkbox"},
91+
],
92+
"viewedit_fields" : [
93+
{"title":"#","key":"id","editable":False},
94+
{"title":"Name","key":"name"},
95+
{"title":"Description","key":"description"},
96+
{"title":"Is reserved","key":"reserve","component":"checkbox"},
97+
],
98+
"add_fields" : [
99+
{"title":"Name","key":"name"},
100+
{"title":"Description","key":"description"},
101+
{"title":"Is reserved","key":"reserve","component":"checkbox"},
102+
],
103+
}
104+
```
105+
106+
## document
107+
108+
Provide 2 vue component about table:
109+
110+
| | apijson-table | apijson-viewedit |
111+
| ----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
112+
| uliweb template include | {{include "vue/inc_apijson_table.html"}} | {{include "vue/inc_apijson_viewedit.html"}} |
113+
| example: | ```<apijson-table model_name="permission" :config="tconfig" :custom_tcolumns_render_generator="custom_tcolumns_render_generator" ref="table"></apijson-table>``` | ```<apijson-viewedit model_name="permission" request_tag="{{=request_tag}}" :id="id_" :config="tconfig"></apijson-viewedit>``` |
114+
115+
116+
117+
118+
61119

62120
# Supported API Examples
63121

‎uliweb_apijson/apijson/templates/vue/inc_apijson_viewedit.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"request_tag",
77
"id",
88
"config",
9-
"custom_tcolumns_render_generator",
109
"hook_init",
1110
"hook_ajax_params"
1211
],
@@ -16,6 +15,7 @@
1615
<i-input v-if="item.component=='input'" v-model="item.value" :readonly="!editable(item)"></i-input>
1716
<checkbox v-if="item.component=='checkbox'" v-model="item.value" :disabled="!editable(item)"></checkbox>
1817
<i-input v-if="item.component=='textarea'" v-model="item.value" type="textarea" :autosize="{minRows: 2,maxRows: 5}"></i-input>
18+
{{block custom_viewedit_componet}}{{end custom_viewedit_componet}}
1919
</form-item>
2020
<form-item v-if="config_editable" label="Action">
2121
<i-button type="info" icon="ios-download" size="large" @click="save">Save</i-button>

‎uliweb_apijson/apijson/views.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __begin__(self):
2323
log.error("try to load json but get exception: '%s', request data: %s"%(e,request.data))
2424
return json({"code":400,"msg":"not json data in the request"})
2525

26-
def apply_vars(self):
26+
def _apply_vars(self):
2727
for key in self.request_data:
2828
if key[-1]=="@":
2929
k = self.request_data[key]
@@ -42,12 +42,12 @@ def get(self):
4242
else:
4343
rsp = self._get_one(key)
4444
if rsp: return rsp
45-
self.apply_vars()
45+
self._apply_vars()
4646
except Exception as e:
4747
err = "exception when handling 'apijson get': %s"%(e)
4848
log.error(err)
4949
traceback.print_exc()
50-
return json({"code":400,"msg":err})
50+
return json({"code":400,"msg":"get exception when handling 'apijson get',please check server side log"})
5151
return json(self.rdict)
5252

5353
def _get_one(self,key):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /