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
Jérome Perrin
gitlab-ce
Commits
e171c1d8
Commit
e171c1d8
authored
Oct 06, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Issue Board API to handle with has_many association
parent
1a2002d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
lib/api/boards.rb
lib/api/boards.rb
+17
-14
No files found.
lib/api/boards.rb
View file @
e171c1d8
...
@@ -7,13 +7,14 @@ module API
...
@@ -7,13 +7,14 @@ module API
# Get the project board
# Get the project board
get
':id/boards'
do
get
':id/boards'
do
authorize!
(
:read_board
,
user_project
)
authorize!
(
:read_board
,
user_project
)
present
[
user_project
.
board
]
,
with:
Entities
::
Board
present
user_project
.
boards
,
with:
Entities
::
Board
end
end
segment
':id/boards/:board_id'
do
segment
':id/boards/:board_id'
do
helpers
do
helpers
do
def
project_board
def
project_board
board
=
user_project
.
board
board
=
user_project
.
boards
.
first
if
params
[
:board_id
].
to_i
==
board
.
id
if
params
[
:board_id
].
to_i
==
board
.
id
board
board
else
else
...
@@ -55,8 +56,10 @@ module API
...
@@ -55,8 +56,10 @@ module API
authorize!
(
:admin_list
,
user_project
)
authorize!
(
:admin_list
,
user_project
)
list
=
::
Boards
::
Lists
::
CreateService
.
new
(
user_project
,
current_user
,
service
=
::
Boards
::
Lists
::
CreateService
.
new
(
user_project
,
current_user
,
{
label_id:
params
[
:label_id
]
}).
execute
{
label_id:
params
[
:label_id
]
})
list
=
service
.
execute
(
project_board
)
if
list
.
valid?
if
list
.
valid?
present
list
,
with:
Entities
::
List
present
list
,
with:
Entities
::
List
...
@@ -78,10 +81,10 @@ module API
...
@@ -78,10 +81,10 @@ module API
authorize!
(
:admin_list
,
user_project
)
authorize!
(
:admin_list
,
user_project
)
moved
=
::
Boards
::
Lists
::
MoveService
.
new
(
user_project
,
current_user
,
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
user_project
,
current_user
,
{
position:
params
[
:position
].
to_i
})
.
execute
(
list
)
{
position:
params
[
:position
].
to_i
})
if
moved
if
service
.
execute
(
list
)
present
list
,
with:
Entities
::
List
present
list
,
with:
Entities
::
List
else
else
render_api_error!
({
error:
"List could not be moved!"
},
400
)
render_api_error!
({
error:
"List could not be moved!"
},
400
)
...
@@ -97,16 +100,16 @@ module API
...
@@ -97,16 +100,16 @@ module API
# Example Request:
# Example Request:
# DELETE /projects/:id/boards/:board_id/lists/:list_id
# DELETE /projects/:id/boards/:board_id/lists/:list_id
delete
"/lists/:list_id"
do
delete
"/lists/:list_id"
do
list
=
board_lists
.
find_by
(
id:
params
[
:list_id
])
authorize!
(
:admin_list
,
user_project
)
authorize!
(
:admin_list
,
user_project
)
if
list
list
=
board_lists
.
find
(
params
[
:list_id
])
destroyed_list
=
::
Boards
::
Lists
::
DestroyService
.
new
(
user_project
,
current_user
).
execute
(
list
)
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
user_project
,
current_user
)
present
destroyed_list
,
with:
Entities
::
List
if
service
.
execute
(
list
)
present
list
,
with:
Entities
::
List
else
else
not_found!
(
'List'
)
render_api_error!
({
error:
'List could not be deleted!'
},
400
)
end
end
end
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