Remove duplicate attributes from discussion entity and move note.can_edit into note.current_user
This commit is contained in:
parent
ebf9155113
commit
cf926f6b7f
|
@ -3,18 +3,8 @@ class DiscussionEntity < Grape::Entity
|
|||
|
||||
expose :id, :reply_id
|
||||
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 :individual_note?, as: :individual_note
|
||||
|
||||
expose :can_reply do |discussion|
|
||||
can?(request.current_user, :create_note, discussion.project)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,8 +17,10 @@ class NoteEntity < API::Entities::Note
|
|||
expose :last_edited_at, if: -> (note, _) { note.is_edited? }
|
||||
expose :last_edited_by, using: UserEntity, if: -> (note, _) { note.is_edited? }
|
||||
|
||||
expose :can_edit do |note|
|
||||
Ability.can_edit_note?(request.current_user, note)
|
||||
expose :current_user do
|
||||
expose :can_edit do |note|
|
||||
Ability.can_edit_note?(request.current_user, note)
|
||||
end
|
||||
end
|
||||
|
||||
expose :system_note_icon_name, if: -> (note, _) { note.system? } do |note|
|
||||
|
|
Loading…
Reference in New Issue