diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-09 16:24:54 -0500 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2017-07-21 22:35:24 +0300 |
commit | 76c3d2d434d3c550c3de912abc0a5b1dc1455368 (patch) | |
tree | caf45606608993ccd660c8cab45ef387fbf9756e /app/serializers/discussion_entity.rb | |
parent | cb2287df0ad9396d1f075bde1c4f6de481d908e6 (diff) | |
download | gitlab-ce-76c3d2d434d3c550c3de912abc0a5b1dc1455368.tar.gz |
Add full JSON endpoints for issue notes and discussions
Diffstat (limited to 'app/serializers/discussion_entity.rb')
-rw-r--r-- | app/serializers/discussion_entity.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/serializers/discussion_entity.rb b/app/serializers/discussion_entity.rb new file mode 100644 index 00000000000..cb6c3c23807 --- /dev/null +++ b/app/serializers/discussion_entity.rb @@ -0,0 +1,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 |