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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7d6a02aa
Commit
7d6a02aa
authored
Aug 01, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle formats at the controller level in Projects::BoardListsController
parent
547d218e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
22 deletions
+18
-22
app/controllers/projects/board_lists_controller.rb
app/controllers/projects/board_lists_controller.rb
+18
-22
No files found.
app/controllers/projects/board_lists_controller.rb
View file @
7d6a02aa
class
Projects::BoardListsController
<
Projects
::
ApplicationController
class
Projects::BoardListsController
<
Projects
::
ApplicationController
respond_to
:json
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
def
create
def
create
list
=
Boards
::
Lists
::
CreateService
.
new
(
project
,
list_params
).
execute
list
=
Boards
::
Lists
::
CreateService
.
new
(
project
,
list_params
).
execute
respond_to
do
|
format
|
if
list
.
valid?
if
list
.
valid?
render
json:
list
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:color
]
}
})
format
.
json
{
render
json:
list
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:color
]
}
})
}
else
else
render
json:
list
.
errors
,
status: :unprocessable_entity
format
.
json
{
render
json:
list
.
errors
,
status: :unprocessable_entity
}
end
end
end
end
end
def
update
def
update
service
=
Boards
::
Lists
::
MoveService
.
new
(
project
,
move_params
)
service
=
Boards
::
Lists
::
MoveService
.
new
(
project
,
move_params
)
respond_to
do
|
format
|
if
service
.
execute
if
service
.
execute
head
:ok
format
.
json
{
head
:ok
}
else
else
head
:unprocessable_entity
format
.
json
{
head
:unprocessable_entity
}
end
end
end
end
end
def
destroy
def
destroy
service
=
Boards
::
Lists
::
DestroyService
.
new
(
project
,
params
)
service
=
Boards
::
Lists
::
DestroyService
.
new
(
project
,
params
)
respond_to
do
|
format
|
if
service
.
execute
if
service
.
execute
head
:ok
format
.
json
{
head
:ok
}
else
else
head
:unprocessable_entity
format
.
json
{
head
:unprocessable_entity
}
end
end
end
end
end
private
private
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
def
list_params
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
params
.
require
(
:list
).
permit
(
:label_id
)
end
end
...
@@ -50,4 +42,8 @@ class Projects::BoardListsController < Projects::ApplicationController
...
@@ -50,4 +42,8 @@ class Projects::BoardListsController < Projects::ApplicationController
def
move_params
def
move_params
params
.
require
(
:list
).
permit
(
:position
).
merge
(
id:
params
[
:id
])
params
.
require
(
:list
).
permit
(
:position
).
merge
(
id:
params
[
:id
])
end
end
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
end
end
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