Commit 9d318db48f4d76b8493aefa80e7b29c2ea3cc1cf

Authored by Andrey Kumanyaev
Committed by Dmitriy Zaporozhets
1 parent 29847168

Added the correct hierarchy of controllers for the administrative part

app/controllers/admin/application_controller.rb 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +# Provides a base class for Admin controllers to subclass
  2 +#
  3 +# Automatically sets the layout and ensures an administrator is logged in
  4 +class Admin::ApplicationController < ApplicationController
  5 + layout 'admin'
  6 + before_filter :authenticate_admin!
  7 +
  8 + def authenticate_admin!
  9 + return render_404 unless current_user.is_admin?
  10 + end
  11 +end
app/controllers/admin/dashboard_controller.rb
1 -class Admin::DashboardController < AdminController 1 +class Admin::DashboardController < Admin::ApplicationController
2 def index 2 def index
3 @projects = Project.order("created_at DESC").limit(10) 3 @projects = Project.order("created_at DESC").limit(10)
4 @users = User.order("created_at DESC").limit(10) 4 @users = User.order("created_at DESC").limit(10)
app/controllers/admin/groups_controller.rb
1 -class Admin::GroupsController < AdminController 1 +class Admin::GroupsController < Admin::ApplicationController
2 before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :project_teams_update] 2 before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :project_teams_update]
3 3
4 def index 4 def index
app/controllers/admin/hooks_controller.rb
1 -class Admin::HooksController < AdminController 1 +class Admin::HooksController < Admin::ApplicationController
2 def index 2 def index
3 @hooks = SystemHook.all 3 @hooks = SystemHook.all
4 @hook = SystemHook.new 4 @hook = SystemHook.new
app/controllers/admin/logs_controller.rb
1 -class Admin::LogsController < AdminController 1 +class Admin::LogsController < Admin::ApplicationController
2 end 2 end
app/controllers/admin/projects_controller.rb
1 -class Admin::ProjectsController < AdminController 1 +class Admin::ProjectsController < Admin::ApplicationController
2 before_filter :project, only: [:edit, :show, :update, :destroy, :team_update] 2 before_filter :project, only: [:edit, :show, :update, :destroy, :team_update]
3 3
4 def index 4 def index
app/controllers/admin/resque_controller.rb
1 -class Admin::ResqueController < AdminController 1 +class Admin::ResqueController < Admin::ApplicationController
2 def show 2 def show
3 end 3 end
4 end 4 end
app/controllers/admin/team_members_controller.rb
1 -class Admin::TeamMembersController < AdminController 1 +class Admin::TeamMembersController < Admin::ApplicationController
2 def edit 2 def edit
3 @admin_team_member = UsersProject.find(params[:id]) 3 @admin_team_member = UsersProject.find(params[:id])
4 end 4 end
app/controllers/admin/teams_controller.rb
1 -class Admin::TeamsController < AdminController 1 +class Admin::TeamsController < Admin::ApplicationController
2 before_filter :user_team, 2 before_filter :user_team,
3 only: [ :edit, :show, :update, :destroy, 3 only: [ :edit, :show, :update, :destroy,
4 :delegate_projects, :relegate_project, 4 :delegate_projects, :relegate_project,
app/controllers/admin/users_controller.rb
1 -class Admin::UsersController < AdminController 1 +class Admin::UsersController < Admin::ApplicationController
2 def index 2 def index
3 @admin_users = User.scoped 3 @admin_users = User.scoped
4 @admin_users = @admin_users.filter(params[:filter]) 4 @admin_users = @admin_users.filter(params[:filter])
app/controllers/admin_controller.rb
@@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
1 -# Provides a base class for Admin controllers to subclass  
2 -#  
3 -# Automatically sets the layout and ensures an administrator is logged in  
4 -class AdminController < ApplicationController  
5 - layout 'admin'  
6 - before_filter :authenticate_admin!  
7 -  
8 - def authenticate_admin!  
9 - return render_404 unless current_user.is_admin?  
10 - end  
11 -end