Improve permissions list display, to be sorted.
Better permission names for "admin users" and "admin roles".
This commit is contained in:
@@ -42,10 +42,12 @@ feature -- Process
|
||||
set_title (translation ("Admin Page", Void))
|
||||
b.append ("<ul id=%"content-types%">")
|
||||
fixme ("Check how to make it configurable")
|
||||
if has_permissions (<< "View any">>) then
|
||||
if has_permissions (<< "admin users">>) then
|
||||
b.append ("<li>" + link ("Users", "admin/users", Void))
|
||||
b.append ("<div class=%"description%">View/Edit/Add Users</div>")
|
||||
b.append ("</li>")
|
||||
end
|
||||
if has_permissions (<< "admin roles">>) then
|
||||
b.append ("<li>" + link ("Roles", "admin/roles", Void))
|
||||
b.append ("<div class=%"description%">View/Edit/Add Roles</div>")
|
||||
b.append ("</li>")
|
||||
|
||||
@@ -100,7 +100,7 @@ feature -- HTTP Methods
|
||||
s.append ("</ul>%N")
|
||||
end
|
||||
|
||||
if l_response.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
|
||||
if l_response.has_permission ("admin roles") then
|
||||
s.append (l_response.link ("Add Role", "admin/add/role", Void))
|
||||
end
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ inherit
|
||||
initialize
|
||||
end
|
||||
|
||||
CMS_SHARED_SORTING_UTILITIES
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
@@ -317,7 +319,10 @@ feature -- Form
|
||||
cb: WSF_FORM_CHECKBOX_INPUT
|
||||
ts: WSF_FORM_SUBMIT_INPUT
|
||||
-- tb: WSF_FORM_BUTTON_INPUT
|
||||
lab: WSF_WIDGET_TEXT
|
||||
l_role_permissions: detachable LIST [READABLE_STRING_8]
|
||||
l_module_names: ARRAYED_LIST [READABLE_STRING_8]
|
||||
l_mod_name: READABLE_STRING_8
|
||||
do
|
||||
if attached a_role as l_role then
|
||||
create fs.make
|
||||
@@ -330,20 +335,45 @@ feature -- Form
|
||||
|
||||
a_form.extend_html_text ("<br/>")
|
||||
|
||||
|
||||
create fs.make
|
||||
fs.set_legend ("Permissions")
|
||||
|
||||
if
|
||||
attached api.user_api.role_permissions as l_permissions
|
||||
attached api.user_api.role_permissions as l_permissions_by_module
|
||||
then
|
||||
l_role_permissions := l_role.permissions
|
||||
l_role_permissions.compare_objects
|
||||
across l_permissions as ic loop
|
||||
create cb.make_with_value ("cms_permissions", ic.item)
|
||||
cb.set_checked (l_role_permissions.has (ic.item))
|
||||
cb.set_title (ic.item)
|
||||
fs.extend (cb)
|
||||
|
||||
create l_module_names.make (l_permissions_by_module.count)
|
||||
across
|
||||
l_permissions_by_module as mod_ic
|
||||
loop
|
||||
l_module_names.force (mod_ic.key)
|
||||
end
|
||||
string_sorter.sort (l_module_names)
|
||||
across
|
||||
l_module_names as mod_ic
|
||||
loop
|
||||
l_mod_name := mod_ic.item
|
||||
if
|
||||
attached l_permissions_by_module.item (l_mod_name) as l_permissions and then
|
||||
not l_permissions.is_empty
|
||||
then
|
||||
if l_mod_name.is_whitespace then
|
||||
l_mod_name := "... "
|
||||
end
|
||||
|
||||
create lab.make_with_text ("<strong>" + l_mod_name + " module</strong>")
|
||||
|
||||
fs.extend (lab)
|
||||
string_sorter.sort (l_permissions)
|
||||
across l_permissions as ic loop
|
||||
create cb.make_with_value ("cms_permissions", ic.item)
|
||||
cb.set_checked (across l_role_permissions as rp_ic some rp_ic.item.is_case_insensitive_equal (ic.item) end)
|
||||
cb.set_title (ic.item)
|
||||
fs.extend (cb)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
create ti.make ("new_cms_permissions[]")
|
||||
@@ -475,4 +505,5 @@ feature -- Generation
|
||||
})
|
||||
});
|
||||
]"
|
||||
|
||||
end
|
||||
|
||||
@@ -84,7 +84,7 @@ feature -- HTTP Methods
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
if r.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
|
||||
if r.has_permission ("admin roles") then
|
||||
if req.percent_encoded_path_info.ends_with_general ("/edit") then
|
||||
check valid_url: req.percent_encoded_path_info.starts_with_general ("/admin/role/") end
|
||||
create edit_response.make (req, res, api)
|
||||
@@ -122,7 +122,7 @@ feature -- HTTP Methods
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
if r.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
|
||||
if r.has_permission ("admin roles") then
|
||||
if req.percent_encoded_path_info.ends_with_general ("/edit") then
|
||||
create edit_response.make (req, res, api)
|
||||
edit_response.execute
|
||||
@@ -186,7 +186,7 @@ feature -- Error
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- New User
|
||||
feature {NONE} -- New role
|
||||
|
||||
create_new_role (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
|
||||
@@ -72,7 +72,7 @@ feature -- HTTP Methods
|
||||
-- the setup class.
|
||||
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
|
||||
if l_response.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
|
||||
if l_response.has_permission ("admin users") then
|
||||
user_api := api.user_api
|
||||
|
||||
l_count := user_api.users_count
|
||||
|
||||
@@ -84,7 +84,7 @@ feature -- HTTP Methods
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
if r.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
|
||||
if r.has_permission ("admin users") then
|
||||
if req.percent_encoded_path_info.ends_with_general ("/edit") then
|
||||
check valid_url: req.percent_encoded_path_info.starts_with_general ("/admin/user/") end
|
||||
create edit_response.make (req, res, api)
|
||||
@@ -122,7 +122,7 @@ feature -- HTTP Methods
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
if r.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
|
||||
if r.has_permission ("admin users") then
|
||||
if req.percent_encoded_path_info.ends_with_general ("/edit") then
|
||||
create edit_response.make (req, res, api)
|
||||
edit_response.execute
|
||||
|
||||
Reference in New Issue
Block a user