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
iv
gitlab-ce
Commits
1d2bdb4d
Commit
1d2bdb4d
authored
Jan 16, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move all Context classes into Services
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
dba98240
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
27 additions
and
27 deletions
+27
-27
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+1
-1
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
app/controllers/projects/edit_tree_controller.rb
app/controllers/projects/edit_tree_controller.rb
+1
-1
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-1
app/controllers/projects/new_tree_controller.rb
app/controllers/projects/new_tree_controller.rb
+1
-1
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+2
-2
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+4
-4
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+2
-2
app/services/base_service.rb
app/services/base_service.rb
+1
-1
app/services/files/base_service.rb
app/services/files/base_service.rb
+1
-1
app/services/files/create_service.rb
app/services/files/create_service.rb
+1
-1
app/services/files/delete_service.rb
app/services/files/delete_service.rb
+1
-1
app/services/files/update_service.rb
app/services/files/update_service.rb
+1
-1
app/services/issues/bulk_update_service.rb
app/services/issues/bulk_update_service.rb
+1
-1
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+1
-1
app/services/notes/load_service.rb
app/services/notes/load_service.rb
+1
-1
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+1
-1
app/services/projects/fork_service.rb
app/services/projects/fork_service.rb
+1
-1
app/services/projects/transfer_service.rb
app/services/projects/transfer_service.rb
+1
-1
app/services/projects/update_service.rb
app/services/projects/update_service.rb
+1
-1
app/services/search/global_service.rb
app/services/search/global_service.rb
+1
-1
app/services/search/project_service.rb
app/services/search/project_service.rb
+1
-1
No files found.
app/controllers/admin/projects_controller.rb
View file @
1d2bdb4d
...
@@ -19,7 +19,7 @@ class Admin::ProjectsController < Admin::ApplicationController
...
@@ -19,7 +19,7 @@ class Admin::ProjectsController < Admin::ApplicationController
end
end
def
transfer
def
transfer
result
=
::
Projects
::
Transfer
Context
.
new
(
@project
,
current_user
,
project:
params
).
execute
(
:admin
)
result
=
::
Projects
::
Transfer
Service
.
new
(
@project
,
current_user
,
project:
params
).
execute
(
:admin
)
if
result
if
result
redirect_to
[
:admin
,
@project
]
redirect_to
[
:admin
,
@project
]
...
...
app/controllers/projects/blob_controller.rb
View file @
1d2bdb4d
...
@@ -13,7 +13,7 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -13,7 +13,7 @@ class Projects::BlobController < Projects::ApplicationController
end
end
def
destroy
def
destroy
result
=
Files
::
Delete
Context
.
new
(
@project
,
current_user
,
params
,
@ref
,
@path
).
execute
result
=
Files
::
Delete
Service
.
new
(
@project
,
current_user
,
params
,
@ref
,
@path
).
execute
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"Your changes have been successfully committed"
flash
[
:notice
]
=
"Your changes have been successfully committed"
...
...
app/controllers/projects/edit_tree_controller.rb
View file @
1d2bdb4d
...
@@ -7,7 +7,7 @@ class Projects::EditTreeController < Projects::BaseTreeController
...
@@ -7,7 +7,7 @@ class Projects::EditTreeController < Projects::BaseTreeController
end
end
def
update
def
update
result
=
Files
::
Update
Context
.
new
(
@project
,
current_user
,
params
,
@ref
,
@path
).
execute
result
=
Files
::
Update
Service
.
new
(
@project
,
current_user
,
params
,
@ref
,
@path
).
execute
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"Your changes have been successfully committed"
flash
[
:notice
]
=
"Your changes have been successfully committed"
...
...
app/controllers/projects/issues_controller.rb
View file @
1d2bdb4d
...
@@ -89,7 +89,7 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -89,7 +89,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
def
bulk_update
def
bulk_update
result
=
Issues
::
BulkUpdate
Context
.
new
(
project
,
current_user
,
params
).
execute
result
=
Issues
::
BulkUpdate
Service
.
new
(
project
,
current_user
,
params
).
execute
redirect_to
:back
,
notice:
"
#{
result
[
:count
]
}
issues updated"
redirect_to
:back
,
notice:
"
#{
result
[
:count
]
}
issues updated"
end
end
...
...
app/controllers/projects/new_tree_controller.rb
View file @
1d2bdb4d
...
@@ -6,7 +6,7 @@ class Projects::NewTreeController < Projects::BaseTreeController
...
@@ -6,7 +6,7 @@ class Projects::NewTreeController < Projects::BaseTreeController
def
update
def
update
file_path
=
File
.
join
(
@path
,
File
.
basename
(
params
[
:file_name
]))
file_path
=
File
.
join
(
@path
,
File
.
basename
(
params
[
:file_name
]))
result
=
Files
::
Create
Context
.
new
(
@project
,
current_user
,
params
,
@ref
,
file_path
).
execute
result
=
Files
::
Create
Service
.
new
(
@project
,
current_user
,
params
,
@ref
,
file_path
).
execute
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"Your changes have been successfully committed"
flash
[
:notice
]
=
"Your changes have been successfully committed"
...
...
app/controllers/projects/notes_controller.rb
View file @
1d2bdb4d
...
@@ -5,7 +5,7 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -5,7 +5,7 @@ class Projects::NotesController < Projects::ApplicationController
before_filter
:authorize_admin_note!
,
only:
[
:update
,
:destroy
]
before_filter
:authorize_admin_note!
,
only:
[
:update
,
:destroy
]
def
index
def
index
@notes
=
Notes
::
Load
Context
.
new
(
project
,
current_user
,
params
).
execute
@notes
=
Notes
::
Load
Service
.
new
(
project
,
current_user
,
params
).
execute
notes_json
=
{
notes:
[]
}
notes_json
=
{
notes:
[]
}
...
@@ -20,7 +20,7 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -20,7 +20,7 @@ class Projects::NotesController < Projects::ApplicationController
end
end
def
create
def
create
@note
=
Notes
::
Create
Context
.
new
(
project
,
current_user
,
params
).
execute
@note
=
Notes
::
Create
Service
.
new
(
project
,
current_user
,
params
).
execute
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
json
{
render_note_json
(
@note
)
}
format
.
json
{
render_note_json
(
@note
)
}
...
...
app/controllers/projects_controller.rb
View file @
1d2bdb4d
...
@@ -20,7 +20,7 @@ class ProjectsController < ApplicationController
...
@@ -20,7 +20,7 @@ class ProjectsController < ApplicationController
end
end
def
create
def
create
@project
=
::
Projects
::
Create
Context
.
new
(
current_user
,
params
[
:project
]).
execute
@project
=
::
Projects
::
Create
Service
.
new
(
current_user
,
params
[
:project
]).
execute
respond_to
do
|
format
|
respond_to
do
|
format
|
flash
[
:notice
]
=
'Project was successfully created.'
if
@project
.
saved?
flash
[
:notice
]
=
'Project was successfully created.'
if
@project
.
saved?
...
@@ -36,7 +36,7 @@ class ProjectsController < ApplicationController
...
@@ -36,7 +36,7 @@ class ProjectsController < ApplicationController
end
end
def
update
def
update
status
=
::
Projects
::
Update
Context
.
new
(
@project
,
current_user
,
params
).
execute
status
=
::
Projects
::
Update
Service
.
new
(
@project
,
current_user
,
params
).
execute
respond_to
do
|
format
|
respond_to
do
|
format
|
if
status
if
status
...
@@ -51,7 +51,7 @@ class ProjectsController < ApplicationController
...
@@ -51,7 +51,7 @@ class ProjectsController < ApplicationController
end
end
def
transfer
def
transfer
::
Projects
::
Transfer
Context
.
new
(
project
,
current_user
,
params
).
execute
::
Projects
::
Transfer
Service
.
new
(
project
,
current_user
,
params
).
execute
end
end
def
show
def
show
...
@@ -89,7 +89,7 @@ class ProjectsController < ApplicationController
...
@@ -89,7 +89,7 @@ class ProjectsController < ApplicationController
end
end
def
fork
def
fork
@forked_project
=
::
Projects
::
Fork
Context
.
new
(
project
,
current_user
).
execute
@forked_project
=
::
Projects
::
Fork
Service
.
new
(
project
,
current_user
).
execute
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
...
...
app/controllers/search_controller.rb
View file @
1d2bdb4d
...
@@ -5,9 +5,9 @@ class SearchController < ApplicationController
...
@@ -5,9 +5,9 @@ class SearchController < ApplicationController
if
@project
if
@project
return
access_denied!
unless
can?
(
current_user
,
:download_code
,
@project
)
return
access_denied!
unless
can?
(
current_user
,
:download_code
,
@project
)
@search_results
=
Search
::
Project
Context
.
new
(
@project
,
current_user
,
params
).
execute
@search_results
=
Search
::
Project
Service
.
new
(
@project
,
current_user
,
params
).
execute
else
else
@search_results
=
Search
::
Global
Context
.
new
(
current_user
,
params
).
execute
@search_results
=
Search
::
Global
Service
.
new
(
current_user
,
params
).
execute
end
end
end
end
end
end
app/
contexts/base_context
.rb
→
app/
services/base_service
.rb
View file @
1d2bdb4d
class
Base
Context
class
Base
Service
attr_accessor
:project
,
:current_user
,
:params
attr_accessor
:project
,
:current_user
,
:params
def
initialize
(
project
,
user
,
params
)
def
initialize
(
project
,
user
,
params
)
...
...
app/
contexts/files/base_context
.rb
→
app/
services/files/base_service
.rb
View file @
1d2bdb4d
module
Files
module
Files
class
Base
Context
<
::
BaseContext
class
Base
Service
<
::
BaseService
attr_reader
:ref
,
:path
attr_reader
:ref
,
:path
def
initialize
(
project
,
user
,
params
,
ref
,
path
=
nil
)
def
initialize
(
project
,
user
,
params
,
ref
,
path
=
nil
)
...
...
app/
contexts/files/create_context
.rb
→
app/
services/files/create_service
.rb
View file @
1d2bdb4d
require_relative
"base_context"
require_relative
"base_context"
module
Files
module
Files
class
Create
Context
<
BaseContext
class
Create
Service
<
BaseService
def
execute
def
execute
allowed
=
if
project
.
protected_branch?
(
ref
)
allowed
=
if
project
.
protected_branch?
(
ref
)
can?
(
current_user
,
:push_code_to_protected_branches
,
project
)
can?
(
current_user
,
:push_code_to_protected_branches
,
project
)
...
...
app/
contexts/files/delete_context
.rb
→
app/
services/files/delete_service
.rb
View file @
1d2bdb4d
require_relative
"base_context"
require_relative
"base_context"
module
Files
module
Files
class
Delete
Context
<
BaseContext
class
Delete
Service
<
BaseService
def
execute
def
execute
allowed
=
if
project
.
protected_branch?
(
ref
)
allowed
=
if
project
.
protected_branch?
(
ref
)
can?
(
current_user
,
:push_code_to_protected_branches
,
project
)
can?
(
current_user
,
:push_code_to_protected_branches
,
project
)
...
...
app/
contexts/files/update_context
.rb
→
app/
services/files/update_service
.rb
View file @
1d2bdb4d
require_relative
"base_context"
require_relative
"base_context"
module
Files
module
Files
class
Update
Context
<
BaseContext
class
Update
Service
<
BaseService
def
execute
def
execute
allowed
=
if
project
.
protected_branch?
(
ref
)
allowed
=
if
project
.
protected_branch?
(
ref
)
can?
(
current_user
,
:push_code_to_protected_branches
,
project
)
can?
(
current_user
,
:push_code_to_protected_branches
,
project
)
...
...
app/
contexts/issues/bulk_update_context
.rb
→
app/
services/issues/bulk_update_service
.rb
View file @
1d2bdb4d
module
Issues
module
Issues
class
BulkUpdate
Context
<
BaseContext
class
BulkUpdate
Service
<
BaseService
def
execute
def
execute
update_data
=
params
[
:update
]
update_data
=
params
[
:update
]
...
...
app/
contexts/notes/create_context
.rb
→
app/
services/notes/create_service
.rb
View file @
1d2bdb4d
module
Notes
module
Notes
class
Create
Context
<
BaseContext
class
Create
Service
<
BaseService
def
execute
def
execute
note
=
project
.
notes
.
new
(
params
[
:note
])
note
=
project
.
notes
.
new
(
params
[
:note
])
note
.
author
=
current_user
note
.
author
=
current_user
...
...
app/
contexts/notes/load_context
.rb
→
app/
services/notes/load_service
.rb
View file @
1d2bdb4d
module
Notes
module
Notes
class
Load
Context
<
BaseContext
class
Load
Service
<
BaseService
def
execute
def
execute
target_type
=
params
[
:target_type
]
target_type
=
params
[
:target_type
]
target_id
=
params
[
:target_id
]
target_id
=
params
[
:target_id
]
...
...
app/
contexts/projects/create_context
.rb
→
app/
services/projects/create_service
.rb
View file @
1d2bdb4d
module
Projects
module
Projects
class
Create
Context
<
BaseContext
class
Create
Service
<
BaseService
def
initialize
(
user
,
params
)
def
initialize
(
user
,
params
)
@current_user
,
@params
=
user
,
params
.
dup
@current_user
,
@params
=
user
,
params
.
dup
end
end
...
...
app/
contexts/projects/fork_context
.rb
→
app/
services/projects/fork_service
.rb
View file @
1d2bdb4d
module
Projects
module
Projects
class
Fork
Context
<
BaseContext
class
Fork
Service
<
BaseService
include
Gitlab
::
ShellAdapter
include
Gitlab
::
ShellAdapter
def
initialize
(
project
,
user
)
def
initialize
(
project
,
user
)
...
...
app/
contexts/projects/transfer_context
.rb
→
app/
services/projects/transfer_service
.rb
View file @
1d2bdb4d
module
Projects
module
Projects
class
Transfer
Context
<
BaseContext
class
Transfer
Service
<
BaseService
def
execute
(
role
=
:default
)
def
execute
(
role
=
:default
)
namespace_id
=
params
[
:project
].
delete
(
:namespace_id
)
namespace_id
=
params
[
:project
].
delete
(
:namespace_id
)
allowed_transfer
=
can?
(
current_user
,
:change_namespace
,
project
)
||
role
==
:admin
allowed_transfer
=
can?
(
current_user
,
:change_namespace
,
project
)
||
role
==
:admin
...
...
app/
contexts/projects/update_context
.rb
→
app/
services/projects/update_service
.rb
View file @
1d2bdb4d
module
Projects
module
Projects
class
Update
Context
<
BaseContext
class
Update
Service
<
BaseService
def
execute
(
role
=
:default
)
def
execute
(
role
=
:default
)
params
[
:project
].
delete
(
:namespace_id
)
params
[
:project
].
delete
(
:namespace_id
)
# check that user is allowed to set specified visibility_level
# check that user is allowed to set specified visibility_level
...
...
app/
contexts/search/global_context
.rb
→
app/
services/search/global_service
.rb
View file @
1d2bdb4d
module
Search
module
Search
class
Global
Context
class
Global
Service
attr_accessor
:current_user
,
:params
attr_accessor
:current_user
,
:params
def
initialize
(
user
,
params
)
def
initialize
(
user
,
params
)
...
...
app/
contexts/search/project_context
.rb
→
app/
services/search/project_service
.rb
View file @
1d2bdb4d
module
Search
module
Search
class
Project
Context
class
Project
Service
attr_accessor
:project
,
:current_user
,
:params
attr_accessor
:project
,
:current_user
,
:params
def
initialize
(
project
,
user
,
params
)
def
initialize
(
project
,
user
,
params
)
...
...
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