summaryrefslogtreecommitdiff
path: root/app/models/event.rb
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-09-10 10:11:38 +0000
committerRémy Coutable <remy@rymai.me>2019-09-10 10:11:38 +0000
commitf4945879735d3a6d9f6ecac4773cb6a660cd57a4 (patch)
tree4f25a800821efafc56ea35cebacb221326d0d583 /app/models/event.rb
parent6d486fde835bd8d25c20124fb09b83c6cbe97012 (diff)
downloadgitlab-ce-f4945879735d3a6d9f6ecac4773cb6a660cd57a4.tar.gz
Add event presenter
This presenter will be used in an upcoming MR which adds rendering of epic events on group activity page.
Diffstat (limited to 'app/models/event.rb')
-rw-r--r--app/models/event.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/event.rb b/app/models/event.rb
index 52d54be39a9..580bb770599 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -3,6 +3,8 @@
class Event < ApplicationRecord
include Sortable
include FromUnion
+ include Presentable
+
default_scope { reorder(nil) }
CREATED = 1
@@ -135,6 +137,10 @@ class Event < ApplicationRecord
end
end
+ def present
+ super(presenter_class: ::EventPresenter)
+ end
+
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
def visible_to_user?(user = nil)
@@ -161,12 +167,8 @@ class Event < ApplicationRecord
# rubocop:enable Metrics/PerceivedComplexity
# rubocop:enable Metrics/CyclomaticComplexity
- def project_name
- if project
- project.full_name
- else
- "(deleted project)"
- end
+ def resource_parent
+ project || group
end
def target_title