Class: Decidim::DecidimAwesome::RoleBasePresenter
Instance Attribute Summary
#entry, #html
Instance Method Summary
collapse
#initialize, #item, #item_id, #item_type
Instance Method Details
#created_at ⇒ Object
62
63
64
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 62
def created_at
entry.changeset["created_at"]&.last || entry&.created_at
end
|
#created_date ⇒ Object
66
67
68
69
70
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 66
def created_date
I18n.l(created_at, format: :short)
rescue I18n::ArgumentError
""
end
|
#destroy_entry ⇒ Object
Also known as:
destroyed?
Finds the destroyed entry if exists
9
10
11
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 9
def destroy_entry
nil
end
|
#destroy_item ⇒ Object
try to reconstruct a destroyed event
16
17
18
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 16
def destroy_item
@destroy_item ||= destroy_entry&.reify
end
|
#destroyed_at ⇒ Object
72
73
74
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 72
def destroyed_at
destroy_entry&.created_at
end
|
#last_sign_in_date ⇒ Object
82
83
84
85
86
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 82
def last_sign_in_date
I18n.l(user&.last_sign_in_at, format: :short)
rescue I18n::ArgumentError
info_text("never_logged")
end
|
#participatory_space ⇒ Object
28
29
30
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 28
def participatory_space
nil
end
|
#participatory_space_name ⇒ Object
32
33
34
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 32
def participatory_space_name
participatory_space_type.present? ? "#{participatory_space_type} > #{translated_attribute participatory_space&.title}" : ""
end
|
#participatory_space_path ⇒ Object
try to link to the user roles page or to the participatory space if not existing
41
42
43
44
45
46
47
48
49
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 41
def participatory_space_path
proxy.send("#{participatory_space.manifest.route_name}_user_roles_path")
rescue NoMethodError
begin
proxy.send("#{participatory_space.manifest.route_name}_path", participatory_space)
rescue NoMethodError
""
end
end
|
#participatory_space_type ⇒ Object
36
37
38
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 36
def participatory_space_type
I18n.t(participatory_space&.manifest&.name, scope: "decidim.admin.menu") if participatory_space.present?
end
|
#removal_date ⇒ Object
76
77
78
79
80
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 76
def removal_date
I18n.l(destroyed_at, format: :short)
rescue I18n::ArgumentError
info_text("currently_active", klass: "text-success")
end
|
#role_name ⇒ Object
24
25
26
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 24
def role_name
raise "Please implement this method to return the role text"
end
|
#user ⇒ Object
20
21
22
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 20
def user
raise "Please implement this method to return the user object"
end
|
#user_email ⇒ Object
58
59
60
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 58
def user_email
user&.email || entry.changeset["email"]&.last
end
|
#user_name ⇒ Object
51
52
53
54
55
56
|
# File 'app/presenters/decidim/decidim_awesome/role_base_presenter.rb', line 51
def user_name
return I18n.t("missing_user", scope: "decidim.decidim_awesome.admin.admin_accountability") unless user
return I18n.t("deleted_user", scope: "decidim.decidim_awesome.admin.admin_accountability") if user.deleted?
user&.name
end
|