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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
37bc7bac
Commit
37bc7bac
authored
Jul 24, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Issuable#to_ability_name
parent
b5e6ffa6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+10
-0
app/views/shared/issuable/_context.html.haml
app/views/shared/issuable/_context.html.haml
+2
-2
No files found.
app/models/concerns/issuable.rb
View file @
37bc7bac
...
@@ -159,6 +159,16 @@ module Issuable
...
@@ -159,6 +159,16 @@ module Issuable
end
end
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
private
def
filter_superceded_votes
(
votes
,
notes
)
def
filter_superceded_votes
(
votes
,
notes
)
...
...
app/views/shared/issuable/_context.html.haml
View file @
37bc7bac
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
-
else
-
else
none
none
.issuable-context-selectbox
.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
)
=
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
%div
.prepend-top-20.clearfix
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
-
else
-
else
none
none
.issuable-context-selectbox
.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'
})
=
f
.
select
(
:milestone_id
,
milestone_options
(
issuable
),
{
include_blank:
'Select milestone'
},
{
class:
'select2 select2-compact js-select2 js-milestone'
})
=
hidden_field_tag
:issuable_context
=
hidden_field_tag
:issuable_context
=
f
.
submit
class:
'btn hide'
=
f
.
submit
class:
'btn hide'
...
...
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