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
678e5355
Commit
678e5355
authored
Dec 14, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create events on comments and milestone
parent
190e483f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
3 deletions
+40
-3
app/controllers/milestones_controller.rb
app/controllers/milestones_controller.rb
+2
-0
app/models/event.rb
app/models/event.rb
+9
-1
app/models/milestone.rb
app/models/milestone.rb
+1
-0
app/models/note.rb
app/models/note.rb
+8
-0
app/observers/activity_observer.rb
app/observers/activity_observer.rb
+2
-2
app/views/events/_event.html.haml
app/views/events/_event.html.haml
+2
-0
app/views/events/event/_note.html.haml
app/views/events/event/_note.html.haml
+16
-0
No files found.
app/controllers/milestones_controller.rb
View file @
678e5355
...
...
@@ -43,6 +43,7 @@ class MilestonesController < ProjectResourceController
def
create
@milestone
=
@project
.
milestones
.
new
(
params
[
:milestone
])
@milestone
.
author_id
=
current_user
.
id
if
@milestone
.
save
redirect_to
project_milestone_path
(
@project
,
@milestone
)
...
...
@@ -52,6 +53,7 @@ class MilestonesController < ProjectResourceController
end
def
update
@milestone
.
author_id
=
current_user
.
id
@milestone
.
update_attributes
(
params
[
:milestone
])
respond_to
do
|
format
|
...
...
app/models/event.rb
View file @
678e5355
...
...
@@ -63,7 +63,7 @@ class Event < ActiveRecord::Base
# - new issue
# - merge request
def
allowed?
push?
||
issue?
||
merge_request?
||
membership_changed?
push?
||
issue?
||
merge_request?
||
membership_changed?
||
note?
||
milestone?
end
def
project_name
...
...
@@ -94,6 +94,14 @@ class Event < ActiveRecord::Base
action
==
self
.
class
::
Reopened
end
def
milestone?
target_type
==
"Milestone"
end
def
note?
target_type
==
"Note"
end
def
issue?
target_type
==
"Issue"
end
...
...
app/models/milestone.rb
View file @
678e5355
...
...
@@ -14,6 +14,7 @@
class
Milestone
<
ActiveRecord
::
Base
attr_accessible
:title
,
:description
,
:due_date
,
:closed
attr_accessor
:author_id
belongs_to
:project
has_many
:issues
...
...
app/models/note.rb
View file @
678e5355
...
...
@@ -121,4 +121,12 @@ class Note < ActiveRecord::Base
def
downvote?
note
.
start_with?
(
'-1'
)
||
note
.
start_with?
(
':-1:'
)
end
def
noteable_type_name
if
noteable_type
.
present?
noteable_type
.
downcase
else
"wall"
end
end
end
app/observers/activity_observer.rb
View file @
678e5355
class
ActivityObserver
<
ActiveRecord
::
Observer
observe
:issue
,
:merge_request
observe
:issue
,
:merge_request
,
:note
,
:milestone
def
after_create
(
record
)
Event
.
create
(
...
...
@@ -12,7 +12,7 @@ class ActivityObserver < ActiveRecord::Observer
end
def
after_save
(
record
)
if
record
.
changed
.
include?
(
"closed"
)
if
record
.
changed
.
include?
(
"closed"
)
Event
.
create
(
project:
record
.
project
,
target_id:
record
.
id
,
...
...
app/views/events/_event.html.haml
View file @
678e5355
...
...
@@ -5,6 +5,8 @@
-
if
event
.
push?
=
render
"events/event/push"
,
event:
event
-
if
event
.
note?
=
render
"events/event/note"
,
event:
event
-
else
=
render
"events/event/common"
,
event:
event
...
...
app/views/events/event/_note.html.haml
0 → 100644
View file @
678e5355
.event-title
%span
.author_name
=
link_to_author
event
%span
.event_label
commented on
#{
event
.
target
.
noteable_type_name
}
-
if
event
.
target
and
event
.
target
.
noteable_id
=
link_to
[
event
.
project
,
event
.
target
.
noteable
]
do
%strong
=
truncate
event
.
target
.
noteable_id
-
else
%strong
(deleted)
at
-
if
event
.
project
=
link_to_project
event
.
project
-
else
=
event
.
project_name
.event-body
%p
.hint
=
truncate
event
.
target
.
note
,
length:
70
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