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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
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
Hide 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
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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();
...
...
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