diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
index 7cb28b96..a0d8d0d9 100644
--- a/app/helpers/admin_helper.rb
+++ b/app/helpers/admin_helper.rb
@@ -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
\ No newline at end of file
diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb
index aa8075c4..a673e5d9 100644
--- a/app/helpers/orbit_backend_helper.rb
+++ b/app/helpers/orbit_backend_helper.rb
@@ -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)
diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb
index f2ef5c04..c57c6c68 100644
--- a/app/models/object_auth.rb
+++ b/app/models/object_auth.rb
@@ -15,8 +15,12 @@ class ObjectAuth < PrototypeAuth
end
def check_user_has_can_access_app
- sub_managing_users = auth_obj.module_app.sub_managing_users rescue []
- module_app = auth_obj.module_app
+ if auth_obj.is_a?(PageContext)
+ module_app = ModuleApp.where(key: 'page_content').first
+ else
+ module_app = auth_obj.module_app
+ end
+ sub_managing_users = module_app.sub_managing_users rescue []
self.auth_users.each do |auth_user|
if !sub_managing_users.include? auth_user && !auth_user.admin?
module_app.assign_sub_manager(auth_user,User.current)
diff --git a/app/views/admin/authorizations/_user.html.erb b/app/views/admin/authorizations/_user.html.erb
index c1c4ddad..2723234e 100644
--- a/app/views/admin/authorizations/_user.html.erb
+++ b/app/views/admin/authorizations/_user.html.erb
@@ -1,8 +1,10 @@
-
+
-
+ <% unless user == current_user || is_admin? %>
+
+ <% end %>
\ No newline at end of file
diff --git a/app/views/admin/authorizations/index.html.erb b/app/views/admin/authorizations/index.html.erb
index 41d6b55d..6e98df12 100644
--- a/app/views/admin/authorizations/index.html.erb
+++ b/app/views/admin/authorizations/index.html.erb
@@ -15,7 +15,7 @@