Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
dcea5220
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dcea5220
编写于
1月 22, 2013
作者:
A
Andrey Kumanyaev
提交者:
Dmitriy Zaporozhets
1月 24, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove before_filter from controllers
上级
f87b76a8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
33 deletion
+34
-33
app/controllers/admin/teams/members_controller.rb
app/controllers/admin/teams/members_controller.rb
+5
-6
app/controllers/admin/teams/projects_controller.rb
app/controllers/admin/teams/projects_controller.rb
+5
-6
app/controllers/admin/teams_controller.rb
app/controllers/admin/teams_controller.rb
+14
-18
app/controllers/teams/projects_controller.rb
app/controllers/teams/projects_controller.rb
+10
-3
未找到文件。
app/controllers/admin/teams/members_controller.rb
浏览文件 @
dcea5220
class
Admin::Teams::MembersController
<
Admin
::
Teams
::
ApplicationController
class
Admin::Teams::MembersController
<
Admin
::
Teams
::
ApplicationController
before_filter
:team_member
,
only:
[
:edit
,
:destroy
,
:update
]
def
new
def
new
@users
=
User
.
active
@users
=
User
.
active
@users
=
@users
.
not_in_team
(
@team
)
if
@team
.
members
.
any?
@users
=
@users
.
not_in_team
(
@team
)
if
@team
.
members
.
any?
...
@@ -19,11 +17,12 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
...
@@ -19,11 +17,12 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
end
end
def
edit
def
edit
team_member
end
end
def
update
def
update
options
=
{
default_projects_access:
params
[
:default_project_access
],
group_admin:
params
[
:group_admin
]}
options
=
{
default_projects_access:
params
[
:default_project_access
],
group_admin:
params
[
:group_admin
]}
if
@team
.
update_membership
(
@
member
,
options
)
if
@team
.
update_membership
(
team_
member
,
options
)
redirect_to
admin_team_path
(
@team
),
notice:
'Membership was successfully updated.'
redirect_to
admin_team_path
(
@team
),
notice:
'Membership was successfully updated.'
else
else
render
:edit
render
:edit
...
@@ -31,16 +30,16 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
...
@@ -31,16 +30,16 @@ class Admin::Teams::MembersController < Admin::Teams::ApplicationController
end
end
def
destroy
def
destroy
if
@team
.
remove_member
(
@
member
)
if
@team
.
remove_member
(
team_
member
)
redirect_to
admin_team_path
(
@team
),
notice:
"Member was successfully removed from team."
redirect_to
admin_team_path
(
@team
),
notice:
"Member was successfully removed from team."
else
else
redirect_to
admin_team_members
(
@team
),
notice:
"Something wrong."
redirect_to
admin_team_members
(
@team
),
notice:
"Something wrong."
end
end
end
end
pr
ivate
pr
otected
def
team_member
def
team_member
@member
=
@team
.
members
.
find
(
params
[
:id
])
@member
||
=
@team
.
members
.
find
(
params
[
:id
])
end
end
end
end
app/controllers/admin/teams/projects_controller.rb
浏览文件 @
dcea5220
class
Admin::Teams::ProjectsController
<
Admin
::
Teams
::
ApplicationController
class
Admin::Teams::ProjectsController
<
Admin
::
Teams
::
ApplicationController
before_filter
:team_project
,
only:
[
:edit
,
:destroy
,
:update
]
def
new
def
new
@projects
=
Project
.
scoped
@projects
=
Project
.
scoped
@projects
=
@projects
.
without_team
(
@team
)
if
@team
.
projects
.
any?
@projects
=
@projects
.
without_team
(
@team
)
if
@team
.
projects
.
any?
...
@@ -18,10 +16,11 @@ class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController
...
@@ -18,10 +16,11 @@ class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController
end
end
def
edit
def
edit
team_project
end
end
def
update
def
update
if
@team
.
update_project_access
(
@
project
,
params
[
:greatest_project_access
])
if
@team
.
update_project_access
(
team_
project
,
params
[
:greatest_project_access
])
redirect_to
admin_team_path
(
@team
),
notice:
'Membership was successfully updated.'
redirect_to
admin_team_path
(
@team
),
notice:
'Membership was successfully updated.'
else
else
render
:edit
render
:edit
...
@@ -29,14 +28,14 @@ class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController
...
@@ -29,14 +28,14 @@ class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController
end
end
def
destroy
def
destroy
@team
.
resign_from_project
(
@
project
)
@team
.
resign_from_project
(
team_
project
)
redirect_to
admin_team_path
(
@team
),
notice:
'Project was successfully removed.'
redirect_to
admin_team_path
(
@team
),
notice:
'Project was successfully removed.'
end
end
pr
ivate
pr
otected
def
team_project
def
team_project
@project
=
@team
.
projects
.
find_by_path
(
params
[
:id
])
@project
||
=
@team
.
projects
.
find_by_path
(
params
[
:id
])
end
end
end
end
app/controllers/admin/teams_controller.rb
浏览文件 @
dcea5220
class
Admin::TeamsController
<
Admin
::
ApplicationController
class
Admin::TeamsController
<
Admin
::
ApplicationController
before_filter
:user_team
,
only:
[
:edit
,
:show
,
:update
,
:destroy
,
:delegate_projects
,
:relegate_project
,
:add_members
,
:remove_member
]
def
index
def
index
@teams
=
UserTeam
.
order
(
'name ASC'
)
@teams
=
UserTeam
.
order
(
'name ASC'
)
@teams
=
@teams
.
search
(
params
[
:name
])
if
params
[
:name
].
present?
@teams
=
@teams
.
search
(
params
[
:name
])
if
params
[
:name
].
present?
...
@@ -12,11 +7,11 @@ class Admin::TeamsController < Admin::ApplicationController
...
@@ -12,11 +7,11 @@ class Admin::TeamsController < Admin::ApplicationController
def
show
def
show
@projects
=
Project
.
scoped
@projects
=
Project
.
scoped
@projects
=
@projects
.
without_team
(
@team
)
if
@
team
.
projects
.
any?
@projects
=
@projects
.
without_team
(
user_team
)
if
user_
team
.
projects
.
any?
#@projects.reject!(&:empty_repo?)
#@projects.reject!(&:empty_repo?)
@users
=
User
.
active
@users
=
User
.
active
@users
=
@users
.
not_in_team
(
@team
)
if
@
team
.
members
.
any?
@users
=
@users
.
not_in_team
(
user_team
)
if
user_
team
.
members
.
any?
@users
=
UserDecorator
.
decorate
@users
@users
=
UserDecorator
.
decorate
@users
end
end
...
@@ -25,15 +20,16 @@ class Admin::TeamsController < Admin::ApplicationController
...
@@ -25,15 +20,16 @@ class Admin::TeamsController < Admin::ApplicationController
end
end
def
edit
def
edit
user_team
end
end
def
create
def
create
@
team
=
UserTeam
.
new
(
params
[
:user_team
])
user_
team
=
UserTeam
.
new
(
params
[
:user_team
])
@team
.
path
=
@team
.
name
.
dup
.
parameterize
if
@
team
.
name
user_team
.
path
=
user_team
.
name
.
dup
.
parameterize
if
user_
team
.
name
@
team
.
owner
=
current_user
user_
team
.
owner
=
current_user
if
@
team
.
save
if
user_
team
.
save
redirect_to
admin_team_path
(
@
team
),
notice:
'UserTeam was successfully created.'
redirect_to
admin_team_path
(
user_
team
),
notice:
'UserTeam was successfully created.'
else
else
render
action:
"new"
render
action:
"new"
end
end
...
@@ -44,26 +40,26 @@ class Admin::TeamsController < Admin::ApplicationController
...
@@ -44,26 +40,26 @@ class Admin::TeamsController < Admin::ApplicationController
owner_id
=
user_team_params
.
delete
(
:owner_id
)
owner_id
=
user_team_params
.
delete
(
:owner_id
)
if
owner_id
if
owner_id
@
team
.
owner
=
User
.
find
(
owner_id
)
user_
team
.
owner
=
User
.
find
(
owner_id
)
end
end
if
@
team
.
update_attributes
(
user_team_params
)
if
user_
team
.
update_attributes
(
user_team_params
)
redirect_to
admin_team_path
(
@
team
),
notice:
'UserTeam was successfully updated.'
redirect_to
admin_team_path
(
user_
team
),
notice:
'UserTeam was successfully updated.'
else
else
render
action:
"edit"
render
action:
"edit"
end
end
end
end
def
destroy
def
destroy
@
team
.
destroy
user_
team
.
destroy
redirect_to
admin_user_teams_path
,
notice:
'UserTeam was successfully deleted.'
redirect_to
admin_user_teams_path
,
notice:
'UserTeam was successfully deleted.'
end
end
pr
ivate
pr
otected
def
user_team
def
user_team
@team
=
UserTeam
.
find_by_path
(
params
[
:id
])
@team
||
=
UserTeam
.
find_by_path
(
params
[
:id
])
end
end
end
end
app/controllers/teams/projects_controller.rb
浏览文件 @
dcea5220
...
@@ -21,11 +21,11 @@ class Teams::ProjectsController < Teams::ApplicationController
...
@@ -21,11 +21,11 @@ class Teams::ProjectsController < Teams::ApplicationController
end
end
def
edit
def
edit
@user_team
=
user_team
team_project
end
end
def
update
def
update
if
user_team
.
update_project_access
(
project
,
params
[
:greatest_project_access
])
if
user_team
.
update_project_access
(
team_
project
,
params
[
:greatest_project_access
])
redirect_to
admin_team_path
(
user_team
),
notice:
'Membership was successfully updated.'
redirect_to
admin_team_path
(
user_team
),
notice:
'Membership was successfully updated.'
else
else
render
:edit
render
:edit
...
@@ -33,7 +33,14 @@ class Teams::ProjectsController < Teams::ApplicationController
...
@@ -33,7 +33,14 @@ class Teams::ProjectsController < Teams::ApplicationController
end
end
def
destroy
def
destroy
user_team
.
resign_from_project
(
project
)
user_team
.
resign_from_project
(
team_
project
)
redirect_to
admin_team_path
(
user_team
),
notice:
'Project was successfully removed.'
redirect_to
admin_team_path
(
user_team
),
notice:
'Project was successfully removed.'
end
end
private
def
team_project
@project
||=
@team
.
projects
.
find_by_path
(
params
[
:id
])
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录