summaryrefslogtreecommitdiff
path: root/app/serializers/discussion_entity.rb
blob: cb6c3c238070a55bee2d3daf28a16ea603fec8aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class DiscussionEntity < Grape::Entity
  include RequestAwareEntity

  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