Content-Length: 393099 | pFad | http://github.com/APIJSON/APIJSON-Python/commit/425d3f89feeaf706de864de4490d47054e45ffab

95 apijson-table: fix apijson-put @role not work problem; demo: make use… · APIJSON/APIJSON-Python@425d3f8 · GitHub
Skip to content

Commit 425d3f8

Browse files
committed
apijson-table: fix apijson-put @ROLE not work problem; demo: make user table editable for admin
1 parent c19ebae commit 425d3f8

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

demo/apps/apijson_demo/settings.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ comment = {
3131
}
3232

3333
[APIJSON_REQUESTS]
34+
user = {
35+
"POST" :{
36+
"ADD":{"@role": "ADMIN"},
37+
"DISALLOW" : ["id"],
38+
"NECESSARY" : ["username","nickname"],
39+
},
40+
"PUT" :{
41+
"ADD":{"@role": "OWNER"},
42+
"NECESSARY" : ["id"],
43+
},
44+
}
3445
moment = {
3546
"POST" :{
3647
"ADD":{"@role": "OWNER"},

demo/apps/tables/settings.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[APIJSON_TABLES]
2+
user = {
3+
"editable" : "auto",
4+
}
25
moment = {
36
"editable" : "auto",
47
"table_fields" : [

uliweb_apijson/apijson/templates/vue/inc_apijson_table.html

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
var thisp = this
5454
return {
5555
l_request_tag: null,
56+
role: "{{=role}}",
5657

5758
loading: false,
5859
modal_view: false,
@@ -176,10 +177,13 @@
176177
"@page":thisp.current_page-1,
177178
"@query":2
178179
}
179-
arr_params[thisp.model_name] = {
180-
"@order":thisp.sort_key+thisp.sort_order,
181-
"@role":"{{=role}}"
180+
var model_params = {
181+
"@order":thisp.sort_key+thisp.sort_order
182182
}
183+
if (thisp.role!="") {
184+
model_params["@role"] = thisp.role
185+
}
186+
arr_params[thisp.model_name] = model_params
183187
var params = {
184188
"[]":arr_params,
185189
"total@":"/[]/total"
@@ -293,10 +297,13 @@
293297
//only save modified fields
294298
for (var k in thisp.viewedit_items) {
295299
var d = thisp.viewedit_items[k]
296-
if (d.key=="id"|| d.value!=row[d.key]) {
297-
record_params[d.key] = d.value
300+
if (d.title=="id"|| d.value!=row[d.title]) {
301+
record_params[d.title] = d.value
298302
}
299303
}
304+
if (thisp.role!="") {
305+
record_params["@role"] = thisp.role
306+
}
300307
params[thisp.l_request_tag] = record_params
301308
params = thisp.ajax_hook("apijson_put","update",params)
302309
$.ajax({

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/APIJSON/APIJSON-Python/commit/425d3f89feeaf706de864de4490d47054e45ffab

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy