Add class for Ray's check-box

Fix some typos
Change the default index for auth
Add some hard code in object_auth.rb to handle page_context
A user cannot select himself in authorisation
This commit is contained in:
chris committed 2013-07-31 00:08:15 +08:00
1 parent b1755bdc80
commit d632439f80
10 files changed
+45 -28

No files matched your search

+10 -5
View File
@@ -1,10 +1,5 @@
module AdminHelper
def show_parent_items_link
@parent_items = @parent_item.ancestors.map{ |i| i }
link_to('/' , admin_items_path) + ( @parent_items.map{ |i| link_to(i.name, admin_items_path(:parent_id=>i.id) ) } << @parent_item.name ).join("/").html_safe
end
# Check if the current_user is manager in current module app
def is_manager?
(@module_app.is_manager?(current_or_guest_user) rescue nil) || is_admin?
@@ -34,4 +29,14 @@ module AdminHelper
return false
end
def get_user_module_role(user)
if user.admin?
t(:admin)
elsif @module_app.is_manager?(user)
t(:manager)
elsif @module_app.is_sub_manager?(user)
t(:sub_manager)
end
end
end
+15 -7
View File
@@ -76,9 +76,7 @@ module OrbitBackendHelper
#
# TODO: link for other types
# ===============================================================
def get_value(object, field)
authorization = !@authorization || (@authorization && is_authorized(object))
approvable = !@approvable || (@approvable && is_approvable(object))
def get_value(object, field, authorization, approvable)
res = ''
case field[:type]
when 'associated'
@@ -145,9 +143,11 @@ module OrbitBackendHelper
end)
concat (content_tag :tbody do
(@objects.each do |object|
authorization = !@authorization || (@authorization && is_authorized(object))
approvable = !@approvable || (@approvable && is_approvable(object))
concat (content_tag :tr do
(@fields.each do |field|
concat(content_tag :td, get_value(object, field))
concat(content_tag :td, get_value(object, field, authorization, approvable))
end)
end)
end)
@@ -280,11 +280,11 @@ module OrbitBackendHelper
content_tag :li, link_to(t(quick[:translation] || :approval_), eval("#{quick[:link]}('#{object.id}')"), class: "preview_trigger #{quick[:class]}")
end
when 'authorization'
if authorization
if is_admin? || is_manager?
content_tag :li, link_to(t(quick[:translation] || :authorization_), eval("#{quick[:link]}"), class: "preview_trigger #{quick[:class]}")
end
when 'edit'
if authorization || approvable
if authorization && approvable
content_tag :li, link_to(t(quick[:translation] || :edit), eval("#{quick[:link]}('#{object.id}')"), class: quick[:class])
end
when 'delete'
@@ -319,7 +319,15 @@ module OrbitBackendHelper
end
def is_authorized(object)
at_least_module_manager || object.category.cur_user_is_sub_manager_of("submit_#{@module_app.key}")
autorized = @module_app.authorizable_models.inject(false) do |autorized, klass|
if object.is_a?(klass.constantize)
autorized ||= object.cur_user_is_sub_manager_of("#{klass.underscore}_#{@module_app.key}")
else
autorized ||= object.category.cur_user_is_sub_manager_of("category_#{@module_app.key}")
end
autorized
end
at_least_module_manager || autorized
end
def quick_edit_link(args)