Add an AdminController base class for Admin controllers
Handles stuff that's shared across admin controllers.
This commit is contained in:
parent
83f24de352
commit
925183ed7a
9 changed files with 27 additions and 44 deletions
|
@ -1,8 +1,4 @@
|
||||||
class Admin::DashboardController < ApplicationController
|
class Admin::DashboardController < AdminController
|
||||||
layout "admin"
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
before_filter :authenticate_admin!
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@workers = Resque.workers
|
@workers = Resque.workers
|
||||||
@pending_jobs = Resque.size(:post_receive)
|
@pending_jobs = Resque.size(:post_receive)
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
class Admin::HooksController < ApplicationController
|
class Admin::HooksController < AdminController
|
||||||
layout "admin"
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
before_filter :authenticate_admin!
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@hooks = SystemHook.all
|
@hooks = SystemHook.all
|
||||||
@hook = SystemHook.new
|
@hook = SystemHook.new
|
||||||
|
|
|
@ -1,6 +1,2 @@
|
||||||
class Admin::LogsController < ApplicationController
|
class Admin::LogsController < AdminController
|
||||||
layout "admin"
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
before_filter :authenticate_admin!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
class Admin::ProjectsController < ApplicationController
|
class Admin::ProjectsController < AdminController
|
||||||
layout "admin"
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
before_filter :authenticate_admin!
|
|
||||||
before_filter :admin_project, only: [:edit, :show, :update, :destroy, :team_update]
|
before_filter :admin_project, only: [:edit, :show, :update, :destroy, :team_update]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class Admin::ResqueController < ApplicationController
|
class Admin::ResqueController < AdminController
|
||||||
layout 'admin'
|
|
||||||
def show
|
def show
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,8 +1,4 @@
|
||||||
class Admin::TeamMembersController < ApplicationController
|
class Admin::TeamMembersController < AdminController
|
||||||
layout "admin"
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
before_filter :authenticate_admin!
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@admin_team_member = UsersProject.find(params[:id])
|
@admin_team_member = UsersProject.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
class Admin::UsersController < ApplicationController
|
class Admin::UsersController < AdminController
|
||||||
layout "admin"
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
before_filter :authenticate_admin!
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@admin_users = User.scoped
|
@admin_users = User.scoped
|
||||||
@admin_users = @admin_users.filter(params[:filter])
|
@admin_users = @admin_users.filter(params[:filter])
|
||||||
|
|
11
app/controllers/admin_controller.rb
Normal file
11
app/controllers/admin_controller.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Provides a base class for Admin controllers to subclass
|
||||||
|
#
|
||||||
|
# Automatically sets the layout and ensures an administrator is logged in
|
||||||
|
class AdminController < ApplicationController
|
||||||
|
layout 'admin'
|
||||||
|
before_filter :authenticate_admin!
|
||||||
|
|
||||||
|
def authenticate_admin!
|
||||||
|
return render_404 unless current_user.is_admin?
|
||||||
|
end
|
||||||
|
end
|
|
@ -84,10 +84,6 @@ class ApplicationController < ActionController::Base
|
||||||
abilities << Ability
|
abilities << Ability
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_admin!
|
|
||||||
return render_404 unless current_user.is_admin?
|
|
||||||
end
|
|
||||||
|
|
||||||
def authorize_project!(action)
|
def authorize_project!(action)
|
||||||
return access_denied! unless can?(current_user, action, project)
|
return access_denied! unless can?(current_user, action, project)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue