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
Tatuya Kamada
gitlab-ce
Commits
4a5b7718
Commit
4a5b7718
authored
Oct 14, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Participable doesn't need to know about Mentionable
parent
61d8f961
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
11 deletions
+16
-11
app/models/commit.rb
app/models/commit.rb
+2
-2
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+2
-2
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+6
-0
app/models/concerns/participable.rb
app/models/concerns/participable.rb
+4
-5
app/models/note.rb
app/models/note.rb
+2
-2
No files found.
app/models/commit.rb
View file @
4a5b7718
...
...
@@ -2,13 +2,13 @@ class Commit
extend
ActiveModel
::
Naming
include
ActiveModel
::
Conversion
include
Mentionable
include
Participable
include
Mentionable
include
Referable
include
StaticModel
attr_mentionable
:safe_message
participant
:author
,
:committer
,
:notes
,
:mentioned_users
participant
:author
,
:committer
,
:notes
attr_accessor
:project
...
...
app/models/concerns/issuable.rb
View file @
4a5b7718
...
...
@@ -6,8 +6,8 @@
#
module
Issuable
extend
ActiveSupport
::
Concern
include
Mentionable
include
Participable
include
Mentionable
included
do
belongs_to
:author
,
class_name:
"User"
...
...
@@ -47,7 +47,7 @@ module Issuable
prefix:
true
attr_mentionable
:title
,
:description
participant
:author
,
:assignee
,
:notes
,
:mentioned_users
participant
:author
,
:assignee
,
:notes
end
module
ClassMethods
...
...
app/models/concerns/mentionable.rb
View file @
4a5b7718
...
...
@@ -20,6 +20,12 @@ module Mentionable
end
end
included
do
if
self
<
Participable
participant
->
(
current_user
)
{
mentioned_users
(
current_user
,
load_lazy_references:
false
)
}
end
end
# Returns the text used as the body of a Note when this object is referenced
#
# By default this will be the class name and the result of calling
...
...
app/models/concerns/participable.rb
View file @
4a5b7718
...
...
@@ -12,7 +12,7 @@
#
# # ...
#
# participant :author, :assignee, :
mentioned_users, :notes
# participant :author, :assignee, :
notes, ->(current_user) { mentioned_users(current_user) }
# end
#
# issue = Issue.last
...
...
@@ -39,12 +39,11 @@ module Participable
# Save result into variable if you are going to reuse it inside same request
def
participants
(
current_user
=
self
.
author
,
project
=
self
.
project
,
load_lazy_references:
true
)
participants
=
self
.
class
.
participant_attrs
.
flat_map
do
|
attr
|
meth
=
method
(
attr
)
value
=
if
attr
==
:mentioned_users
meth
.
call
(
current_user
,
load_lazy_references:
false
)
if
attr
.
respond_to?
(
:call
)
instance_exec
(
current_user
,
&
attr
)
else
meth
.
call
send
(
attr
)
end
participants_for
(
value
,
current_user
,
project
)
...
...
app/models/note.rb
View file @
4a5b7718
...
...
@@ -22,14 +22,14 @@ require 'carrierwave/orm/activerecord'
require
'file_size_validator'
class
Note
<
ActiveRecord
::
Base
include
Mentionable
include
Gitlab
::
CurrentSettings
include
Participable
include
Mentionable
default_value_for
:system
,
false
attr_mentionable
:note
participant
:author
,
:mentioned_users
participant
:author
belongs_to
:project
belongs_to
:noteable
,
polymorphic:
true
...
...
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