Class: Decidim::Assemblies::AssemblySerializer

Inherits:
Exporters::Serializer show all
Includes:
Decidim::ApplicationHelper, ResourceHelper, TranslationsHelper
Defined in:
decidim-assemblies/app/serializers/decidim/assemblies/assembly_serializer.rb

Overview

This class serializes an Assembly so it can be exported to CSV, JSON or other formats.

Instance Method Summary collapse

Methods included from TranslationsHelper

empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?

Methods included from TranslatableAttributes

#default_locale?

Methods included from ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #linked_resources_for, #resource_locator, #resource_title

Methods included from Decidim::ApplicationHelper

#cell, #edit_link, #extra_admin_link, #html_truncate, #present, #resolve_presenter_class, #step_cta_url

Methods included from CacheHelper

#cache

Methods included from Decidim::AmendmentsHelper

#accept_and_reject_buttons_for, #action_button_card_for, #allowed_to_accept_and_reject?, #allowed_to_promote?, #amend_button_for, #amenders_list_for, #amendments_enabled?, #amendments_for, #amendments_form_field_for, #amendments_form_fields_label, #amendments_form_fields_value, #can_participate_in_private_space?, #can_react_to_emendation?, #emendation_actions_for, #emendation_announcement_for, #promote_button_for, #render_emendation_body

Methods included from RichTextEditorHelper

included, #text_editor_for

Methods included from ContextualHelpHelper

#floating_help

Methods included from ScopesHelper

#has_visible_scopes?, #scope_name_for_picker, #scopes_picker_field, #scopes_picker_filter, #scopes_picker_tag

Methods included from DecidimFormHelper

#areas_for_select, #base_error_messages, #decidim_form_for, #decidim_form_slug_url, #editor_field_tag, #form_field_has_error?, #form_required_explanation, #name_with_locale, #scopes_picker_field_tag, #tab_element_class_for, #translated_field_tag

Methods included from OmniauthHelper

#normalize_provider_name, #oauth_icon, #provider_name

Methods inherited from Exporters::Serializer

#event_name, #finalize, #run

Constructor Details

#initialize(assembly) ⇒ AssemblySerializer

Public: Initializes the serializer with a assembly.


12
13
14
# File 'decidim-assemblies/app/serializers/decidim/assemblies/assembly_serializer.rb', line 12

def initialize(assembly)
  @assembly = assembly
end

Instance Method Details

#serializeObject

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


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'decidim-assemblies/app/serializers/decidim/assemblies/assembly_serializer.rb', line 17

def serialize
  {
    id: assembly.id,
    slug: assembly.slug,
    hashtag: assembly.hashtag,
    decidim_organization_id: assembly.decidim_organization_id,
    title: assembly.title,
    subtitle: assembly.subtitle,
    weight: assembly.weight,
    short_description: assembly.short_description,
    description: assembly.description,
    remote_hero_image_url: Decidim::Assemblies::AssemblyPresenter.new(assembly).hero_image_url,
    remote_banner_image_url: Decidim::Assemblies::AssemblyPresenter.new(assembly).banner_image_url,
    promoted: assembly.promoted,
    developer_group: assembly.developer_group,
    meta_scope: assembly.meta_scope,
    local_area: assembly.local_area,
    target: assembly.target,
    decidim_scope_id: assembly.decidim_scope_id,
    paticipatory_scope: assembly.participatory_scope,
    participatory_structure: assembly.participatory_structure,
    show_statistics: assembly.show_statistics,
    scopes_enabled: assembly.scopes_enabled,
    private_space: assembly.private_space,
    reference: assembly.reference,
    purpose_of_action: assembly.purpose_of_action,
    composition: assembly.composition,
    duration: assembly.duration,
    participatory_scope: assembly.participatory_scope,
    included_at: assembly.included_at,
    closing_date: assembly.closing_date,
    created_by: assembly.created_by,
    creation_date: assembly.creation_date,
    closing_date_reason: assembly.closing_date_reason,
    internal_organisation: assembly.internal_organisation,
    is_transparent: assembly.is_transparent,
    special_features: assembly.special_features,
    twitter_handler: assembly.twitter_handler,
    instagram_handler: assembly.instagram_handler,
    facebook_handler: assembly.facebook_handler,
    youtube_handler: assembly.youtube_handler,
    github_handler: assembly.github_handler,
    created_by_other: assembly.created_by_other,
    decidim_assemblies_type_id: assembly.decidim_assemblies_type_id,
    area: {
      id: assembly.area.try(:id),
      name: assembly.area.try(:name) || empty_translatable
    },
    scope: {
      id: assembly.scope.try(:id),
      name: assembly.scope.try(:name) || empty_translatable
    },

    assembly_categories: serialize_categories,
    attachments: {
      attachment_collections: serialize_attachment_collections,
      files: serialize_attachments
    },
    components: serialize_components,
    announcement: assembly.announcement
  }
end