Class: Decidim::DecidimAwesome::ParticipatorySpaceRolePresenter
- Inherits:
-
RoleBasePresenter
- Object
- PaperTrailBasePresenter
- RoleBasePresenter
- Decidim::DecidimAwesome::ParticipatorySpaceRolePresenter
- Defined in:
- app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb
Instance Attribute Summary
Attributes inherited from PaperTrailBasePresenter
Instance Method Summary collapse
-
#destroy_entry ⇒ Object
Finds the destroyed entry if exists.
-
#participatory_space ⇒ Object
participatory spaces is in the normal entry if the role hasn’t been removed otherwise is in the removed role log entry.
-
#role ⇒ Object
roles are in the destroyed event if the role has been removed.
- #role_name ⇒ Object
- #user ⇒ Object
Methods inherited from RoleBasePresenter
#created_at, #created_date, #destroy_item, #destroyed_at, #last_sign_in_date, #participatory_space_name, #participatory_space_path, #participatory_space_type, #removal_date, #user_email, #user_name
Methods inherited from PaperTrailBasePresenter
#initialize, #item, #item_id, #item_type
Constructor Details
This class inherits a constructor from Decidim::DecidimAwesome::PaperTrailBasePresenter
Instance Method Details
#destroy_entry ⇒ Object
Finds the destroyed entry if exists
7 8 9 |
# File 'app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb', line 7 def destroy_entry @destroy_entry ||= PaperTrail::Version.find_by(item_type:, event: "destroy", item_id:) end |
#participatory_space ⇒ Object
participatory spaces is in the normal entry if the role hasn’t been removed otherwise is in the removed role log entry
29 30 31 |
# File 'app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb', line 29 def participatory_space item&.participatory_space || destroy_item&.participatory_space end |
#role ⇒ Object
roles are in the destroyed event if the role has been removed
12 13 14 |
# File 'app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb', line 12 def role @role ||= destroy_item&.role || item&.role end |
#role_name ⇒ Object
16 17 18 19 20 21 |
# File 'app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb', line 16 def role_name type = I18n.t(role, scope: "decidim.decidim_awesome.admin.admin_accountability.roles", default: role) return type unless html && role_class "<span class=\"#{role_class}\">#{type}</span>".html_safe end |
#user ⇒ Object
23 24 25 |
# File 'app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb', line 23 def user @user ||= Decidim::User.find_by(id: entry.changeset["decidim_user_id"]&.last) end |