Class: Decidim::DecidimAwesome::PaperTrailVersion
- Inherits:
-
PaperTrail::Version
- Object
- PaperTrail::Version
- Decidim::DecidimAwesome::PaperTrailVersion
- Defined in:
- app/models/decidim/decidim_awesome/paper_trail_version.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.admin_role_actions(filter = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/decidim/decidim_awesome/paper_trail_version.rb', line 28 def self.admin_role_actions(filter = nil) base = where(item_type: "Decidim::UserBaseEntity", event: %w(create update)) case filter when nil base.where("object_changes LIKE '%\nroles:\n- []\n- - %' OR object_changes LIKE '%\nadmin:\n- false\n- true%'") when "admin" base.where("object_changes LIKE '%\nadmin:\n- false\n- true%'") else base.where(Arel.sql("object_changes LIKE '%\nroles:\n- []\n- - #{filter}\n%'")) end end |
.safe_user_roles ⇒ Object
8 9 10 |
# File 'app/models/decidim/decidim_awesome/paper_trail_version.rb', line 8 def self.safe_user_roles DecidimAwesome.participatory_space_roles.filter(&:safe_constantize) end |
Instance Method Details
#present(html: true) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'app/models/decidim/decidim_awesome/paper_trail_version.rb', line 40 def present(html: true) @present ||= if item_type == "Decidim::UserBaseEntity" UserEntityPresenter.new(self, html:) elsif item_type.in?(PaperTrailVersion.safe_user_roles) ParticipatorySpaceRolePresenter.new(self, html:) else self end end |