Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
f37fa968
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,发现更多精彩内容 >>
提交
f37fa968
编写于
11月 24, 2012
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ability to change namespace from project edit page
上级
f9979476
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
65 addition
and
27 deletion
+65
-27
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-2
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+1
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+8
-0
app/models/ability.rb
app/models/ability.rb
+11
-0
app/models/project.rb
app/models/project.rb
+10
-0
app/views/groups/_projects.html.haml
app/views/groups/_projects.html.haml
+5
-0
app/views/projects/_form.html.haml
app/views/projects/_form.html.haml
+27
-23
app/views/projects/_new_form.html.haml
app/views/projects/_new_form.html.haml
+1
-1
app/views/projects/update.js.haml
app/views/projects/update.js.haml
+1
-1
未找到文件。
app/controllers/application_controller.rb
浏览文件 @
f37fa968
...
...
@@ -64,9 +64,8 @@ class ApplicationController < ActionController::Base
def
project
id
=
params
[
:project_id
]
||
params
[
:id
]
id
=
id
.
split
(
"/"
)
if
id
.
include?
(
"/"
)
@project
||=
current_user
.
projects
.
find_
by_path
(
id
)
@project
||=
current_user
.
projects
.
find_
with_namespace
(
id
)
@project
||
render_404
end
...
...
app/controllers/groups_controller.rb
浏览文件 @
f37fa968
...
...
@@ -4,6 +4,7 @@ class GroupsController < ApplicationController
before_filter
:group
before_filter
:projects
before_filter
:add_project_abilities
def
show
@events
=
Event
.
in_projects
(
project_ids
).
limit
(
20
).
offset
(
params
[
:offset
]
||
0
)
...
...
app/controllers/projects_controller.rb
浏览文件 @
f37fa968
...
...
@@ -34,8 +34,16 @@ class ProjectsController < ProjectResourceController
end
def
update
namespace_id
=
params
[
:project
].
delete
(
:namespace_id
)
if
namespace_id
namespace
=
Namespace
.
find
(
namespace_id
)
project
.
transfer
(
namespace
)
end
respond_to
do
|
format
|
if
project
.
update_attributes
(
params
[
:project
])
flash
[
:notice
]
=
'Project was successfully updated.'
format
.
html
{
redirect_to
edit_project_path
(
project
),
notice:
'Project was successfully updated.'
}
format
.
js
else
...
...
app/models/ability.rb
浏览文件 @
f37fa968
...
...
@@ -7,6 +7,7 @@ class Ability
when
"Note"
then
note_abilities
(
object
,
subject
)
when
"Snippet"
then
snippet_abilities
(
object
,
subject
)
when
"MergeRequest"
then
merge_request_abilities
(
object
,
subject
)
when
"Group"
then
group_abilities
(
object
,
subject
)
else
[]
end
end
...
...
@@ -61,6 +62,16 @@ class Ability
rules
.
flatten
end
def
group_abilities
user
,
group
rules
=
[]
rules
<<
[
:manage_group
]
if
group
.
owner
==
user
rules
.
flatten
end
[
:issue
,
:note
,
:snippet
,
:merge_request
].
each
do
|
name
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
if
subject
.
author
==
user
...
...
app/models/project.rb
浏览文件 @
f37fa968
...
...
@@ -84,6 +84,16 @@ class Project < ActiveRecord::Base
where
(
"projects.name LIKE :query OR projects.path LIKE :query"
,
query:
"%
#{
query
}
%"
)
end
def
find_with_namespace
(
id
)
if
id
.
include?
(
"/"
)
id
=
id
.
split
(
"/"
)
namespace_id
=
Namespace
.
find_by_path
(
id
.
first
).
id
where
(
namespace_id:
namespace_id
).
find_by_path
(
id
.
last
)
else
find_by_path
(
id
)
end
end
def
create_by_user
(
params
,
user
)
namespace_id
=
params
.
delete
(
:namespace_id
)
namespace_id
||=
user
.
namespace
.
try
(
:id
)
...
...
app/views/groups/_projects.html.haml
浏览文件 @
f37fa968
...
...
@@ -3,6 +3,11 @@
Projects
%small
(
#{
projects
.
count
}
)
-
if
can?
current_user
,
:manage_group
,
@group
%span
.right
=
link_to
new_project_path
(
namespace_id:
@group
.
id
),
class:
"btn very_small info"
do
%i
.icon-plus
New Project
%ul
.unstyled
-
projects
.
each
do
|
project
|
%li
.wll
...
...
app/views/projects/_form.html.haml
浏览文件 @
f37fa968
...
...
@@ -9,41 +9,45 @@
Project name is
.input
=
f
.
text_field
:name
,
placeholder:
"Example Project"
,
class:
"xxlarge"
%fieldset
%legend
Advanced settings:
.c
learfix
.c
ontrol-group
=
f
.
label
:path
do
Path
.input
.input-prepend
%strong
=
text_field_tag
:ppath
,
@project
.
path_to_repo
,
class:
"xlarge"
,
disabled:
true
-
unless
@project
.
new_record?
||
@project
.
heads
.
empty?
.controls
=
text_field_tag
:ppath
,
@project
.
path_to_repo
,
class:
"xlarge"
,
disabled:
true
.control-group
=
f
.
label
:namespace_id
do
%span
Namespace
.controls
=
f
.
select
:namespace_id
,
namespaces_options
(
@project
.
namespace_id
),
{},
{
class:
'chosen'
}
%span
.cred
Be careful. Changing project namespace can have unintended side effects
-
unless
@project
.
heads
.
empty?
.clearfix
=
f
.
label
:default_branch
,
"Default Branch"
.input
=
f
.
select
(
:default_branch
,
@project
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
-
unless
@project
.
new_record?
%fieldset
%legend
Features:
%fieldset
%legend
Features:
.clearfix
=
f
.
label
:issues_enabled
,
"Issues"
.input
=
f
.
check_box
:issues_enabled
.clearfix
=
f
.
label
:issues_enabled
,
"Issues"
.input
=
f
.
check_box
:issues_enabled
.clearfix
=
f
.
label
:merge_requests_enabled
,
"Merge Requests"
.input
=
f
.
check_box
:merge_requests_enabled
.clearfix
=
f
.
label
:merge_requests_enabled
,
"Merge Requests"
.input
=
f
.
check_box
:merge_requests_enabled
.clearfix
=
f
.
label
:wall_enabled
,
"Wall"
.input
=
f
.
check_box
:wall_enabled
.clearfix
=
f
.
label
:wall_enabled
,
"Wall"
.input
=
f
.
check_box
:wall_enabled
.clearfix
=
f
.
label
:wiki_enabled
,
"Wiki"
.input
=
f
.
check_box
:wiki_enabled
.clearfix
=
f
.
label
:wiki_enabled
,
"Wiki"
.input
=
f
.
check_box
:wiki_enabled
%br
...
...
app/views/projects/_new_form.html.haml
浏览文件 @
f37fa968
...
...
@@ -14,7 +14,7 @@
=
f
.
label
:namespace_id
do
%span
.cgray
Namespace
.input
=
f
.
select
:namespace_id
,
namespaces_options
,
{},
{
class:
'chosen'
}
=
f
.
select
:namespace_id
,
namespaces_options
(
params
[
:namespace_id
]
||
:current_user
)
,
{},
{
class:
'chosen'
}
%hr
%p
.padded
All created project are private. You choose who can see project and commit to repository.
app/views/projects/update.js.haml
浏览文件 @
f37fa968
-
if
@project
.
valid?
:plain
location.href = "
#{
edit_project_path
(
@project
,
notice:
'Project was successfully updated.'
)
}
";
location.href = "
#{
edit_project_path
(
@project
)
}
";
-
else
:plain
$('.project_edit_holder').show();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录