Class: Sufia::WorkShowPresenter
- Inherits:
-
CurationConcerns::WorkShowPresenter
- Object
- CurationConcerns::WorkShowPresenter
- Sufia::WorkShowPresenter
- Defined in:
- app/presenters/sufia/work_show_presenter.rb
Instance Method Summary collapse
- #display_feature_link? ⇒ Boolean
- #display_unfeature_link? ⇒ Boolean
- #editor? ⇒ Boolean
- #grouped_presenters(filtered_by: nil, except: nil) ⇒ Object
- #presenter_types ⇒ Object
- #stats_path ⇒ Object
- #tweeter ⇒ Object
Instance Method Details
#display_feature_link? ⇒ Boolean
31 32 33 |
# File 'app/presenters/sufia/work_show_presenter.rb', line 31 def display_feature_link? user_can_feature_works? && solr_document.public? && FeaturedWork.can_create_another? && !featured? end |
#display_unfeature_link? ⇒ Boolean
35 36 37 |
# File 'app/presenters/sufia/work_show_presenter.rb', line 35 def display_unfeature_link? user_can_feature_works? && solr_document.public? && featured? end |
#editor? ⇒ Boolean
7 8 9 |
# File 'app/presenters/sufia/work_show_presenter.rb', line 7 def editor? current_ability.can?(:edit, solr_document) end |
#grouped_presenters(filtered_by: nil, except: nil) ⇒ Object
24 25 26 27 28 29 |
# File 'app/presenters/sufia/work_show_presenter.rb', line 24 def grouped_presenters(filtered_by: nil, except: nil) grouped = collection_presenters.group_by(&:model_name).transform_keys { |key| key.to_s.underscore } grouped.select! { |obj| obj.downcase == filtered_by } unless filtered_by.nil? grouped.except!(*except) unless except.nil? grouped end |
#presenter_types ⇒ Object
20 21 22 |
# File 'app/presenters/sufia/work_show_presenter.rb', line 20 def presenter_types CurationConcerns.config.registered_curation_concern_types.map(&:underscore) + ["collection"] end |
#stats_path ⇒ Object
39 40 41 |
# File 'app/presenters/sufia/work_show_presenter.rb', line 39 def stats_path Sufia::Engine.routes.url_helpers.stats_work_path(self) end |
#tweeter ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/presenters/sufia/work_show_presenter.rb', line 11 def tweeter user = ::User.find_by_user_key(depositor) if user.try(:twitter_handle).present? "@#{user.twitter_handle}" else I18n.translate('sufia.product_twitter_handle') end end |