diff options
| author | Andrew8xx8 <avk@8xx8.ru> | 2013-03-25 15:58:09 +0400 |
|---|---|---|
| committer | Andrew8xx8 <avk@8xx8.ru> | 2013-03-25 15:58:09 +0400 |
| commit | 3e695acfa2f4035431cb325645b3114d06e43105 (patch) | |
| tree | 34f9ee77f6888c23e0ee7c4d8055b65b35b1d0e7 /app | |
| parent | e3351287b4284af95390835bc75a6c3c461f04ba (diff) | |
| download | gitlab-ce-3e695acfa2f4035431cb325645b3114d06e43105.tar.gz | |
Notes fixed
Diffstat (limited to 'app')
| -rw-r--r-- | app/models/event.rb | 4 | ||||
| -rw-r--r-- | app/models/note.rb | 6 | ||||
| -rw-r--r-- | app/models/snippet.rb | 1 | ||||
| -rw-r--r-- | app/views/events/event/_note.html.haml | 4 |
4 files changed, 15 insertions, 0 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index ae14454c59a..d39445c4ffe 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -259,6 +259,10 @@ class Event < ActiveRecord::Base target.noteable_type == "Commit" end + def note_project_snippet? + target.noteable_type == "Snippet" + end + def note_target target.noteable end diff --git a/app/models/note.rb b/app/models/note.rb index f56f999fda1..2f3b059918a 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -170,4 +170,10 @@ class Note < ActiveRecord::Base "wall" end end + + # FIXME: Hack for polymorphic associations with STI + # For more information wisit http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#label-Polymorphic+Associations + def noteable_type=(sType) + super(sType.to_s.classify.constantize.base_class.to_s) + end end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 5d09c6b6e47..1b37ffe8339 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -20,6 +20,7 @@ class Snippet < ActiveRecord::Base attr_accessible :title, :content, :file_name, :expires_at, :private belongs_to :author, class_name: "User" + has_many :notes, as: :noteable, dependent: :destroy delegate :name, :email, to: :author, prefix: true, allow_nil: true diff --git a/app/views/events/event/_note.html.haml b/app/views/events/event/_note.html.haml index 8bcfa95ff62..81b8ff9bf24 100644 --- a/app/views/events/event/_note.html.haml +++ b/app/views/events/event/_note.html.haml @@ -5,6 +5,10 @@ - if event.note_commit? = event.note_target_type = link_to event.note_short_commit_id, project_commit_path(event.project, event.note_commit_id), class: "commit_short_id" + - if event.note_project_snippet? + = link_to project_snippet_path(event.project, event.note_target) do + %strong + #{event.note_target_type} ##{truncate event.note_target_id} - else = link_to [event.project, event.note_target] do %strong |
