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
Kazuhiko Shiozaki
gitlab-ce
Commits
d32c19b2
Commit
d32c19b2
authored
May 14, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bulk issue status update
parent
72d5a566
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
56 deletions
+70
-56
app/contexts/issues/bulk_update_context.rb
app/contexts/issues/bulk_update_context.rb
+36
-0
app/contexts/issues/list_context.rb
app/contexts/issues/list_context.rb
+32
-0
app/contexts/issues_bulk_update_context.rb
app/contexts/issues_bulk_update_context.rb
+0
-24
app/contexts/issues_list_context.rb
app/contexts/issues_list_context.rb
+0
-30
app/controllers/issues_controller.rb
app/controllers/issues_controller.rb
+2
-2
No files found.
app/contexts/issues/bulk_update_context.rb
0 → 100644
View file @
d32c19b2
module
Issues
class
BulkUpdateContext
<
BaseContext
def
execute
update_data
=
params
[
:update
]
issues_ids
=
update_data
[
:issues_ids
].
split
(
","
)
milestone_id
=
update_data
[
:milestone_id
]
assignee_id
=
update_data
[
:assignee_id
]
status
=
update_data
[
:status
]
opts
=
{}
opts
[
:milestone_id
]
=
milestone_id
if
milestone_id
.
present?
opts
[
:assignee_id
]
=
assignee_id
if
assignee_id
.
present?
issues
=
Issue
.
where
(
id:
issues_ids
).
all
issues
=
issues
.
select
{
|
issue
|
can?
(
current_user
,
:modify_issue
,
issue
)
}
issues
.
each
do
|
issue
|
issue
.
update_attributes
(
opts
)
if
status
.
present?
if
status
==
'closed'
issue
.
close
else
issue
.
reopen
end
end
end
{
count:
issues
.
count
,
success:
!
issues
.
count
.
zero?
}
end
end
end
app/contexts/issues/list_context.rb
0 → 100644
View file @
d32c19b2
module
Issues
class
ListContext
<
BaseContext
include
IssuesHelper
attr_accessor
:issues
def
execute
@issues
=
case
params
[
:status
]
when
issues_filter
[
:all
]
then
@project
.
issues
when
issues_filter
[
:closed
]
then
@project
.
issues
.
closed
when
issues_filter
[
:to_me
]
then
@project
.
issues
.
assigned
(
current_user
)
when
issues_filter
[
:by_me
]
then
@project
.
issues
.
authored
(
current_user
)
else
@project
.
issues
.
opened
end
@issues
=
@issues
.
tagged_with
(
params
[
:label_name
])
if
params
[
:label_name
].
present?
@issues
=
@issues
.
includes
(
:author
,
:project
)
# Filter by specific assignee_id (or lack thereof)?
if
params
[
:assignee_id
].
present?
@issues
=
@issues
.
where
(
assignee_id:
(
params
[
:assignee_id
]
==
'0'
?
nil
:
params
[
:assignee_id
]))
end
# Filter by specific milestone_id (or lack thereof)?
if
params
[
:milestone_id
].
present?
@issues
=
@issues
.
where
(
milestone_id:
(
params
[
:milestone_id
]
==
'0'
?
nil
:
params
[
:milestone_id
]))
end
@issues
end
end
end
app/contexts/issues_bulk_update_context.rb
deleted
100644 → 0
View file @
72d5a566
class
IssuesBulkUpdateContext
<
BaseContext
def
execute
update_data
=
params
[
:update
]
issues_ids
=
update_data
[
:issues_ids
].
split
(
","
)
milestone_id
=
update_data
[
:milestone_id
]
assignee_id
=
update_data
[
:assignee_id
]
status
=
update_data
[
:status
]
opts
=
{}
opts
[
:milestone_id
]
=
milestone_id
if
milestone_id
.
present?
opts
[
:assignee_id
]
=
assignee_id
if
assignee_id
.
present?
opts
[
:closed
]
=
(
status
==
"closed"
)
if
status
.
present?
issues
=
Issue
.
where
(
id:
issues_ids
).
all
issues
=
issues
.
select
{
|
issue
|
can?
(
current_user
,
:modify_issue
,
issue
)
}
issues
.
each
{
|
issue
|
issue
.
update_attributes
(
opts
)
}
{
count:
issues
.
count
,
success:
!
issues
.
count
.
zero?
}
end
end
app/contexts/issues_list_context.rb
deleted
100644 → 0
View file @
72d5a566
class
IssuesListContext
<
BaseContext
include
IssuesHelper
attr_accessor
:issues
def
execute
@issues
=
case
params
[
:status
]
when
issues_filter
[
:all
]
then
@project
.
issues
when
issues_filter
[
:closed
]
then
@project
.
issues
.
closed
when
issues_filter
[
:to_me
]
then
@project
.
issues
.
assigned
(
current_user
)
when
issues_filter
[
:by_me
]
then
@project
.
issues
.
authored
(
current_user
)
else
@project
.
issues
.
opened
end
@issues
=
@issues
.
tagged_with
(
params
[
:label_name
])
if
params
[
:label_name
].
present?
@issues
=
@issues
.
includes
(
:author
,
:project
)
# Filter by specific assignee_id (or lack thereof)?
if
params
[
:assignee_id
].
present?
@issues
=
@issues
.
where
(
assignee_id:
(
params
[
:assignee_id
]
==
'0'
?
nil
:
params
[
:assignee_id
]))
end
# Filter by specific milestone_id (or lack thereof)?
if
params
[
:milestone_id
].
present?
@issues
=
@issues
.
where
(
milestone_id:
(
params
[
:milestone_id
]
==
'0'
?
nil
:
params
[
:milestone_id
]))
end
@issues
end
end
app/controllers/issues_controller.rb
View file @
d32c19b2
...
...
@@ -86,7 +86,7 @@ class IssuesController < ProjectResourceController
end
def
bulk_update
result
=
IssuesBulkUpdateContext
.
new
(
project
,
current_user
,
params
).
execute
result
=
Issues
::
BulkUpdateContext
.
new
(
project
,
current_user
,
params
).
execute
redirect_to
:back
,
notice:
"
#{
result
[
:count
]
}
issues updated"
end
...
...
@@ -109,6 +109,6 @@ class IssuesController < ProjectResourceController
end
def
issues_filtered
@issues
=
IssuesListContext
.
new
(
project
,
current_user
,
params
).
execute
@issues
=
Issues
::
ListContext
.
new
(
project
,
current_user
,
params
).
execute
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