BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
fffbc369
Commit
fffbc369
authored
Jul 25, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rs-issue-2092' into 'master'
Dynamically check `:admin_*` ability in two more spots. Closes #2092 Depends on !1037 See merge request !1042
parents
71a8c780
b9b2d086
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
5 deletions
+27
-5
issuable.rb
app/models/concerns/issuable.rb
+10
-0
issuable_base_service.rb
app/services/issuable_base_service.rb
+4
-2
base_service.rb
app/services/issues/base_service.rb
+4
-0
base_service.rb
app/services/merge_requests/base_service.rb
+6
-0
_context.html.haml
app/views/shared/issuable/_context.html.haml
+2
-2
_form.html.haml
app/views/shared/issuable/_form.html.haml
+1
-1
No files found.
app/models/concerns/issuable.rb
View file @
fffbc369
...
...
@@ -159,6 +159,16 @@ module Issuable
end
end
# Convert this Issuable class name to a format usable by Ability definitions
#
# Examples:
#
# issuable.class # => MergeRequest
# issuable.to_ability_name # => "merge_request"
def
to_ability_name
self
.
class
.
to_s
.
underscore
end
private
def
filter_superceded_votes
(
votes
,
notes
)
...
...
app/services/issuable_base_service.rb
View file @
fffbc369
...
...
@@ -27,8 +27,10 @@ class IssuableBaseService < BaseService
old_branch
,
new_branch
)
end
def
filter_params
unless
can?
(
current_user
,
:admin_issue
,
project
)
def
filter_params
(
issuable_ability_name
=
:issue
)
ability
=
:"admin_
#{
issuable_ability_name
}
"
unless
can?
(
current_user
,
ability
,
project
)
params
.
delete
(
:milestone_id
)
params
.
delete
(
:label_ids
)
params
.
delete
(
:assignee_id
)
...
...
app/services/issues/base_service.rb
View file @
fffbc369
...
...
@@ -10,6 +10,10 @@ module Issues
private
def
filter_params
super
(
:issue
)
end
def
execute_hooks
(
issue
,
action
=
'open'
)
issue_data
=
hook_data
(
issue
,
action
)
issue
.
project
.
execute_hooks
(
issue_data
,
:issue_hooks
)
...
...
app/services/merge_requests/base_service.rb
View file @
fffbc369
...
...
@@ -20,5 +20,11 @@ module MergeRequests
merge_request
.
project
.
execute_services
(
merge_data
,
:merge_request_hooks
)
end
end
private
def
filter_params
super
(
:merge_request
)
end
end
end
app/views/shared/issuable/_context.html.haml
View file @
fffbc369
...
...
@@ -8,7 +8,7 @@
-
else
none
.issuable-context-selectbox
-
if
can?
(
current_user
,
:"admin_
#{
issuable
.
class
.
to_s
.
underscor
e
}
"
,
@project
)
-
if
can?
(
current_user
,
:"admin_
#{
issuable
.
to_ability_nam
e
}
"
,
@project
)
=
users_select_tag
(
"
#{
issuable
.
class
.
table_name
.
singularize
}
[assignee_id]"
,
placeholder:
'Select assignee'
,
class:
'custom-form-control js-select2 js-assignee'
,
selected:
issuable
.
assignee_id
,
project:
@target_project
,
null_user:
true
)
%div
.prepend-top-20.clearfix
...
...
@@ -24,7 +24,7 @@
-
else
none
.issuable-context-selectbox
-
if
can?
(
current_user
,
:"admin_
#{
issuable
.
class
.
to_s
.
underscor
e
}
"
,
@project
)
-
if
can?
(
current_user
,
:"admin_
#{
issuable
.
to_ability_nam
e
}
"
,
@project
)
=
f
.
select
(
:milestone_id
,
milestone_options
(
issuable
),
{
include_blank:
'Select milestone'
},
{
class:
'select2 select2-compact js-select2 js-milestone'
})
=
hidden_field_tag
:issuable_context
=
f
.
submit
class:
'btn hide'
...
...
app/views/shared/issuable/_form.html.haml
View file @
fffbc369
...
...
@@ -38,7 +38,7 @@
.clearfix
.error-alert
%hr
-
if
can?
(
current_user
,
:
admin_issue
,
@project
)
-
if
can?
(
current_user
,
:
"admin_
#{
issuable
.
to_ability_name
}
"
,
@project
)
.form-group
.issue-assignee
=
f
.
label
:assignee_id
,
class:
'control-label'
do
...
...
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