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
Boxiang Sun
gitlab-ce
Commits
e292d7c1
Commit
e292d7c1
authored
Mar 25, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make transfer action in project controller
parent
ff35b37f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
26 deletions
+11
-26
app/contexts/projects/update_context.rb
app/contexts/projects/update_context.rb
+1
-17
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+4
-4
app/models/project.rb
app/models/project.rb
+0
-2
app/views/projects/_form.html.haml
app/views/projects/_form.html.haml
+2
-1
app/views/projects/update_failed.js.haml
app/views/projects/update_failed.js.haml
+0
-2
config/routes.rb
config/routes.rb
+4
-0
No files found.
app/contexts/projects/update_context.rb
View file @
e292d7c1
module
Projects
module
Projects
class
UpdateContext
<
BaseContext
class
UpdateContext
<
BaseContext
def
execute
(
role
=
:default
)
def
execute
(
role
=
:default
)
namespace_id
=
params
[
:project
].
delete
(
:namespace_id
)
params
[
:project
].
delete
(
:namespace_id
)
params
[
:project
].
delete
(
:public
)
unless
can?
(
current_user
,
:change_public_mode
,
project
)
params
[
:project
].
delete
(
:public
)
unless
can?
(
current_user
,
:change_public_mode
,
project
)
allowed_transfer
=
can?
(
current_user
,
:change_namespace
,
project
)
||
role
==
:admin
if
allowed_transfer
&&
namespace_id
.
present?
if
namespace_id
==
Namespace
.
global_id
if
project
.
namespace
.
present?
# Transfer to global namespace from anyone
project
.
transfer
(
nil
)
end
elsif
namespace_id
.
to_i
!=
project
.
namespace_id
# Transfer to someone namespace
namespace
=
Namespace
.
find
(
namespace_id
)
project
.
transfer
(
namespace
)
end
end
project
.
update_attributes
(
params
[
:project
],
as:
role
)
project
.
update_attributes
(
params
[
:project
],
as:
role
)
end
end
end
end
...
...
app/controllers/projects_controller.rb
View file @
e292d7c1
...
@@ -4,7 +4,7 @@ class ProjectsController < ProjectResourceController
...
@@ -4,7 +4,7 @@ class ProjectsController < ProjectResourceController
# Authorize
# Authorize
before_filter
:authorize_read_project!
,
except:
[
:index
,
:new
,
:create
]
before_filter
:authorize_read_project!
,
except:
[
:index
,
:new
,
:create
]
before_filter
:authorize_admin_project!
,
only:
[
:edit
,
:update
,
:destroy
]
before_filter
:authorize_admin_project!
,
only:
[
:edit
,
:update
,
:destroy
,
:transfer
]
before_filter
:require_non_empty_project
,
only:
[
:blob
,
:tree
,
:graph
]
before_filter
:require_non_empty_project
,
only:
[
:blob
,
:tree
,
:graph
]
layout
'application'
,
only:
[
:new
,
:create
]
layout
'application'
,
only:
[
:new
,
:create
]
...
@@ -45,10 +45,10 @@ class ProjectsController < ProjectResourceController
...
@@ -45,10 +45,10 @@ class ProjectsController < ProjectResourceController
format
.
js
format
.
js
end
end
end
end
end
rescue
Project
::
TransferError
=>
ex
def
transfer
@error
=
ex
::
Projects
::
TransferContext
.
new
(
project
,
current_user
,
params
).
execute
render
:update_failed
end
end
def
show
def
show
...
...
app/models/project.rb
View file @
e292d7c1
...
@@ -26,8 +26,6 @@ class Project < ActiveRecord::Base
...
@@ -26,8 +26,6 @@ class Project < ActiveRecord::Base
include
Gitlab
::
ShellAdapter
include
Gitlab
::
ShellAdapter
extend
Enumerize
extend
Enumerize
class
TransferError
<
StandardError
;
end
attr_accessible
:name
,
:path
,
:description
,
:default_branch
,
:issues_tracker
,
attr_accessible
:name
,
:path
,
:description
,
:default_branch
,
:issues_tracker
,
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:snippets_enabled
,
:issues_tracker_id
,
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:snippets_enabled
,
:issues_tracker_id
,
:wiki_enabled
,
:public
,
:import_url
,
as:
[
:default
,
:admin
]
:wiki_enabled
,
:public
,
:import_url
,
as:
[
:default
,
:admin
]
...
...
app/views/projects/_form.html.haml
View file @
e292d7c1
...
@@ -107,8 +107,9 @@
...
@@ -107,8 +107,9 @@
-
if
can?
(
current_user
,
:change_namespace
,
@project
)
-
if
can?
(
current_user
,
:change_namespace
,
@project
)
.ui-box.ui-box-danger
.ui-box.ui-box-danger
%h5
.title
Transfer project
%h5
.title
Transfer project
.errors-holder
.form-holder
.form-holder
=
form_for
(
@project
,
remote:
true
,
html:
{
class:
'transfer-project'
})
do
|
f
|
=
form_for
(
@project
,
url:
transfer_project_path
(
@project
),
remote:
true
,
html:
{
class:
'transfer-project'
})
do
|
f
|
.control-group
.control-group
=
f
.
label
:namespace_id
do
=
f
.
label
:namespace_id
do
%span
Namespace
%span
Namespace
...
...
app/views/projects/update_failed.js.haml
deleted
100644 → 0
View file @
ff35b37f
:plain
$(".save-project-loader").replaceWith(errorMessage('
#{
escape_javascript
(
@error
.
message
)
}
'));
config/routes.rb
View file @
e292d7c1
...
@@ -167,6 +167,10 @@ Gitlab::Application.routes.draw do
...
@@ -167,6 +167,10 @@ Gitlab::Application.routes.draw do
# Project Area
# Project Area
#
#
resources
:projects
,
constraints:
{
id:
/(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/
},
except:
[
:new
,
:create
,
:index
],
path:
"/"
do
resources
:projects
,
constraints:
{
id:
/(?:[a-zA-Z.0-9_\-]+\/)?[a-zA-Z.0-9_\-]+/
},
except:
[
:new
,
:create
,
:index
],
path:
"/"
do
member
do
put
:transfer
end
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:tree
,
only:
[
:show
],
constraints:
{
id:
/.+/
,
format:
/(html|js)/
}
resources
:tree
,
only:
[
:show
],
constraints:
{
id:
/.+/
,
format:
/(html|js)/
}
resources
:edit_tree
,
only:
[
:show
,
:update
],
constraints:
{
id:
/.+/
},
path:
'edit'
resources
:edit_tree
,
only:
[
:show
,
:update
],
constraints:
{
id:
/.+/
},
path:
'edit'
...
...
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