Fix for NCCU 0430 all functions ok with two submanagers but different behavors

This commit is contained in:
Matthew K. Fu JuYuan authored and Christophe Vilayphiou committed 2012-05-04 15:38:18 +08:00
1 parent 45e21f9569
commit 05ded8de03
14 files changed
+107 -27

No files matched your search

@@ -2,7 +2,7 @@ class Admin::DashboardsController < ApplicationController
layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
# before_filter :is_admin?
def index
end
+2 -1
View File
@@ -5,7 +5,8 @@ class Admin::DesignsController < ApplicationController
layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :is_admin?
before_filter :for_admin_only
def upload_package
if !params[:design].nil?
+51 -1
View File
@@ -39,9 +39,59 @@ class ApplicationController < ActionController::Base
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
end
def auth_failed_in_backend
redirect_to admin_dashboards_url
end
# Check if the current_user is admin
def is_admin?
redirect_to root_url unless current_user.admin?
auth_failed_in_backend unless current_user.admin?
end
def is_manager?
@module_app.managing_users.include?(current_user) || is_admin?
end
def for_admin_only
if is_admin?
true
else
flash[:notice] = "Access Denied for you are not Admin"
auth_failed_in_backend
end
end
def for_app_manager
if is_manager?
true
else
flash[:notice] = "Access Denied for you are not Manager for this app"
auth_failed_in_backend
end
end
def for_app_sub_manager
if (@module_app.sub_managing_users.include?(current_user) || is_manager?)
true
else
flash[:notice] = "Access Denied for you are not SubManager for this app"
auth_failed_in_backend
end
end
def for_app_user
if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager )
true
else
flash[:notice] = "Access Denied for you are not User for this app"
auth_failed_in_backend
end
end
def check_object_premission(obj,title)
flash[:notice] = "Access Denied for you don't have permission for this object"
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? )
end
# Render the page
+3 -3
View File
@@ -25,9 +25,9 @@ module OrbitBackendHelper
content_tag :thead do
content_tag :tr, :class => "sort-header" do
concat (content_tag :th, :class => "span1 strong" do
concat check_box_tag :check_all
concat link_to content_tag(:i, nil, :class => "icon-trash"), '#', :class => "list-remove"
end) if delete_all
concat check_box_tag :check_all
concat link_to content_tag(:i, nil, :class => "icon-trash"), '#', :class => "list-remove"
end) if delete_all && is_manager?
titles.each do |title|
concat render_title(title[0], title[1], title[2], title[3])
end
@@ -1,3 +1,5 @@
<%= flash_messages %>
<div id="isotope">
<div class="item element">
<h3><i class="icons-content"></i><a href=""><%= t(:content) %></a></h3>
+4
View File
@@ -1,6 +1,10 @@
<%#= content_tag :li, :class => active_for_controllers('purchases') do -%>
<%#= link_to content_tag(:i, nil, :class => 'icons-purchase') + t('admin.purchase'), admin_purchases_path %>
<%# end -%>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "/static/kernel.js" %>
<% end %>
<%= flash_messages %>
<%= content_tag :li, :class => active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys','module_apps', 'approvals') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %>