Skip to content

Commit 7f1fab5

Browse files
authored
Merge pull request #7 from zhangchunlin/master
同步
2 parents fe07a5e + 89702f0 commit 7f1fab5

File tree

5 files changed

+160
-89
lines changed

5 files changed

+160
-89
lines changed

demo/apps/apijson_demo/settings.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ moment = 'apijson_demo.models.Moment'
66
[APIJSON_MODELS]
77
moment = {
88
"user_id_field" : "user_id",
9-
"GET" : { "roles" : ["OWNER"] },
9+
"GET" : { "roles" : ["OWNER","LOGIN"] },
10+
"HEAD" : { "roles" : ["OWNER","LOGIN"] },
1011
"POST" : { "roles" : ["OWNER"] },
1112
"PUT" : { "roles" : ["OWNER"] },
1213
"DELETE" : { "roles" : ["OWNER"] },
1314
}
1415
comment = {
1516
"user_id_field" : "user_id",
16-
"GET" : { "roles" : ["OWNER"] },
17+
"GET" : { "roles" : ["OWNER","LOGIN"] },
18+
"HEAD" : { "roles" : ["OWNER","LOGIN"] },
1719
"POST" : { "roles" : ["OWNER"] },
1820
"PUT" : { "roles" : ["OWNER"] },
1921
"DELETE" : { "roles" : ["OWNER"] },

demo/apps/apijson_demo/templates/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<div id="app">
88
<tabs v-model:value="tab_current" type="card" :animated="false">
99
<tab-pane label="apijson get" name="tab_get"></tab-pane>
10+
<tab-pane label="apijson head" name="tab_head"></tab-pane>
1011
<tab-pane label="apijson post" name="tab_post"></tab-pane>
1112
<tab-pane label="apijson put" name="tab_put"></tab-pane>
1213
<tab-pane label="apijson delete" name="tab_delete"></tab-pane>
@@ -33,6 +34,20 @@
3334
</i-col>
3435
</Row>
3536

37+
<Row v-if="tab_current==='tab_head'">
38+
<i-col span="3"><div align="center">HTTP HEAD URL</div></i-col>
39+
<i-col span="8"><i-input value="/apijson/head" readonly/></i-col>
40+
</Row>
41+
<Row v-if="tab_current==='tab_head'">
42+
<i-col span="3"><div align="center"><strong>apijson head</strong> request examples</div></i-col>
43+
<i-col span="8">
44+
<i-select v-model="request_data">
45+
<i-option v-for="item in request_head" :value="item.value" :key="item.value">{ item.label }</i-option>
46+
</i-select>
47+
</i-col>
48+
</Row>
49+
50+
3651
<Row v-if="tab_current==='tab_post'">
3752
<i-col span="3"><div align="center">POST URL</div></i-col>
3853
<i-col span="8"><i-input value="/apijson/post" readonly/></i-col>
@@ -88,6 +103,7 @@
88103
delimiters: ['{', '}'],
89104
data: {
90105
request_get : {{=request_get_json}},
106+
request_head : {{=request_head_json}},
91107
request_post : {{=request_post_json}},
92108
request_put : {{=request_put_json}},
93109
request_delete : {{=request_delete_json}},
@@ -97,6 +113,7 @@
97113
tab_current : "tab_get",
98114
tab2url : {
99115
"tab_get":"{{=url_for('uliweb_apijson.apijson.views.ApiJson.get')}}",
116+
"tab_head":"{{=url_for('uliweb_apijson.apijson.views.ApiJson.head')}}",
100117
"tab_post":"{{=url_for('uliweb_apijson.apijson.views.ApiJson.post')}}",
101118
"tab_put":"{{=url_for('uliweb_apijson.apijson.views.ApiJson.put')}}",
102119
"tab_delete":"{{=url_for('uliweb_apijson.apijson.views.ApiJson.delete')}}"
@@ -130,6 +147,9 @@
130147
if (n=="tab_get") {
131148
vm.request_data = vm.request_get[0].value
132149
}
150+
else if (n=="tab_head") {
151+
vm.request_data = vm.request_head[0].value
152+
}
133153
else if (n=="tab_post") {
134154
vm.request_data = vm.request_post[0].value
135155
}

demo/apps/apijson_demo/views.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,31 @@ def index():
88
user_info = "login as user '%s(%s)'"%(request.user.username,request.user)
99
else:
1010
user_info = "not login, you can login with username 'admin/usera/userb/userc', and password '123'"
11+
1112
request_get = [
1213
{
13-
"label":"Single record query: no parameter",
14+
"label":"Single record query: self user",
1415
"value":'''{
1516
"user":{
17+
"@role":"OWNER"
1618
}
1719
}''',
1820
},
1921
{
2022
"label":"Single record query: with id as parameter",
2123
"value":'''{
2224
"user":{
23-
"id":1
25+
"id":2,
26+
"@role":"ADMIN"
2427
}
2528
}''',
2629
},
2730
{
2831
"label":"Single record query: @column",
2932
"value":'''{
3033
"user":{
31-
"@column": "id,username,email"
34+
"@column": "id,username,email",
35+
"@role":"OWNER"
3236
}
3337
}''',
3438
},
@@ -40,7 +44,8 @@ def index():
4044
"@page":0,
4145
"user":{
4246
"@column":"id,username,nickname,email",
43-
"@order":"id-"
47+
"@order":"id-",
48+
"@role":"ADMIN"
4449
}
4550
}
4651
}''',
@@ -59,6 +64,17 @@ def index():
5964
},
6065
]
6166

67+
request_head = [
68+
{
69+
"label":"query number of moments for one user",
70+
"value":'''{
71+
"moment": {
72+
"user_id": 1
73+
}
74+
}''',
75+
},
76+
]
77+
6278
request_post = [
6379
{
6480
"label":"Add new moment",
@@ -112,6 +128,7 @@ def index():
112128
return {
113129
"user_info":user_info,
114130
"request_get_json":dumps(request_get),
131+
"request_head_json":dumps(request_head),
115132
"request_post_json":dumps(request_post),
116133
"request_put_json":dumps(request_put),
117134
"request_delete_json":dumps(request_delete),

uliweb_apijson/apijson/settings.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ user = {
1111
"user_id_field" : "id",
1212
"secret_fields" : ["password"],
1313
"GET" : { "roles" : ["ADMIN","OWNER"] },
14+
"HEAD" : { "roles" : ["ADMIN","OWNER"] },
1415
"POST" : { "roles" : ["ADMIN","OWNER"] },
1516
"PUT" : { "roles" : ["ADMIN","OWNER"] },
1617
"DELETE" : { "roles" : ["ADMIN","OWNER"] },

0 commit comments

Comments
 (0)