def create
@milestone = @project.milestones.new(params[:milestone])
+ @milestone.author_id = current_user.id
if @milestone.save
redirect_to project_milestone_path(@project, @milestone)
end
def update
+ @milestone.author_id = current_user.id
@milestone.update_attributes(params[:milestone])
respond_to do |format|
# - new issue
# - merge request
def allowed?
- push? || issue? || merge_request? || membership_changed?
+ push? || issue? || merge_request? || membership_changed? || note? || milestone?
end
def project_name
action == self.class::Reopened
end
+ def milestone?
+ target_type == "Milestone"
+ end
+
+ def note?
+ target_type == "Note"
+ end
+
def issue?
target_type == "Issue"
end
class Milestone < ActiveRecord::Base
attr_accessible :title, :description, :due_date, :closed
+ attr_accessor :author_id
belongs_to :project
has_many :issues
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
class ActivityObserver < ActiveRecord::Observer
- observe :issue, :merge_request
+ observe :issue, :merge_request, :note, :milestone
def after_create(record)
Event.create(
end
def after_save(record)
- if record.changed.include?("closed")
+ if record.changed.include?("closed")
Event.create(
project: record.project,
target_id: record.id,
- 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
--- /dev/null
+.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