Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
925183ed
Commit
925183ed
authored
Sep 16, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an AdminController base class for Admin controllers
Handles stuff that's shared across admin controllers.
parent
83f24de3
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
27 additions
and
44 deletions
+27
-44
app/controllers/admin/dashboard_controller.rb
app/controllers/admin/dashboard_controller.rb
+1
-5
app/controllers/admin/hooks_controller.rb
app/controllers/admin/hooks_controller.rb
+2
-6
app/controllers/admin/logs_controller.rb
app/controllers/admin/logs_controller.rb
+1
-5
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+3
-6
app/controllers/admin/resque_controller.rb
app/controllers/admin/resque_controller.rb
+2
-3
app/controllers/admin/team_members_controller.rb
app/controllers/admin/team_members_controller.rb
+1
-5
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+6
-10
app/controllers/admin_controller.rb
app/controllers/admin_controller.rb
+11
-0
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+0
-4
No files found.
app/controllers/admin/dashboard_controller.rb
View file @
925183ed
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
)
...
...
app/controllers/admin/hooks_controller.rb
View file @
925183ed
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
...
@@ -15,7 +11,7 @@ class Admin::HooksController < ApplicationController
...
@@ -15,7 +11,7 @@ class Admin::HooksController < ApplicationController
redirect_to
admin_hooks_path
,
notice:
'Hook was successfully created.'
redirect_to
admin_hooks_path
,
notice:
'Hook was successfully created.'
else
else
@hooks
=
SystemHook
.
all
@hooks
=
SystemHook
.
all
render
:index
render
:index
end
end
end
end
...
...
app/controllers/admin/logs_controller.rb
View file @
925183ed
class
Admin::LogsController
<
ApplicationController
class
Admin::LogsController
<
AdminController
layout
"admin"
before_filter
:authenticate_user!
before_filter
:authenticate_admin!
end
end
app/controllers/admin/projects_controller.rb
View file @
925183ed
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
...
@@ -43,7 +40,7 @@ class Admin::ProjectsController < ApplicationController
...
@@ -43,7 +40,7 @@ class Admin::ProjectsController < ApplicationController
def
update
def
update
owner_id
=
params
[
:project
].
delete
(
:owner_id
)
owner_id
=
params
[
:project
].
delete
(
:owner_id
)
if
owner_id
if
owner_id
@admin_project
.
owner
=
User
.
find
(
owner_id
)
@admin_project
.
owner
=
User
.
find
(
owner_id
)
end
end
...
@@ -60,7 +57,7 @@ class Admin::ProjectsController < ApplicationController
...
@@ -60,7 +57,7 @@ class Admin::ProjectsController < ApplicationController
redirect_to
admin_projects_url
,
notice:
'Project was successfully deleted.'
redirect_to
admin_projects_url
,
notice:
'Project was successfully deleted.'
end
end
private
private
def
admin_project
def
admin_project
@admin_project
=
Project
.
find_by_code
(
params
[
:id
])
@admin_project
=
Project
.
find_by_code
(
params
[
:id
])
...
...
app/controllers/admin/resque_controller.rb
View file @
925183ed
class
Admin::ResqueController
<
ApplicationController
class
Admin::ResqueController
<
AdminController
layout
'admin'
def
show
def
show
end
end
end
end
\ No newline at end of file
app/controllers/admin/team_members_controller.rb
View file @
925183ed
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
...
...
app/controllers/admin/users_controller.rb
View file @
925183ed
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
])
...
@@ -24,7 +20,7 @@ class Admin::UsersController < ApplicationController
...
@@ -24,7 +20,7 @@ class Admin::UsersController < ApplicationController
@admin_user
=
User
.
find
(
params
[
:id
])
@admin_user
=
User
.
find
(
params
[
:id
])
UsersProject
.
user_bulk_import
(
UsersProject
.
user_bulk_import
(
@admin_user
,
@admin_user
,
params
[
:project_ids
],
params
[
:project_ids
],
params
[
:project_access
]
params
[
:project_access
]
)
)
...
@@ -41,22 +37,22 @@ class Admin::UsersController < ApplicationController
...
@@ -41,22 +37,22 @@ class Admin::UsersController < ApplicationController
@admin_user
=
User
.
find
(
params
[
:id
])
@admin_user
=
User
.
find
(
params
[
:id
])
end
end
def
block
def
block
@admin_user
=
User
.
find
(
params
[
:id
])
@admin_user
=
User
.
find
(
params
[
:id
])
if
@admin_user
.
block
if
@admin_user
.
block
redirect_to
:back
,
alert:
"Successfully blocked"
redirect_to
:back
,
alert:
"Successfully blocked"
else
else
redirect_to
:back
,
alert:
"Error occured. User was not blocked"
redirect_to
:back
,
alert:
"Error occured. User was not blocked"
end
end
end
end
def
unblock
def
unblock
@admin_user
=
User
.
find
(
params
[
:id
])
@admin_user
=
User
.
find
(
params
[
:id
])
if
@admin_user
.
update_attribute
(
:blocked
,
false
)
if
@admin_user
.
update_attribute
(
:blocked
,
false
)
redirect_to
:back
,
alert:
"Successfully unblocked"
redirect_to
:back
,
alert:
"Successfully unblocked"
else
else
redirect_to
:back
,
alert:
"Error occured. User was not unblocked"
redirect_to
:back
,
alert:
"Error occured. User was not unblocked"
end
end
end
end
...
...
app/controllers/admin_controller.rb
0 → 100644
View file @
925183ed
# 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
app/controllers/application_controller.rb
View file @
925183ed
...
@@ -84,10 +84,6 @@ class ApplicationController < ActionController::Base
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment