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
Show 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
# Get the project board
get
':id/boards'
do
authorize!
(
:read_board
,
user_project
)
present
[
user_project
.
board
]
,
with:
Entities
::
Board
present
user_project
.
boards
,
with:
Entities
::
Board
end
segment
':id/boards/:board_id'
do
helpers
do
def
project_board
board
=
user_project
.
board
board
=
user_project
.
boards
.
first
if
params
[
:board_id
].
to_i
==
board
.
id
board
else
...
...
@@ -55,8 +56,10 @@ module API
authorize!
(
:admin_list
,
user_project
)
list
=
::
Boards
::
Lists
::
CreateService
.
new
(
user_project
,
current_user
,
{
label_id:
params
[
:label_id
]
}).
execute
service
=
::
Boards
::
Lists
::
CreateService
.
new
(
user_project
,
current_user
,
{
label_id:
params
[
:label_id
]
})
list
=
service
.
execute
(
project_board
)
if
list
.
valid?
present
list
,
with:
Entities
::
List
...
...
@@ -78,10 +81,10 @@ module API
authorize!
(
:admin_list
,
user_project
)
moved
=
::
Boards
::
Lists
::
MoveService
.
new
(
user_project
,
current_user
,
{
position:
params
[
:position
].
to_i
})
.
execute
(
list
)
service
=
::
Boards
::
Lists
::
MoveService
.
new
(
user_project
,
current_user
,
{
position:
params
[
:position
].
to_i
})
if
moved
if
service
.
execute
(
list
)
present
list
,
with:
Entities
::
List
else
render_api_error!
({
error:
"List could not be moved!"
},
400
)
...
...
@@ -97,16 +100,16 @@ module API
# Example Request:
# DELETE /projects/:id/boards/:board_id/lists/:list_id
delete
"/lists/:list_id"
do
list
=
board_lists
.
find_by
(
id:
params
[
:list_id
])
authorize!
(
:admin_list
,
user_project
)
if
list
destroyed_list
=
::
Boards
::
Lists
::
DestroyService
.
new
(
user_project
,
current_user
).
execute
(
list
)
present
destroyed_list
,
with:
Entities
::
List
list
=
board_lists
.
find
(
params
[
:list_id
])
service
=
::
Boards
::
Lists
::
DestroyService
.
new
(
user_project
,
current_user
)
if
service
.
execute
(
list
)
present
list
,
with:
Entities
::
List
else
not_found!
(
'List'
)
render_api_error!
({
error:
'List could not be deleted!'
},
400
)
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