Class: Decidim::DecidimAwesome::PaperTrailVersionSerializer

Inherits:
Exporters::Serializer
  • Object
show all
Includes:
ApplicationHelper, ResourceHelper, TranslationsHelper
Defined in:
app/serializers/decidim/decidim_awesome/paper_trail_version_serializer.rb

Overview

This class serializes a AdminAccountability so can be exported to CSV, JSON or other formats.

Instance Method Summary collapse

Constructor Details

#initialize(log_entry) ⇒ PaperTrailVersionSerializer

Public: Initializes the serializer with a admin actions.



13
14
15
# File 'app/serializers/decidim/decidim_awesome/paper_trail_version_serializer.rb', line 13

def initialize(log_entry)
  @entry = log_entry.present(html: false)
end

Instance Method Details

#serializeObject

Public: Exports a hash with the serialized data for this admin action.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/serializers/decidim/decidim_awesome/paper_trail_version_serializer.rb', line 18

def serialize
  {
    role: entry.role_name,
    user_name: entry.user_name,
    user_email: entry.user_email,
    user_role_type: entry.entry.item_type,
    participatory_space_type: entry.participatory_space_type,
    participatory_space_title: translated_attribute(entry.participatory_space&.title),
    last_sign_in_at: entry.,
    role_created_at: entry.created_date,
    role_removed_at: entry.removal_date
  }
end