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
Tatuya Kamada
gitlab-ce
Commits
c5cbbea8
Commit
c5cbbea8
authored
Jan 25, 2013
by
Andrey Kumanyaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite admin users controller (use 1 variable and find by username)
parent
ef85202f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
24 deletions
+20
-24
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+20
-24
No files found.
app/controllers/admin/users_controller.rb
View file @
c5cbbea8
...
...
@@ -7,25 +7,21 @@ class Admin::UsersController < Admin::ApplicationController
end
def
show
@admin_user
=
User
.
find
(
params
[
:id
])
@projects
=
if
@admin_user
.
authorized_projects
.
empty?
projects
=
if
admin_user
.
authorized_projects
.
empty?
Project
else
Project
.
without_user
(
@
admin_user
)
Project
.
without_user
(
admin_user
)
end
.
all
end
def
team_update
@admin_user
=
User
.
find
(
params
[
:id
])
UsersProject
.
add_users_into_projects
(
params
[
:project_ids
],
[
@
admin_user
.
id
],
[
admin_user
.
id
],
params
[
:project_access
]
)
redirect_to
[
:admin
,
@
admin_user
],
notice:
'Teams were successfully updated.'
redirect_to
[
:admin
,
admin_user
],
notice:
'Teams were successfully updated.'
end
...
...
@@ -34,13 +30,11 @@ class Admin::UsersController < Admin::ApplicationController
end
def
edit
@admin_user
=
User
.
find
(
params
[
:id
])
admin_user
end
def
block
@admin_user
=
User
.
find
(
params
[
:id
])
if
@admin_user
.
block
if
admin_user
.
block
redirect_to
:back
,
alert:
"Successfully blocked"
else
redirect_to
:back
,
alert:
"Error occured. User was not blocked"
...
...
@@ -48,9 +42,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def
unblock
@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"
else
redirect_to
:back
,
alert:
"Error occured. User was not unblocked"
...
...
@@ -82,30 +74,34 @@ class Admin::UsersController < Admin::ApplicationController
params
[
:user
].
delete
(
:password_confirmation
)
end
@admin_user
=
User
.
find
(
params
[
:id
])
@admin_user
.
admin
=
(
admin
&&
admin
.
to_i
>
0
)
admin_user
.
admin
=
(
admin
&&
admin
.
to_i
>
0
)
respond_to
do
|
format
|
if
@
admin_user
.
update_attributes
(
params
[
:user
],
as: :admin
)
format
.
html
{
redirect_to
[
:admin
,
@
admin_user
],
notice:
'User was successfully updated.'
}
if
admin_user
.
update_attributes
(
params
[
:user
],
as: :admin
)
format
.
html
{
redirect_to
[
:admin
,
admin_user
],
notice:
'User was successfully updated.'
}
format
.
json
{
head
:ok
}
else
format
.
html
{
render
action:
"edit"
}
format
.
json
{
render
json:
@
admin_user
.
errors
,
status: :unprocessable_entity
}
format
.
json
{
render
json:
admin_user
.
errors
,
status: :unprocessable_entity
}
end
end
end
def
destroy
@admin_user
=
User
.
find
(
params
[
:id
])
if
@admin_user
.
personal_projects
.
count
>
0
if
admin_user
.
personal_projects
.
count
>
0
redirect_to
admin_users_path
,
alert:
"User is a project owner and can't be removed."
and
return
end
@
admin_user
.
destroy
admin_user
.
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
admin_users_
url
}
format
.
html
{
redirect_to
admin_users_
path
}
format
.
json
{
head
:ok
}
end
end
protected
def
admin_user
@admin_user
||=
User
.
find_by_username
(
params
[
:id
])
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