Class: Decidim::DecidimAwesome::PrivateDataPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::DecidimAwesome::PrivateDataPresenter
- Includes:
- ActionView::Helpers::DateHelper, ActionView::Helpers::TagHelper, TranslatableAttributes
- Defined in:
- app/presenters/decidim/decidim_awesome/private_data_presenter.rb
Instance Method Summary collapse
- #as_json(_options = nil) ⇒ Object
- #destroyable? ⇒ Boolean
- #done ⇒ Object
- #last_date ⇒ Object
- #locked? ⇒ Boolean
- #name ⇒ Object
- #path ⇒ Object
- #time_ago ⇒ Object
- #total ⇒ Object
Instance Method Details
#as_json(_options = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 47 def as_json( = nil) { id:, name:, path:, total:, last_date:, time_ago:, locked: locked?, done: } end |
#destroyable? ⇒ Boolean
37 38 39 40 41 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 37 def destroyable? return false unless last_date last_date < DecidimAwesome.private_data_expiration_time.ago end |
#done ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 60 def done return content_tag("span", "", class: "loading-spinner primary") if locked? return if destroyable? return if last_date I18n.t("decidim.decidim_awesome.admin.maintenance.private_data.done") end |
#last_date ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 25 def last_date @last_date ||= Decidim::Proposals::Proposal.joins(:extra_fields) .where(component: self) .where.not(extra_fields: { private_body: nil }) .order(private_body_updated_at: :desc) .first&.extra_fields&.private_body_updated_at end |
#locked? ⇒ Boolean
43 44 45 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 43 def locked? Decidim::DecidimAwesome::Lock.new(organization).locked?(__getobj__) end |
#name ⇒ Object
10 11 12 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 10 def name @name ||= "#{translated_attribute(participatory_space.title)} / #{translated_attribute(super)}" end |
#path ⇒ Object
14 15 16 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 14 def path @path ||= Decidim::EngineRouter.main_proxy(self).root_path end |
#time_ago ⇒ Object
33 34 35 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 33 def time_ago I18n.t("decidim.decidim_awesome.admin.maintenance.private_data.time_ago", time: time_ago_in_words(last_date)) if last_date end |
#total ⇒ Object
18 19 20 21 22 23 |
# File 'app/presenters/decidim/decidim_awesome/private_data_presenter.rb', line 18 def total @total ||= Decidim::Proposals::Proposal.joins(:extra_fields) .where(component: self) .where.not(extra_fields: { private_body: nil }) .count.to_s end |