Commit cf926f6b authored by Douwe Maan's avatar Douwe Maan Committed by Fatih Acet

Remove duplicate attributes from discussion entity and move note.can_edit into note.current_user

parent ebf91551
...@@ -3,18 +3,8 @@ class DiscussionEntity < Grape::Entity ...@@ -3,18 +3,8 @@ class DiscussionEntity < Grape::Entity
expose :id, :reply_id expose :id, :reply_id
expose :expanded?, as: :expanded expose :expanded?, as: :expanded
expose :author, using: UserEntity
expose :created_at
expose :last_updated_at, if: -> (discussion, _) { discussion.updated? }
expose :last_updated_by, if: -> (discussion, _) { discussion.updated? }, using: UserEntity
expose :notes, using: NoteEntity expose :notes, using: NoteEntity
expose :individual_note?, as: :individual_note expose :individual_note?, as: :individual_note
expose :can_reply do |discussion|
can?(request.current_user, :create_note, discussion.project)
end
end end
...@@ -17,8 +17,10 @@ class NoteEntity < API::Entities::Note ...@@ -17,8 +17,10 @@ class NoteEntity < API::Entities::Note
expose :last_edited_at, if: -> (note, _) { note.is_edited? } expose :last_edited_at, if: -> (note, _) { note.is_edited? }
expose :last_edited_by, using: UserEntity, if: -> (note, _) { note.is_edited? } expose :last_edited_by, using: UserEntity, if: -> (note, _) { note.is_edited? }
expose :can_edit do |note| expose :current_user do
Ability.can_edit_note?(request.current_user, note) expose :can_edit do |note|
Ability.can_edit_note?(request.current_user, note)
end
end end
expose :system_note_icon_name, if: -> (note, _) { note.system? } do |note| expose :system_note_icon_name, if: -> (note, _) { note.system? } do |note|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment