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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
94befdd5
Commit
94befdd5
authored
Mar 07, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Events improved. Open/close issue, merge request events displayed
parent
98b484b9
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
98 additions
and
19 deletions
+98
-19
app/controllers/issues_controller.rb
app/controllers/issues_controller.rb
+1
-1
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+1
-1
app/models/activity_observer.rb
app/models/activity_observer.rb
+15
-2
app/models/event.rb
app/models/event.rb
+23
-7
app/models/issue.rb
app/models/issue.rb
+1
-0
app/models/merge_request.rb
app/models/merge_request.rb
+1
-0
app/models/project.rb
app/models/project.rb
+2
-1
app/views/events/_event.html.haml
app/views/events/_event.html.haml
+5
-1
app/views/events/_event_changed_issue.html.haml
app/views/events/_event_changed_issue.html.haml
+14
-0
app/views/events/_event_changed_merge_request.html.haml
app/views/events/_event_changed_merge_request.html.haml
+19
-0
app/views/events/_event_push.html.haml
app/views/events/_event_push.html.haml
+9
-5
db/migrate/20120307095918_add_author_id_to_event.rb
db/migrate/20120307095918_add_author_id_to_event.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
No files found.
app/controllers/issues_controller.rb
View file @
94befdd5
...
@@ -76,7 +76,7 @@ class IssuesController < ApplicationController
...
@@ -76,7 +76,7 @@ class IssuesController < ApplicationController
end
end
def
update
def
update
@issue
.
update_attributes
(
params
[
:issue
])
@issue
.
update_attributes
(
params
[
:issue
]
.
merge
(
:author_id_of_changes
=>
current_user
.
id
)
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
js
format
.
js
...
...
app/controllers/merge_requests_controller.rb
View file @
94befdd5
...
@@ -87,7 +87,7 @@ class MergeRequestsController < ApplicationController
...
@@ -87,7 +87,7 @@ class MergeRequestsController < ApplicationController
def
update
def
update
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@merge_request
.
update_attributes
(
params
[
:merge_request
])
if
@merge_request
.
update_attributes
(
params
[
:merge_request
]
.
merge
(
:author_id_of_changes
=>
current_user
.
id
)
)
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully updated.'
}
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully updated.'
}
format
.
json
{
head
:ok
}
format
.
json
{
head
:ok
}
else
else
...
...
app/models/activity_observer.rb
View file @
94befdd5
class
ActivityObserver
<
ActiveRecord
::
Observer
class
ActivityObserver
<
ActiveRecord
::
Observer
observe
:issue
,
:merge_request
,
:note
observe
:issue
,
:merge_request
def
after_create
(
record
)
def
after_create
(
record
)
Event
.
create
(
Event
.
create
(
:project
=>
record
.
project
,
:project
=>
record
.
project
,
:target_id
=>
record
.
id
,
:target_id
=>
record
.
id
,
:target_type
=>
record
.
class
.
name
,
:target_type
=>
record
.
class
.
name
,
:action
=>
Event
.
determine_action
(
record
)
:action
=>
Event
.
determine_action
(
record
),
:author_id
=>
record
.
author_id
)
)
end
end
def
after_save
(
record
)
if
record
.
changed
.
include?
(
"closed"
)
Event
.
create
(
:project
=>
record
.
project
,
:target_id
=>
record
.
id
,
:target_type
=>
record
.
class
.
name
,
:action
=>
(
record
.
closed
?
Event
::
Closed
:
Event
::
Reopened
),
:author_id
=>
record
.
author_id_of_changes
)
end
end
end
end
app/models/event.rb
View file @
94befdd5
class
Event
<
ActiveRecord
::
Base
class
Event
<
ActiveRecord
::
Base
default_scope
where
(
"author_id IS NOT NULL"
)
Created
=
1
Created
=
1
Updated
=
2
Updated
=
2
Closed
=
3
Closed
=
3
...
@@ -26,13 +28,22 @@ class Event < ActiveRecord::Base
...
@@ -26,13 +28,22 @@ class Event < ActiveRecord::Base
# - new issue
# - new issue
# - merge request
# - merge request
def
allowed?
def
allowed?
push?
||
new_issue?
||
new_merge_request?
push?
||
new_issue?
||
new_merge_request?
||
changed_merge_request?
||
changed_issue?
end
end
def
push?
def
push?
action
==
self
.
class
::
Pushed
action
==
self
.
class
::
Pushed
end
end
def
closed?
action
==
self
.
class
::
Closed
end
def
reopened?
action
==
self
.
class
::
Reopened
end
def
new_tag?
def
new_tag?
data
[
:ref
][
"refs/tags"
]
data
[
:ref
][
"refs/tags"
]
end
end
...
@@ -57,10 +68,6 @@ class Event < ActiveRecord::Base
...
@@ -57,10 +68,6 @@ class Event < ActiveRecord::Base
@tag_name
||=
data
[
:ref
].
gsub
(
"refs/tags/"
,
""
)
@tag_name
||=
data
[
:ref
].
gsub
(
"refs/tags/"
,
""
)
end
end
def
pusher
User
.
find_by_id
(
data
[
:user_id
])
end
def
new_issue?
def
new_issue?
target_type
==
"Issue"
&&
target_type
==
"Issue"
&&
action
==
Created
action
==
Created
...
@@ -71,6 +78,16 @@ class Event < ActiveRecord::Base
...
@@ -71,6 +78,16 @@ class Event < ActiveRecord::Base
action
==
Created
action
==
Created
end
end
def
changed_merge_request?
target_type
==
"MergeRequest"
&&
[
Closed
,
Reopened
].
include?
(
action
)
end
def
changed_issue?
target_type
==
"Issue"
&&
[
Closed
,
Reopened
].
include?
(
action
)
end
def
issue
def
issue
target
if
target_type
==
"Issue"
target
if
target_type
==
"Issue"
end
end
...
@@ -80,7 +97,7 @@ class Event < ActiveRecord::Base
...
@@ -80,7 +97,7 @@ class Event < ActiveRecord::Base
end
end
def
author
def
author
target
.
author
@author
||=
User
.
find
(
author_id
)
end
end
def
commits
def
commits
...
@@ -89,7 +106,6 @@ class Event < ActiveRecord::Base
...
@@ -89,7 +106,6 @@ class Event < ActiveRecord::Base
end
end
end
end
delegate
:id
,
:name
,
:email
,
:to
=>
:pusher
,
:prefix
=>
true
,
:allow_nil
=>
true
delegate
:name
,
:email
,
:to
=>
:author
,
:prefix
=>
true
,
:allow_nil
=>
true
delegate
:name
,
:email
,
:to
=>
:author
,
:prefix
=>
true
,
:allow_nil
=>
true
delegate
:title
,
:to
=>
:issue
,
:prefix
=>
true
,
:allow_nil
=>
true
delegate
:title
,
:to
=>
:issue
,
:prefix
=>
true
,
:allow_nil
=>
true
delegate
:title
,
:to
=>
:merge_request
,
:prefix
=>
true
,
:allow_nil
=>
true
delegate
:title
,
:to
=>
:merge_request
,
:prefix
=>
true
,
:allow_nil
=>
true
...
...
app/models/issue.rb
View file @
94befdd5
...
@@ -5,6 +5,7 @@ class Issue < ActiveRecord::Base
...
@@ -5,6 +5,7 @@ class Issue < ActiveRecord::Base
has_many
:notes
,
:as
=>
:noteable
,
:dependent
=>
:destroy
has_many
:notes
,
:as
=>
:noteable
,
:dependent
=>
:destroy
attr_protected
:author
,
:author_id
,
:project
,
:project_id
attr_protected
:author
,
:author_id
,
:project
,
:project_id
attr_accessor
:author_id_of_changes
validates_presence_of
:project_id
validates_presence_of
:project_id
validates_presence_of
:assignee_id
validates_presence_of
:assignee_id
...
...
app/models/merge_request.rb
View file @
94befdd5
...
@@ -5,6 +5,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -5,6 +5,7 @@ class MergeRequest < ActiveRecord::Base
has_many
:notes
,
:as
=>
:noteable
,
:dependent
=>
:destroy
has_many
:notes
,
:as
=>
:noteable
,
:dependent
=>
:destroy
attr_protected
:author
,
:author_id
,
:project
,
:project_id
attr_protected
:author
,
:author_id
,
:project
,
:project_id
attr_accessor
:author_id_of_changes
validates_presence_of
:project_id
validates_presence_of
:project_id
validates_presence_of
:assignee_id
validates_presence_of
:assignee_id
...
...
app/models/project.rb
View file @
94befdd5
...
@@ -68,7 +68,8 @@ class Project < ActiveRecord::Base
...
@@ -68,7 +68,8 @@ class Project < ActiveRecord::Base
Event
.
create
(
Event
.
create
(
:project
=>
self
,
:project
=>
self
,
:action
=>
Event
::
Pushed
,
:action
=>
Event
::
Pushed
,
:data
=>
data
:data
=>
data
,
:author_id
=>
Key
.
find_by_identifier
(
author_key_id
).
user
.
id
)
)
end
end
...
...
app/views/events/_event.html.haml
View file @
94befdd5
...
@@ -2,7 +2,11 @@
...
@@ -2,7 +2,11 @@
.event_feed
.event_feed
-
if
event
.
new_issue?
-
if
event
.
new_issue?
=
render
"events/event_new_issue"
,
:event
=>
event
=
render
"events/event_new_issue"
,
:event
=>
event
-
if
event
.
new_merge_request?
-
els
if
event
.
new_merge_request?
=
render
"events/event_new_merge_request"
,
:event
=>
event
=
render
"events/event_new_merge_request"
,
:event
=>
event
-
elsif
event
.
changed_merge_request?
=
render
"events/event_changed_merge_request"
,
:event
=>
event
-
elsif
event
.
changed_issue?
=
render
"events/event_changed_issue"
,
:event
=>
event
-
elsif
event
.
push?
-
elsif
event
.
push?
=
render
"events/event_push"
,
:event
=>
event
=
render
"events/event_push"
,
:event
=>
event
app/views/events/_event_changed_issue.html.haml
0 → 100644
View file @
94befdd5
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
-
if
event
.
closed?
closed
-
else
reopened
issue
=
link_to
project_issue_path
(
event
.
project
,
event
.
issue
)
do
%strong
=
truncate
event
.
issue_title
at
%strong
=
link_to
event
.
project
.
name
,
event
.
project
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
ago.
app/views/events/_event_changed_merge_request.html.haml
0 → 100644
View file @
94befdd5
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
-
if
event
.
closed?
closed
-
else
reopened
merge request
=
link_to
project_merge_request_path
(
event
.
project
,
event
.
merge_request
)
do
%strong
=
truncate
event
.
merge_request_title
at
%strong
=
link_to
event
.
project
.
name
,
event
.
project
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
ago.
%br
%span
.label
=
event
.
merge_request
.
source_branch
→
%span
.label
=
event
.
merge_request
.
target_branch
app/views/events/_event_push.html.haml
View file @
94befdd5
-
if
event
.
new_branch?
||
event
.
new_tag?
-
if
event
.
new_branch?
||
event
.
new_tag?
=
image_tag
gravatar_icon
(
event
.
pushe
r_email
),
:class
=>
"avatar"
=
image_tag
gravatar_icon
(
event
.
autho
r_email
),
:class
=>
"avatar"
%strong
#{
event
.
pushe
r_name
}
%strong
#{
event
.
autho
r_name
}
pushed new
pushed new
-
if
event
.
new_tag?
-
if
event
.
new_tag?
tag
tag
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
=
time_ago_in_words
(
event
.
created_at
)
=
time_ago_in_words
(
event
.
created_at
)
ago.
ago.
-
else
-
else
=
image_tag
gravatar_icon
(
event
.
pushe
r_email
),
:class
=>
"avatar"
=
image_tag
gravatar_icon
(
event
.
autho
r_email
),
:class
=>
"avatar"
%strong
#{
event
.
pushe
r_name
}
%strong
#{
event
.
autho
r_name
}
pushed to
pushed to
=
link_to
project_commits_path
(
event
.
project
,
:ref
=>
event
.
branch_name
)
do
=
link_to
project_commits_path
(
event
.
project
,
:ref
=>
event
.
branch_name
)
do
%strong
=
event
.
branch_name
%strong
=
event
.
branch_name
...
@@ -31,6 +31,10 @@
...
@@ -31,6 +31,10 @@
Compare
#{
event
.
commits
.
first
.
commit
.
id
[
0
..
8
]
}
...
#{
event
.
commits
.
last
.
id
[
0
..
8
]
}
Compare
#{
event
.
commits
.
first
.
commit
.
id
[
0
..
8
]
}
...
#{
event
.
commits
.
last
.
id
[
0
..
8
]
}
-
@project
=
event
.
project
-
@project
=
event
.
project
%ul
.unstyled
%ul
.unstyled
-
if
event
.
commits
.
size
>
4
=
render
event
.
commits
[
0
..
2
]
%li
... and
#{
event
.
commits
.
size
-
3
}
more commits
-
else
=
render
event
.
commits
=
render
event
.
commits
db/migrate/20120307095918_add_author_id_to_event.rb
0 → 100644
View file @
94befdd5
class
AddAuthorIdToEvent
<
ActiveRecord
::
Migration
def
change
add_column
:events
,
:author_id
,
:integer
,
:null
=>
true
end
end
db/schema.rb
View file @
94befdd5
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
2012030
1185805
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
2012030
7095918
)
do
create_table
"events"
,
:force
=>
true
do
|
t
|
create_table
"events"
,
:force
=>
true
do
|
t
|
t
.
string
"target_type"
t
.
string
"target_type"
...
@@ -22,6 +22,7 @@ ActiveRecord::Schema.define(:version => 20120301185805) do
...
@@ -22,6 +22,7 @@ ActiveRecord::Schema.define(:version => 20120301185805) do
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
integer
"action"
t
.
integer
"action"
t
.
integer
"author_id"
end
end
create_table
"issues"
,
:force
=>
true
do
|
t
|
create_table
"issues"
,
:force
=>
true
do
|
t
|
...
...
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