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
Kazuhiko Shiozaki
gitlab-ce
Commits
f37fa968
Commit
f37fa968
authored
Nov 24, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ability to change namespace from project edit page
parent
f9979476
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
27 deletions
+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
No files found.
app/controllers/application_controller.rb
View file @
f37fa968
...
@@ -64,9 +64,8 @@ class ApplicationController < ActionController::Base
...
@@ -64,9 +64,8 @@ class ApplicationController < ActionController::Base
def
project
def
project
id
=
params
[
:project_id
]
||
params
[
:id
]
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
@project
||
render_404
end
end
...
...
app/controllers/groups_controller.rb
View file @
f37fa968
...
@@ -4,6 +4,7 @@ class GroupsController < ApplicationController
...
@@ -4,6 +4,7 @@ class GroupsController < ApplicationController
before_filter
:group
before_filter
:group
before_filter
:projects
before_filter
:projects
before_filter
:add_project_abilities
def
show
def
show
@events
=
Event
.
in_projects
(
project_ids
).
limit
(
20
).
offset
(
params
[
:offset
]
||
0
)
@events
=
Event
.
in_projects
(
project_ids
).
limit
(
20
).
offset
(
params
[
:offset
]
||
0
)
...
...
app/controllers/projects_controller.rb
View file @
f37fa968
...
@@ -34,8 +34,16 @@ class ProjectsController < ProjectResourceController
...
@@ -34,8 +34,16 @@ class ProjectsController < ProjectResourceController
end
end
def
update
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
|
respond_to
do
|
format
|
if
project
.
update_attributes
(
params
[
:project
])
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
.
html
{
redirect_to
edit_project_path
(
project
),
notice:
'Project was successfully updated.'
}
format
.
js
format
.
js
else
else
...
...
app/models/ability.rb
View file @
f37fa968
...
@@ -7,6 +7,7 @@ class Ability
...
@@ -7,6 +7,7 @@ class Ability
when
"Note"
then
note_abilities
(
object
,
subject
)
when
"Note"
then
note_abilities
(
object
,
subject
)
when
"Snippet"
then
snippet_abilities
(
object
,
subject
)
when
"Snippet"
then
snippet_abilities
(
object
,
subject
)
when
"MergeRequest"
then
merge_request_abilities
(
object
,
subject
)
when
"MergeRequest"
then
merge_request_abilities
(
object
,
subject
)
when
"Group"
then
group_abilities
(
object
,
subject
)
else
[]
else
[]
end
end
end
end
...
@@ -61,6 +62,16 @@ class Ability
...
@@ -61,6 +62,16 @@ class Ability
rules
.
flatten
rules
.
flatten
end
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
|
[
:issue
,
:note
,
:snippet
,
:merge_request
].
each
do
|
name
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
define_method
"
#{
name
}
_abilities"
do
|
user
,
subject
|
if
subject
.
author
==
user
if
subject
.
author
==
user
...
...
app/models/project.rb
View file @
f37fa968
...
@@ -84,6 +84,16 @@ class Project < ActiveRecord::Base
...
@@ -84,6 +84,16 @@ class Project < ActiveRecord::Base
where
(
"projects.name LIKE :query OR projects.path LIKE :query"
,
query:
"%
#{
query
}
%"
)
where
(
"projects.name LIKE :query OR projects.path LIKE :query"
,
query:
"%
#{
query
}
%"
)
end
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
)
def
create_by_user
(
params
,
user
)
namespace_id
=
params
.
delete
(
:namespace_id
)
namespace_id
=
params
.
delete
(
:namespace_id
)
namespace_id
||=
user
.
namespace
.
try
(
:id
)
namespace_id
||=
user
.
namespace
.
try
(
:id
)
...
...
app/views/groups/_projects.html.haml
View file @
f37fa968
...
@@ -3,6 +3,11 @@
...
@@ -3,6 +3,11 @@
Projects
Projects
%small
%small
(
#{
projects
.
count
}
)
(
#{
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
%ul
.unstyled
-
projects
.
each
do
|
project
|
-
projects
.
each
do
|
project
|
%li
.wll
%li
.wll
...
...
app/views/projects/_form.html.haml
View file @
f37fa968
...
@@ -9,23 +9,27 @@
...
@@ -9,23 +9,27 @@
Project name is
Project name is
.input
.input
=
f
.
text_field
:name
,
placeholder:
"Example Project"
,
class:
"xxlarge"
=
f
.
text_field
:name
,
placeholder:
"Example Project"
,
class:
"xxlarge"
%fieldset
%fieldset
%legend
Advanced settings:
%legend
Advanced settings:
.c
learfix
.c
ontrol-group
=
f
.
label
:path
do
=
f
.
label
:path
do
Path
Path
.input
.controls
.input-prepend
%strong
=
text_field_tag
:ppath
,
@project
.
path_to_repo
,
class:
"xlarge"
,
disabled:
true
=
text_field_tag
:ppath
,
@project
.
path_to_repo
,
class:
"xlarge"
,
disabled:
true
-
unless
@project
.
new_record?
||
@project
.
heads
.
empty?
.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
.clearfix
=
f
.
label
:default_branch
,
"Default Branch"
=
f
.
label
:default_branch
,
"Default Branch"
.input
=
f
.
select
(
:default_branch
,
@project
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
.input
=
f
.
select
(
:default_branch
,
@project
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
-
unless
@project
.
new_record?
%fieldset
%fieldset
%legend
Features:
%legend
Features:
...
...
app/views/projects/_new_form.html.haml
View file @
f37fa968
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
=
f
.
label
:namespace_id
do
=
f
.
label
:namespace_id
do
%span
.cgray
Namespace
%span
.cgray
Namespace
.input
.input
=
f
.
select
:namespace_id
,
namespaces_options
,
{},
{
class:
'chosen'
}
=
f
.
select
:namespace_id
,
namespaces_options
(
params
[
:namespace_id
]
||
:current_user
)
,
{},
{
class:
'chosen'
}
%hr
%hr
%p
.padded
%p
.padded
All created project are private. You choose who can see project and commit to repository.
All created project are private. You choose who can see project and commit to repository.
app/views/projects/update.js.haml
View file @
f37fa968
-
if
@project
.
valid?
-
if
@project
.
valid?
:plain
:plain
location.href = "
#{
edit_project_path
(
@project
,
notice:
'Project was successfully updated.'
)
}
";
location.href = "
#{
edit_project_path
(
@project
)
}
";
-
else
-
else
:plain
:plain
$('.project_edit_holder').show();
$('.project_edit_holder').show();
...
...
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