decidim-core 0.23.6 → 0.24.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/images/decidim/icons.svg +1 -1
- data/app/assets/javascripts/decidim/core/bundle.js +1 -1
- data/app/assets/javascripts/decidim/core/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/editor/history_override.js.es6 +117 -0
- data/app/assets/javascripts/decidim/editor/linebreak_module.js.es6 +83 -0
- data/app/assets/javascripts/decidim/editor/modified_backspace_offset1.js.es6 +98 -0
- data/app/assets/javascripts/decidim/editor/modified_backspace_offset_any.js.es6 +48 -0
- data/app/assets/javascripts/decidim/editor/modified_backspace_utils.js.es6 +31 -0
- data/app/assets/javascripts/decidim/editor/modified_enter.js.es6 +118 -0
- data/app/assets/javascripts/decidim/editor.js.es6 +15 -4
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +25 -0
- data/app/assets/javascripts/decidim/geocoding/attach_input.js.es6 +41 -4
- data/app/assets/javascripts/decidim/input_character_counter.js.es6 +6 -1
- data/app/assets/javascripts/decidim/map/controller/markers.js.es6 +27 -9
- data/app/assets/javascripts/decidim/session_timeouter.js.es6 +78 -0
- data/app/assets/javascripts/decidim.js.es6 +1 -0
- data/app/assets/stylesheets/decidim/_variables.scss +9 -0
- data/app/assets/stylesheets/decidim/email.scss +14 -2
- data/app/assets/stylesheets/decidim/extras/_external-links.scss +0 -1
- data/app/assets/stylesheets/decidim/extras/_process_stats.scss +1 -1
- data/app/assets/stylesheets/decidim/extras/_results-per-page.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +2 -2
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +2 -2
- data/app/assets/stylesheets/decidim/modules/_cards.scss +18 -1
- data/app/assets/stylesheets/decidim/modules/_collapsible-list.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_comments.scss +5 -1
- data/app/assets/stylesheets/decidim/modules/_conference-speaker.scss +4 -3
- data/app/assets/stylesheets/decidim/modules/_data-picker.scss +7 -0
- data/app/assets/stylesheets/decidim/modules/_extra.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_forms.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_loading-spinner.scss +34 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_opinion-toggle.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_reveal.scss +6 -0
- data/app/assets/stylesheets/decidim/modules/_signup.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/{_process-stats.scss → _space-stats.scss} +1 -1
- data/app/cells/decidim/activity/show.erb +1 -1
- data/app/cells/decidim/activity_cell.rb +11 -14
- data/app/cells/decidim/address/details.erb +5 -5
- data/app/cells/decidim/address_cell.rb +0 -21
- data/app/cells/decidim/announcement/show.erb +4 -4
- data/app/cells/decidim/announcement_cell.rb +22 -2
- data/app/cells/decidim/author/flag_user.erb +10 -0
- data/app/cells/decidim/author/profile_minicard.erb +1 -1
- data/app/cells/decidim/author_cell.rb +9 -1
- data/app/cells/decidim/card_m/top.erb +1 -1
- data/app/cells/decidim/card_m_cell.rb +1 -1
- data/app/cells/decidim/content_blocks/cta/show.erb +14 -0
- data/app/cells/decidim/content_blocks/cta_cell.rb +35 -0
- data/app/cells/decidim/content_blocks/cta_settings_form/show.erb +9 -0
- data/app/cells/decidim/content_blocks/cta_settings_form_cell.rb +13 -0
- data/app/cells/decidim/content_blocks/hero_cell.rb +14 -0
- data/app/cells/decidim/content_blocks/highlighted_elements/elements.erb +0 -0
- data/app/cells/decidim/content_blocks/highlighted_elements/heading.erb +0 -0
- data/app/cells/decidim/content_blocks/highlighted_elements/show.erb +4 -0
- data/app/cells/decidim/content_blocks/highlighted_elements_cell.rb +51 -0
- data/app/cells/decidim/content_blocks/highlighted_elements_settings_form/show.erb +3 -0
- data/app/cells/decidim/content_blocks/highlighted_elements_settings_form_cell.rb +28 -0
- data/app/cells/decidim/content_blocks/last_activity_cell.rb +11 -0
- data/app/cells/decidim/content_blocks/metrics_cell.rb +0 -6
- data/app/cells/decidim/content_blocks/stats_cell.rb +0 -6
- data/app/cells/decidim/date/show.erb +31 -0
- data/app/cells/decidim/date_cell.rb +50 -0
- data/app/cells/decidim/endorsement_buttons_cell.rb +3 -3
- data/app/cells/decidim/flag_modal/flag_user.erb +24 -0
- data/app/cells/decidim/flag_modal/show.erb +24 -0
- data/app/cells/decidim/flag_modal_cell.rb +25 -0
- data/app/cells/decidim/profile/inaccessible.erb +9 -0
- data/app/cells/decidim/profile_cell.rb +9 -1
- data/app/cells/decidim/profile_sidebar/show.erb +10 -1
- data/app/cells/decidim/profile_sidebar_cell.rb +1 -0
- data/app/cells/decidim/reported_content/show.erb +5 -0
- data/app/cells/decidim/reported_content_cell.rb +44 -0
- data/app/cells/decidim/scopes_picker/scope_picker_prompt.erb +3 -0
- data/app/cells/decidim/scopes_picker/scope_picker_values.erb +5 -0
- data/app/cells/decidim/scopes_picker/show.erb +14 -0
- data/app/cells/decidim/scopes_picker_cell.rb +93 -0
- data/app/cells/decidim/tos_page/announcement.erb +1 -1
- data/app/cells/decidim/tos_page/form.erb +15 -13
- data/app/cells/decidim/tos_page_cell.rb +10 -8
- data/app/cells/decidim/translation_bar_cell.rb +1 -1
- data/app/cells/decidim/user_conversation/conversation_header.erb +1 -1
- data/app/cells/decidim/user_conversations_cell.rb +1 -1
- data/app/commands/decidim/create_report.rb +11 -1
- data/app/commands/decidim/create_user_report.rb +67 -0
- data/app/commands/decidim/destroy_account.rb +0 -2
- data/app/commands/decidim/gallery_methods.rb +2 -2
- data/app/commands/decidim/multiple_attachments_methods.rb +14 -10
- data/app/commands/decidim/search.rb +5 -2
- data/app/commands/decidim/update_notifications_settings.rb +1 -0
- data/app/commands/decidim/update_user_group.rb +1 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +1 -1
- data/app/controllers/concerns/decidim/flaggable.rb +5 -1
- data/app/controllers/concerns/decidim/force_authentication.rb +11 -3
- data/app/controllers/concerns/decidim/locale_switcher.rb +5 -0
- data/app/controllers/concerns/decidim/needs_permission.rb +7 -1
- data/app/controllers/concerns/decidim/orderable.rb +3 -1
- data/app/controllers/concerns/decidim/user_blocked_checker.rb +26 -0
- data/app/controllers/decidim/application_controller.rb +22 -0
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +3 -1
- data/app/controllers/decidim/devise/sessions_controller.rb +10 -6
- data/app/controllers/decidim/errors_controller.rb +1 -1
- data/app/controllers/decidim/locales_controller.rb +1 -1
- data/app/controllers/decidim/profiles_controller.rb +6 -0
- data/app/controllers/decidim/report_users_controller.rb +42 -0
- data/app/controllers/decidim/scopes_controller.rb +19 -10
- data/app/controllers/decidim/timeouts_controller.rb +28 -0
- data/app/controllers/decidim/user_activities_controller.rb +5 -0
- data/app/controllers/decidim/user_timeline_controller.rb +1 -0
- data/app/events/decidim/demoted_membership_event.rb +2 -2
- data/app/events/decidim/invited_to_group_event.rb +2 -2
- data/app/events/decidim/join_request_accepted_event.rb +2 -2
- data/app/events/decidim/join_request_created_event.rb +2 -2
- data/app/events/decidim/join_request_rejected_event.rb +2 -2
- data/app/events/decidim/promoted_to_admin_event.rb +2 -2
- data/app/events/decidim/removed_from_group_event.rb +2 -2
- data/app/forms/decidim/account_form.rb +2 -2
- data/app/forms/decidim/invite_user_form.rb +2 -2
- data/app/forms/decidim/messaging/conversation_form.rb +1 -1
- data/app/forms/decidim/messaging/message_form.rb +1 -1
- data/app/forms/decidim/notifications_settings_form.rb +20 -0
- data/app/forms/url_validator.rb +20 -0
- data/app/helpers/decidim/action_authorization_helper.rb +2 -0
- data/app/helpers/decidim/application_helper.rb +1 -3
- data/app/helpers/decidim/cells_helper.rb +6 -0
- data/app/helpers/decidim/filters_helper.rb +9 -0
- data/app/helpers/decidim/messaging/conversation_helper.rb +11 -1
- data/app/helpers/decidim/newsletters_helper.rb +7 -9
- data/app/helpers/decidim/scopes_helper.rb +1 -1
- data/app/jobs/decidim/block_user_job.rb +11 -0
- data/app/jobs/decidim/export_job.rb +2 -2
- data/app/jobs/decidim/find_and_update_descendants_job.rb +48 -0
- data/app/jobs/decidim/machine_translation_resource_job.rb +3 -0
- data/app/jobs/decidim/machine_translation_save_job.rb +29 -0
- data/app/jobs/decidim/update_search_indexes_job.rb +11 -0
- data/app/jobs/decidim/user_report_job.rb +11 -0
- data/app/mailers/decidim/block_user_mailer.rb +21 -0
- data/app/mailers/decidim/reported_mailer.rb +33 -3
- data/app/mailers/decidim/user_report_mailer.rb +21 -0
- data/app/models/decidim/area.rb +0 -1
- data/app/models/decidim/area_type.rb +1 -1
- data/app/models/decidim/attachment.rb +3 -2
- data/app/models/decidim/attachment_collection.rb +1 -1
- data/app/models/decidim/authorization.rb +4 -0
- data/app/models/decidim/category.rb +6 -1
- data/app/models/decidim/impersonation_log.rb +5 -7
- data/app/models/decidim/metric.rb +2 -2
- data/app/models/decidim/moderation.rb +12 -0
- data/app/models/decidim/organization.rb +5 -1
- data/app/models/decidim/scope.rb +5 -2
- data/app/models/decidim/scope_type.rb +1 -1
- data/app/models/decidim/share_token.rb +1 -1
- data/app/models/decidim/static_page.rb +11 -1
- data/app/models/decidim/static_page_topic.rb +4 -0
- data/app/models/decidim/user.rb +13 -8
- data/app/models/decidim/user_base_entity.rb +13 -13
- data/app/models/decidim/user_block.rb +10 -0
- data/app/models/decidim/user_group.rb +1 -4
- data/app/models/decidim/user_moderation.rb +22 -0
- data/app/models/decidim/user_report.rb +31 -0
- data/app/permissions/decidim/permissions.rb +1 -3
- data/app/permissions/decidim/report_user_permissions.rb +13 -0
- data/app/presenters/decidim/admin_log/impersonation_log_presenter.rb +39 -0
- data/app/presenters/decidim/admin_log/organization_presenter.rb +1 -2
- data/app/presenters/decidim/admin_log/user_moderation_presenter.rb +63 -0
- data/app/presenters/decidim/admin_log/user_presenter.rb +18 -9
- data/app/presenters/decidim/home_stats_presenter.rb +3 -3
- data/app/presenters/decidim/log/diff_presenter.rb +4 -3
- data/app/presenters/decidim/log/resource_presenter.rb +4 -4
- data/app/presenters/decidim/log/user_presenter.rb +1 -1
- data/app/presenters/decidim/menu_presenter.rb +12 -7
- data/app/presenters/decidim/nil_presenter.rb +0 -2
- data/app/presenters/decidim/user_presenter.rb +1 -1
- data/app/queries/decidim/metrics/blocked_users_metric_manage.rb +26 -0
- data/app/queries/decidim/metrics/followers_metric_manage.rb +3 -0
- data/app/queries/decidim/metrics/participants_metric_manage.rb +3 -0
- data/app/queries/decidim/metrics/reported_users_metric_manage.rb +26 -0
- data/app/queries/decidim/metrics/user_reports_metric_manage.rb +26 -0
- data/app/queries/decidim/user_groups/accepted_memberships.rb +1 -1
- data/app/queries/decidim/user_groups/admin_memberships.rb +1 -1
- data/app/queries/decidim/user_groups/member_memberships.rb +1 -1
- data/app/services/decidim/activity_search.rb +1 -3
- data/app/services/decidim/base_diff_renderer.rb +1 -1
- data/app/services/decidim/data_portability_exporter.rb +1 -0
- data/app/services/decidim/email_notification_generator.rb +2 -2
- data/app/services/decidim/events_manager.rb +1 -1
- data/app/services/decidim/open_data_exporter.rb +36 -7
- data/app/services/decidim/zip_stream/zip_stream_writer.rb +3 -3
- data/app/uploaders/decidim/application_uploader.rb +22 -2
- data/app/uploaders/decidim/attachment_uploader.rb +2 -4
- data/app/uploaders/decidim/downloader.rb +9 -0
- data/app/uploaders/decidim/image_uploader.rb +9 -21
- data/app/uploaders/decidim/open_data_uploader.rb +5 -0
- data/app/uploaders/decidim/record_image_uploader.rb +2 -2
- data/app/validators/etiquette_validator.rb +0 -7
- data/app/validators/uploader_content_type_validator.rb +4 -2
- data/app/views/decidim/application/_document.html.erb +1 -1
- data/app/views/decidim/block_user_mailer/notify.html.erb +7 -0
- data/app/views/decidim/devise/confirmations/new.html.erb +1 -1
- data/app/views/decidim/devise/registrations/edit.html.erb +1 -1
- data/app/views/decidim/devise/unlocks/new.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/_conversation.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/_messages.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/_show.html.erb +4 -4
- data/app/views/decidim/notifications_settings/show.html.erb +11 -0
- data/app/views/decidim/pages/_standalone.html.erb +3 -1
- data/app/views/decidim/reported_mailer/report.html.erb +9 -17
- data/app/views/decidim/shared/_check_boxes_tree.html.erb +3 -3
- data/app/views/decidim/shared/_component_announcement.html.erb +2 -2
- data/app/views/decidim/shared/participatory_space_filters/_filters.html.erb +1 -1
- data/app/views/decidim/user_report_mailer/notify.html.erb +7 -0
- data/app/views/decidim/widgets/_data_picker.html.erb +1 -1
- data/app/views/layouts/decidim/_application.html.erb +1 -0
- data/app/views/layouts/decidim/_js_configuration.html.erb +1 -1
- data/app/views/layouts/decidim/_main_footer.html.erb +6 -4
- data/app/views/layouts/decidim/_timeout_modal.html.erb +21 -0
- data/config/initializers/active_support.rb +7 -0
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/omniauth.rb +1 -1
- data/config/locales/ar.yml +1 -7
- data/config/locales/bg.yml +1 -13
- data/config/locales/ca.yml +46 -17
- data/config/locales/cs.yml +118 -53
- data/config/locales/de.yml +83 -18
- data/config/locales/el.yml +1 -14
- data/config/locales/en.yml +79 -14
- data/config/locales/eo.yml +0 -1
- data/config/locales/es-MX.yml +31 -14
- data/config/locales/es-PY.yml +31 -14
- data/config/locales/es.yml +34 -17
- data/config/locales/eu.yml +4 -10
- data/config/locales/fi-plain.yml +80 -16
- data/config/locales/fi.yml +85 -21
- data/config/locales/fr-CA.yml +79 -14
- data/config/locales/fr.yml +76 -11
- data/config/locales/gl.yml +1 -15
- data/config/locales/hu.yml +1 -12
- data/config/locales/id-ID.yml +1 -7
- data/config/locales/is-IS.yml +0 -9
- data/config/locales/it.yml +72 -19
- data/config/locales/ja.yml +1 -14
- data/config/locales/lv.yml +1 -12
- data/config/locales/nl.yml +38 -13
- data/config/locales/no.yml +7 -14
- data/config/locales/pl.yml +81 -14
- data/config/locales/pt-BR.yml +1 -7
- data/config/locales/pt.yml +1 -14
- data/config/locales/ro-RO.yml +15 -25
- data/config/locales/ru.yml +7 -12
- data/config/locales/sk.yml +2 -13
- data/config/locales/sr-CS.yml +0 -9
- data/config/locales/sv.yml +5 -27
- data/config/locales/tr-TR.yml +65 -14
- data/config/locales/uk.yml +7 -9
- data/config/locales/zh-CN.yml +1 -14
- data/config/routes.rb +9 -4
- data/db/migrate/20170713131206_add_admin_to_users.rb +1 -1
- data/db/migrate/20180206143340_fix_reference_for_all_resources.rb +2 -0
- data/db/migrate/20180314085339_rename_maximum_votes_per_proposal_to_threshold_per_proposal.rb +2 -2
- data/db/migrate/20200929171508_remove_show_statistics_from_organizations.rb +7 -0
- data/db/migrate/20201010124755_create_decidim_user_moderations.rb +12 -0
- data/db/migrate/20201010124756_create_decidim_user_reports.rb +16 -0
- data/db/migrate/20201010224433_add_suspension_fields_to_decidim_users.rb +8 -0
- data/db/migrate/20201011074641_create_decidim_user_suspensions.rb +14 -0
- data/db/migrate/20201011081626_add_current_suspension_id_to_decidim_users.rb +7 -0
- data/db/migrate/20201013071533_add_reported_content_to_moderations.rb +7 -0
- data/db/migrate/20201019074554_add_locale_to_moderation_reports.rb +7 -0
- data/db/migrate/20201127114444_encrypt_authorization_metadatas.rb +35 -0
- data/db/migrate/20201128130723_add_allow_public_access_to_static_pages.rb +17 -0
- data/db/migrate/20201218144706_update_table_block_user_functionality.rb +8 -0
- data/db/migrate/20201218145252_rename_decidim_user_fields_for_block_functionality.rb +9 -0
- data/db/migrate/20210208134328_add_email_on_moderations_to_users.rb +7 -0
- data/db/seeds.rb +14 -13
- data/lib/decidim/amendable.rb +3 -2
- data/{app/functions/decidim/core → lib/decidim/api/functions}/component_finder_base.rb +1 -1
- data/{app/functions/decidim/core → lib/decidim/api/functions}/component_list.rb +4 -4
- data/{app/functions/decidim/core → lib/decidim/api/functions}/component_list_base.rb +3 -1
- data/lib/decidim/api/functions/needs_api_default_order.rb +24 -0
- data/{app/functions/decidim/core → lib/decidim/api/functions}/needs_api_filter_and_order.rb +0 -0
- data/{app/functions/decidim/core → lib/decidim/api/functions}/participatory_space_finder_base.rb +2 -2
- data/{app/functions/decidim/core → lib/decidim/api/functions}/participatory_space_list_base.rb +3 -1
- data/{app/functions/decidim/core → lib/decidim/api/functions}/user_entity_finder.rb +1 -4
- data/{app/functions/decidim/core → lib/decidim/api/functions}/user_entity_list.rb +1 -3
- data/{app/types/decidim/core → lib/decidim/api/input_filters}/base_input_filter.rb +0 -0
- data/{app/types/decidim/core → lib/decidim/api/input_filters}/component_input_filter.rb +20 -22
- data/{app/types/decidim/core → lib/decidim/api/input_filters}/has_hastaggable_input_filter.rb +1 -1
- data/{app/types/decidim/core → lib/decidim/api/input_filters}/has_localized_input_filter.rb +3 -3
- data/{app/types/decidim/core → lib/decidim/api/input_filters}/has_publishable_input_filter.rb +6 -6
- data/{app/types/decidim/core → lib/decidim/api/input_filters}/has_timestamp_input_filter.rb +12 -12
- data/{app/types/decidim/core → lib/decidim/api/input_filters}/participatory_space_input_filter.rb +0 -1
- data/lib/decidim/api/input_filters/user_entity_input_filter.rb +89 -0
- data/{app/types/decidim/core → lib/decidim/api/input_sorts}/base_input_sort.rb +3 -2
- data/{app/types/decidim/core → lib/decidim/api/input_sorts}/component_input_sort.rb +10 -11
- data/{app/types/decidim/core → lib/decidim/api/input_sorts}/has_endorsable_input_sort.rb +2 -4
- data/{app/types/decidim/core → lib/decidim/api/input_sorts}/has_localized_input_sort.rb +3 -3
- data/{app/types/decidim/core → lib/decidim/api/input_sorts}/has_publishable_input_sort.rb +1 -1
- data/lib/decidim/api/input_sorts/has_timestamp_input_sort.rb +12 -0
- data/{app/types/decidim/core → lib/decidim/api/input_sorts}/participatory_space_input_sort.rb +1 -1
- data/{app/types/decidim/core → lib/decidim/api/input_sorts}/user_entity_input_sort.rb +4 -4
- data/lib/decidim/api/{amendable_entity_interface.rb → interfaces/amendable_entity_interface.rb} +5 -5
- data/lib/decidim/api/interfaces/amendable_interface.rb +17 -0
- data/lib/decidim/api/{attachable_interface.rb → interfaces/attachable_interface.rb} +3 -3
- data/lib/decidim/api/interfaces/author_interface.rb +32 -0
- data/lib/decidim/api/interfaces/authorable_interface.rb +23 -0
- data/lib/decidim/api/{categorizable_interface.rb → interfaces/categorizable_interface.rb} +3 -3
- data/lib/decidim/api/interfaces/coauthorable_interface.rb +30 -0
- data/lib/decidim/api/interfaces/component_interface.rb +22 -0
- data/lib/decidim/api/interfaces/endorsable_interface.rb +19 -0
- data/lib/decidim/api/{fingerprint_interface.rb → interfaces/fingerprint_interface.rb} +3 -3
- data/lib/decidim/api/interfaces/participatory_space_interface.rb +48 -0
- data/lib/decidim/api/interfaces/participatory_space_resourceable_interface.rb +25 -0
- data/lib/decidim/api/{scopable_interface.rb → interfaces/scopable_interface.rb} +3 -3
- data/lib/decidim/api/interfaces/timestamps_interface.rb +15 -0
- data/lib/decidim/api/interfaces/traceable_interface.rb +14 -0
- data/lib/decidim/api/scalars/date_time_type.rb +17 -0
- data/lib/decidim/api/scalars/date_type.rb +17 -0
- data/lib/decidim/api/types/amendment_type.rb +19 -0
- data/lib/decidim/api/types/area_api_type.rb +16 -0
- data/lib/decidim/api/types/area_type_type.rb +13 -0
- data/lib/decidim/api/types/attachment_type.rb +13 -0
- data/lib/decidim/api/types/category_type.rb +14 -0
- data/{app/types/decidim/core → lib/decidim/api/types}/component_type.rb +2 -4
- data/lib/decidim/api/types/coordinates_type.rb +21 -0
- data/lib/decidim/api/types/decidim_type.rb +13 -0
- data/lib/decidim/api/types/fingerprint_type.rb +12 -0
- data/lib/decidim/api/types/hashtag_type.rb +13 -0
- data/lib/decidim/api/types/localized_string_type.rb +13 -0
- data/lib/decidim/api/types/metric_history_type.rb +18 -0
- data/lib/decidim/api/types/metric_type.rb +13 -0
- data/lib/decidim/api/types/organization_type.rb +17 -0
- data/lib/decidim/api/types/participatory_space_link_type.rb +22 -0
- data/lib/decidim/api/types/participatory_space_type.rb +10 -0
- data/lib/decidim/api/types/scope_api_type.rb +16 -0
- data/lib/decidim/api/types/session_type.rb +22 -0
- data/lib/decidim/api/types/statistic_type.rb +20 -0
- data/lib/decidim/api/types/trace_version_type.rb +21 -0
- data/lib/decidim/api/types/translated_field_type.rb +36 -0
- data/lib/decidim/api/types/user_group_type.rb +64 -0
- data/lib/decidim/api/types/user_type.rb +67 -0
- data/lib/decidim/attachment_attributes.rb +57 -0
- data/lib/decidim/attributes/clean_string.rb +37 -0
- data/lib/decidim/attributes.rb +1 -0
- data/lib/decidim/coauthorable.rb +3 -3
- data/lib/decidim/component_manifest.rb +17 -0
- data/lib/decidim/content_block_manifest.rb +1 -1
- data/lib/decidim/content_parsers/hashtag_parser.rb +3 -6
- data/lib/decidim/content_parsers/user_group_parser.rb +2 -5
- data/lib/decidim/content_parsers/user_parser.rb +2 -5
- data/lib/decidim/content_processor.rb +1 -1
- data/lib/decidim/content_renderers/hashtag_renderer.rb +3 -6
- data/lib/decidim/core/api.rb +71 -16
- data/lib/decidim/core/engine.rb +35 -6
- data/lib/decidim/core/test/factories.rb +53 -15
- data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/amendable/amendment_accepted_event_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/amendable/amendment_promoted_event_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/amendable/amendment_rejected_event_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/categorizable_interface_examples.rb +6 -14
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +11 -9
- data/lib/decidim/core/test/shared_examples/component_type.rb +1 -1
- data/lib/decidim/core/test/shared_examples/controller_render_views.rb +28 -0
- data/lib/decidim/core/test/shared_examples/follows_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/logo_email.rb +1 -1
- data/lib/decidim/core/test/shared_examples/map_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/process_announcements_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/reportable.rb +8 -0
- data/lib/decidim/core/test/shared_examples/rich_text_editor_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/searchable_participatory_space_examples.rb +2 -3
- data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +46 -0
- data/lib/decidim/core/test/shared_examples/static_pages_examples.rb +43 -0
- data/lib/decidim/core/test.rb +2 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +11 -3
- data/lib/decidim/diffy_extension.rb +2 -2
- data/lib/decidim/exporters/csv.rb +3 -2
- data/lib/decidim/exporters/export_data.rb +1 -1
- data/lib/decidim/faker/internet.rb +17 -0
- data/lib/decidim/faker/localized.rb +43 -20
- data/lib/decidim/file_validator_humanizer.rb +6 -4
- data/lib/decidim/form_builder.rb +33 -22
- data/lib/decidim/gamification/badge_scorer.rb +3 -2
- data/lib/decidim/gamification/base_event.rb +2 -2
- data/lib/decidim/geocodable.rb +2 -0
- data/lib/decidim/has_category.rb +1 -1
- data/lib/decidim/has_private_users.rb +1 -1
- data/lib/decidim/importers/import_manifest.rb +36 -0
- data/lib/decidim/map/autocomplete.rb +11 -1
- data/lib/decidim/metric_operation.rb +5 -6
- data/lib/decidim/participatory_space_resourceable.rb +1 -3
- data/lib/decidim/query_extensions.rb +90 -69
- data/lib/decidim/randomable.rb +6 -1
- data/lib/decidim/record_encryptor.rb +131 -0
- data/lib/decidim/reportable.rb +26 -0
- data/lib/decidim/resource_manifest.rb +3 -0
- data/lib/decidim/resourceable.rb +6 -6
- data/lib/decidim/scopable.rb +1 -1
- data/lib/decidim/search_resource_fields_mapper.rb +1 -1
- data/lib/decidim/searchable.rb +9 -0
- data/lib/decidim/settings_manifest.rb +2 -1
- data/lib/decidim/shareable_with_token.rb +0 -1
- data/lib/decidim/translatable_attributes.rb +2 -1
- data/lib/decidim/translatable_resource.rb +10 -0
- data/lib/decidim/user_reportable.rb +33 -0
- data/lib/decidim/view_model.rb +26 -0
- data/lib/premailer/adapter/decidim.rb +4 -4
- data/lib/tasks/decidim_data_portability_tasks.rake +4 -4
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ko.js +18 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.vi.js +14 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.zh-CN.js +14 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.zh-TW.js +14 -0
- metadata +190 -95
- data/app/functions/decidim/core/participatory_space_finder.rb +0 -11
- data/app/functions/decidim/core/participatory_space_list.rb +0 -11
- data/app/helpers/decidim/cache_helper.rb +0 -14
- data/app/types/decidim/core/amendment_type.rb +0 -26
- data/app/types/decidim/core/area_api_type.rb +0 -16
- data/app/types/decidim/core/area_type_type.rb +0 -14
- data/app/types/decidim/core/attachment_type.rb +0 -14
- data/app/types/decidim/core/category_type.rb +0 -16
- data/app/types/decidim/core/coordinates_type.rb +0 -19
- data/app/types/decidim/core/date_time_type.rb +0 -12
- data/app/types/decidim/core/date_type.rb +0 -13
- data/app/types/decidim/core/decidim_type.rb +0 -19
- data/app/types/decidim/core/fingerprint_type.rb +0 -15
- data/app/types/decidim/core/has_timestamp_input_sort.rb +0 -12
- data/app/types/decidim/core/hashtag_type.rb +0 -13
- data/app/types/decidim/core/localized_string_type.rb +0 -14
- data/app/types/decidim/core/metric_history_type.rb +0 -17
- data/app/types/decidim/core/metric_type.rb +0 -14
- data/app/types/decidim/core/organization_type.rb +0 -20
- data/app/types/decidim/core/participatory_space_link_type.rb +0 -24
- data/app/types/decidim/core/participatory_space_type.rb +0 -12
- data/app/types/decidim/core/scope_api_type.rb +0 -16
- data/app/types/decidim/core/session_type.rb +0 -19
- data/app/types/decidim/core/statistic_type.rb +0 -22
- data/app/types/decidim/core/trace_version_type.rb +0 -29
- data/app/types/decidim/core/translated_field_type.rb +0 -45
- data/app/types/decidim/core/user_entity_input_filter.rb +0 -81
- data/app/types/decidim/core/user_group_type.rb +0 -51
- data/app/types/decidim/core/user_type.rb +0 -52
- data/app/views/decidim/shared/_announcement.html.erb +0 -1
- data/app/views/decidim/shared/_flag_modal.html.erb +0 -20
- data/db/migrate/20210302150803_invalidate_all_sessions_for_deleted_users.rb +0 -11
- data/lib/decidim/api/amendable_interface.rb +0 -18
- data/lib/decidim/api/author_interface.rb +0 -29
- data/lib/decidim/api/authorable_interface.rb +0 -22
- data/lib/decidim/api/coauthorable_interface.rb +0 -29
- data/lib/decidim/api/component_interface.rb +0 -20
- data/lib/decidim/api/endorsable_interface.rb +0 -22
- data/lib/decidim/api/participatory_space_interface.rb +0 -47
- data/lib/decidim/api/participatory_space_resourceable_interface.rb +0 -21
- data/lib/decidim/api/timestamps_interface.rb +0 -21
- data/lib/decidim/api/traceable_interface.rb +0 -14
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "decidim/api/component_interface"
|
4
|
-
require "decidim/api/participatory_space_interface"
|
5
|
-
|
6
3
|
module Decidim
|
7
4
|
# This module's job is to extend the API with custom fields related to
|
8
5
|
# decidim-core.
|
@@ -12,91 +9,115 @@ module Decidim
|
|
12
9
|
# type - A GraphQL::BaseType to extend.
|
13
10
|
#
|
14
11
|
# Returns nothing.
|
15
|
-
def self.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
type.field participatory_space_manifest.name.to_s.singularize.camelize(:lower),
|
23
|
-
type: participatory_space_manifest.query_type.constantize,
|
24
|
-
description: "Finds a #{participatory_space_manifest.name.to_s.singularize}",
|
25
|
-
function: participatory_space_manifest.query_finder.constantize.new(manifest: participatory_space_manifest)
|
12
|
+
def self.included(type)
|
13
|
+
type.field :participatory_processes,
|
14
|
+
[Decidim::ParticipatoryProcesses::ParticipatoryProcessType],
|
15
|
+
null: true,
|
16
|
+
description: "Lists all participatory_processes" do
|
17
|
+
argument :filter, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputFilter, "This argument let's you filter the results", required: false
|
18
|
+
argument :order, Decidim::ParticipatoryProcesses::ParticipatoryProcessInputSort, "This argument let's you order the results", required: false
|
26
19
|
end
|
27
20
|
|
28
|
-
type.field :
|
29
|
-
|
30
|
-
|
21
|
+
type.field :participatory_process,
|
22
|
+
Decidim::ParticipatoryProcesses::ParticipatoryProcessType,
|
23
|
+
null: true,
|
24
|
+
description: "Finds a participatory_process" do
|
25
|
+
argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false
|
26
|
+
argument :slug, String, "The slug of the participatory process", required: false
|
27
|
+
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
29
|
+
type.field :component, Decidim::Core::ComponentInterface, null: true do
|
30
|
+
description "Lists the components this space contains."
|
31
|
+
argument :id, GraphQL::Types::ID, required: true, description: "The ID of the component to be found"
|
36
32
|
end
|
37
33
|
|
38
|
-
type.field :session
|
39
|
-
type Core::SessionType
|
40
|
-
description "Return's information about the logged in user"
|
34
|
+
type.field :session, Core::SessionType, description: "Return's information about the logged in user", null: true
|
41
35
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
36
|
+
type.field :decidim, Core::DecidimType, "Decidim's framework properties.", null: true
|
37
|
+
|
38
|
+
type.field :organization, Core::OrganizationType, "The current organization", null: true
|
46
39
|
|
47
|
-
type.field :
|
48
|
-
|
40
|
+
type.field :hashtags, [Core::HashtagType], null: true, description: "The hashtags for current organization" do
|
41
|
+
argument :name, GraphQL::Types::String, "The name of the hashtag", required: false
|
49
42
|
end
|
50
43
|
|
51
|
-
type.field :
|
52
|
-
|
44
|
+
type.field :metrics, type: [Decidim::Core::MetricType], null: true do
|
45
|
+
argument :names, [GraphQL::Types::String], "The names of the metrics you want to retrieve", camelize: false, required: false
|
46
|
+
argument :space_type, GraphQL::Types::String, "The type of ParticipatorySpace you want to filter with", camelize: false, required: false
|
47
|
+
argument :space_id, GraphQL::Types::Int, "The ID of ParticipatorySpace you want to filter with", camelize: false, required: false
|
53
48
|
end
|
54
49
|
|
55
|
-
type.field :
|
56
|
-
|
57
|
-
|
58
|
-
argument :
|
50
|
+
type.field :user,
|
51
|
+
type: Core::AuthorInterface, null: true,
|
52
|
+
description: "A participant (user or group) in the current organization" do
|
53
|
+
argument :id, GraphQL::Types::ID, "The ID of the participant", required: false
|
54
|
+
argument :nickname, GraphQL::Types::String, "The @nickname of the participant", required: false
|
55
|
+
end
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
type.field :users,
|
58
|
+
type: [Core::AuthorInterface], null: true,
|
59
|
+
description: "The participants (users or groups) for the current organization" do
|
60
|
+
argument :order, Decidim::Core::UserEntityInputSort, "Provides several methods to order the results", required: false
|
61
|
+
argument :filter, Decidim::Core::UserEntityInputFilter, "Provides several methods to filter the results", required: false
|
63
62
|
end
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
65
|
+
def participatory_processes(filter: {}, order: {})
|
66
|
+
manifest = Decidim.participatory_space_manifests.select { |m| m.name == :participatory_processes }.first
|
67
|
+
Decidim::Core::ParticipatorySpaceListBase.new(manifest: manifest).call(object, { filter: filter, order: order }, context)
|
68
|
+
end
|
69
|
+
|
70
|
+
def participatory_process(id: nil, slug: nil)
|
71
|
+
manifest = Decidim.participatory_space_manifests.select { |m| m.name == :participatory_processes }.first
|
72
|
+
Decidim::Core::ParticipatorySpaceFinderBase.new(manifest: manifest).call(object, { id: id, slug: slug }, context)
|
73
|
+
end
|
74
|
+
|
75
|
+
def component(id: {})
|
76
|
+
component = Decidim::Component.published.find_by(id: id)
|
77
|
+
component&.organization == context[:current_organization] ? component : nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def session
|
81
|
+
context[:current_user]
|
82
|
+
end
|
83
|
+
|
84
|
+
def decidim
|
85
|
+
Decidim
|
86
|
+
end
|
87
|
+
|
88
|
+
def organization
|
89
|
+
context[:current_organization]
|
90
|
+
end
|
84
91
|
|
85
|
-
|
86
|
-
|
92
|
+
def hashtags(name: nil)
|
93
|
+
Decidim::HashtagsResolver.new(context[:current_organization], name).hashtags
|
94
|
+
end
|
95
|
+
|
96
|
+
def metrics(names: [], space_type: nil, space_id: nil)
|
97
|
+
manifests = if names.blank?
|
98
|
+
Decidim.metrics_registry.all
|
99
|
+
else
|
100
|
+
Decidim.metrics_registry.all.select do |manifest|
|
101
|
+
names.include?(manifest.metric_name.to_s)
|
102
|
+
end
|
87
103
|
end
|
88
|
-
|
104
|
+
filters = {}
|
105
|
+
if space_type.present? && space_id.present?
|
106
|
+
filters[:participatory_space_type] = space_type
|
107
|
+
filters[:participatory_space_id] = space_id
|
89
108
|
end
|
90
109
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
110
|
+
manifests.map do |manifest|
|
111
|
+
Decidim::Core::MetricResolver.new(manifest.metric_name, context[:current_organization], filters)
|
112
|
+
end
|
113
|
+
end
|
95
114
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
115
|
+
def user(id: nil, nickname: nil)
|
116
|
+
Core::UserEntityFinder.new.call(object, { id: id, nickname: nickname }, context)
|
117
|
+
end
|
118
|
+
|
119
|
+
def users(filter: {}, order: {})
|
120
|
+
Core::UserEntityList.new.call(object, { filter: filter, order: order }, context)
|
100
121
|
end
|
101
122
|
end
|
102
123
|
end
|
data/lib/decidim/randomable.rb
CHANGED
@@ -12,7 +12,12 @@ module Decidim
|
|
12
12
|
def order_randomly(seed)
|
13
13
|
transaction do
|
14
14
|
connection.execute("SELECT setseed(#{connection.quote(seed)})")
|
15
|
-
order
|
15
|
+
# Include the record IDs as a base number for the order calculation
|
16
|
+
# in order to avoid PostgreSQL random ordering when the records are
|
17
|
+
# updated. PostgreSQL can randomly change the base ordering in case
|
18
|
+
# the records are changed which is not desired as we want consistent
|
19
|
+
# orders for the records.
|
20
|
+
order(arel_table[primary_key] * Arel.sql("RANDOM()")).load
|
16
21
|
end
|
17
22
|
end
|
18
23
|
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# A concern that provides attribute encryption e.g. to active record models.
|
7
|
+
#
|
8
|
+
# Use this e.g. in models as follows:
|
9
|
+
#
|
10
|
+
# class Example < ApplicationRecord
|
11
|
+
# include Decidim::RecordEncryptor
|
12
|
+
#
|
13
|
+
# encrypt_attribute :name, type: :string
|
14
|
+
# encrypt_attribute :metadata, type: :hash
|
15
|
+
# end
|
16
|
+
module RecordEncryptor
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
|
19
|
+
included do
|
20
|
+
# Store the encrypted attributes in a class accessor
|
21
|
+
cattr_accessor :encrypted_attributes
|
22
|
+
|
23
|
+
before_save :ensure_encrypted_attributes if respond_to?(:before_save)
|
24
|
+
end
|
25
|
+
|
26
|
+
class_methods do
|
27
|
+
# Public: Defines an attribute that should be encrypted
|
28
|
+
def encrypt_attribute(attribute, type:)
|
29
|
+
self.encrypted_attributes ||= []
|
30
|
+
raise "The attribute #{attribute} is already defined as encrypted" if encrypted_attributes.include?(attribute)
|
31
|
+
|
32
|
+
encrypted_attributes << attribute
|
33
|
+
|
34
|
+
# Defines the suffix for the encrypt and decrypt methods. E.g. when
|
35
|
+
# the `type` is `:hash`, method `decrypt_hash_values` would be called
|
36
|
+
# for decryption and `encrypt_hash_values` would be called for
|
37
|
+
# encryption.
|
38
|
+
method_suffix = begin
|
39
|
+
case type
|
40
|
+
when :hash
|
41
|
+
"hash_values"
|
42
|
+
else
|
43
|
+
"value"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Dynamically defines the getter and setter for the encrypted attribute.
|
48
|
+
# E.g. when called as `encrypt_attribute :name, type: :string`, this
|
49
|
+
# would define the following methods:
|
50
|
+
#
|
51
|
+
# def name
|
52
|
+
# decrypt_value(super)
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# def name=(value)
|
56
|
+
# super(encrypt_value(value))
|
57
|
+
# end
|
58
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
59
|
+
def #{attribute}
|
60
|
+
return @#{attribute}_decrypted if instance_variable_defined?(:@#{attribute}_decrypted)
|
61
|
+
|
62
|
+
encrypted_value = begin
|
63
|
+
if defined?(super)
|
64
|
+
super
|
65
|
+
elsif instance_variable_defined?(:@#{attribute})
|
66
|
+
@#{attribute}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
@#{attribute}_decrypted = decrypt_#{method_suffix}(encrypted_value)
|
70
|
+
end
|
71
|
+
|
72
|
+
def #{attribute}=(value)
|
73
|
+
remove_instance_variable(:@#{attribute}_decrypted) if instance_variable_defined?(:@#{attribute}_decrypted)
|
74
|
+
encrypted_value = encrypt_#{method_suffix}(value)
|
75
|
+
|
76
|
+
if defined?(super)
|
77
|
+
super(encrypted_value)
|
78
|
+
else
|
79
|
+
@#{attribute} = encrypted_value
|
80
|
+
end
|
81
|
+
end
|
82
|
+
RUBY
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
# Re-assign the encrypted attributes before save so they are also saved when
|
89
|
+
# they are modified without calling the accessors. This could happen e.g.
|
90
|
+
# for hashes which are modified directly as follows:
|
91
|
+
#
|
92
|
+
# record = Example.find(1)
|
93
|
+
# record.metadata["foo"] = "bar"
|
94
|
+
# record.save!
|
95
|
+
#
|
96
|
+
# This will also clear the cached attributes during saving so that next time
|
97
|
+
# they are accessed, they will be updated according to the stored values.
|
98
|
+
def ensure_encrypted_attributes
|
99
|
+
self.class.encrypted_attributes.each do |attr|
|
100
|
+
send("#{attr}=", send(attr))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def decrypt_value(value)
|
105
|
+
Decidim::AttributeEncryptor.decrypt(value)
|
106
|
+
rescue ActiveSupport::MessageEncryptor::InvalidMessage
|
107
|
+
# Support for legacy unencrypted values. This is necessary e.g. when
|
108
|
+
# migrating the original unencrypted values to encrypted values.
|
109
|
+
value
|
110
|
+
end
|
111
|
+
|
112
|
+
def encrypt_value(value)
|
113
|
+
Decidim::AttributeEncryptor.encrypt(value)
|
114
|
+
end
|
115
|
+
|
116
|
+
def decrypt_hash_values(hash)
|
117
|
+
return hash unless hash.is_a?(Hash)
|
118
|
+
|
119
|
+
hash.transform_values { |value| ActiveSupport::JSON.decode(decrypt_value(value)) }
|
120
|
+
end
|
121
|
+
|
122
|
+
def encrypt_hash_values(hash)
|
123
|
+
return hash unless hash.is_a?(Hash)
|
124
|
+
|
125
|
+
# The values are stored in JSON encoded format in order to match the
|
126
|
+
# PostgreSQL adapter's default functionality as you can see at:
|
127
|
+
# https://git.io/JkdYJ
|
128
|
+
hash.transform_values { |value| encrypt_value(ActiveSupport::JSON.encode(value)) }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
data/lib/decidim/reportable.rb
CHANGED
@@ -42,6 +42,32 @@ module Decidim
|
|
42
42
|
def reported_content_url
|
43
43
|
raise NotImplementedError
|
44
44
|
end
|
45
|
+
|
46
|
+
# Public: The collection of attribute names that are considered
|
47
|
+
# to be reportable.
|
48
|
+
def reported_attributes
|
49
|
+
raise NotImplementedError
|
50
|
+
end
|
51
|
+
|
52
|
+
# Public: An `Array` of `String` that will be concatenated to
|
53
|
+
# the reported searchable content. This content is used
|
54
|
+
# in the admin dashboard to filter moderations.
|
55
|
+
def reported_searchable_content_extras
|
56
|
+
[]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Public: The reported searchable content in a text format so
|
60
|
+
# moderations can be filtered by content.
|
61
|
+
def reported_searchable_content_text
|
62
|
+
reported_searchable_content_extras.concat(
|
63
|
+
reported_attributes.map do |attribute_name|
|
64
|
+
attribute_value = attributes.with_indifferent_access[attribute_name]
|
65
|
+
next attribute_value.values.join("\n") if attribute_value.is_a? Hash
|
66
|
+
|
67
|
+
attribute_value
|
68
|
+
end
|
69
|
+
).join("\n")
|
70
|
+
end
|
45
71
|
end
|
46
72
|
end
|
47
73
|
end
|
@@ -36,6 +36,9 @@ module Decidim
|
|
36
36
|
# The main card to render an instance of the resource.
|
37
37
|
attribute :card, String
|
38
38
|
|
39
|
+
# The reported content to render an instance of the resource.
|
40
|
+
attribute :reported_content_cell, String
|
41
|
+
|
39
42
|
# Set this to `true` if you want this resource to be searchable. It requires
|
40
43
|
# the model to include the `Decidim::Searchable` concern.
|
41
44
|
attribute :searchable, Boolean, default: false
|
data/lib/decidim/resourceable.rb
CHANGED
@@ -93,7 +93,7 @@ module Decidim
|
|
93
93
|
# - the visibility of its participatory space.
|
94
94
|
# - the visibility of the resource itself.
|
95
95
|
def visible?
|
96
|
-
|
96
|
+
component.participatory_space.try(:visible?) && component.published? && resource_visible?
|
97
97
|
end
|
98
98
|
|
99
99
|
# Check only the resource visibility not its hierarchy.
|
@@ -102,11 +102,11 @@ module Decidim
|
|
102
102
|
#
|
103
103
|
# @return If the resource is also Publicable checks if the resource is published, otherwise returns true by default.
|
104
104
|
def resource_visible?
|
105
|
-
if respond_to?(:published?)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
return !hidden? && published? if respond_to?(:hidden?) && respond_to?(:published?)
|
106
|
+
return published? if respond_to?(:published?)
|
107
|
+
return !hidden? if respond_to?(:hidden?)
|
108
|
+
|
109
|
+
true
|
110
110
|
end
|
111
111
|
|
112
112
|
# Public: Whether the permissions for this object actions can be set at resource level.
|
data/lib/decidim/scopable.rb
CHANGED
@@ -74,7 +74,7 @@ module Decidim
|
|
74
74
|
def scope_belongs_to_organization
|
75
75
|
return if !scope || !organization
|
76
76
|
|
77
|
-
errors.add(:scope, :invalid) unless organization.scopes.
|
77
|
+
errors.add(:scope, :invalid) unless organization.scopes.exists?(id: scope.id)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -128,7 +128,7 @@ module Decidim
|
|
128
128
|
|
129
129
|
content = Array.wrap(content).collect do |item|
|
130
130
|
text = if item.is_a?(Hash)
|
131
|
-
item
|
131
|
+
item[locale].presence || item.dig("machine_translations", locale) || ""
|
132
132
|
else
|
133
133
|
item
|
134
134
|
end
|
data/lib/decidim/searchable.rb
CHANGED
@@ -87,22 +87,31 @@ module Decidim
|
|
87
87
|
return unless org
|
88
88
|
|
89
89
|
searchables_in_org = searchable_resources.by_organization(org.id)
|
90
|
+
|
90
91
|
if self.class.search_resource_fields_mapper.index_on_update?(self)
|
91
92
|
if searchables_in_org.empty?
|
92
93
|
add_to_index_as_search_resource
|
93
94
|
else
|
94
95
|
fields = self.class.search_resource_fields_mapper.mapped(self)
|
95
96
|
searchables_in_org.find_each do |sr|
|
97
|
+
next if sr.blank?
|
98
|
+
|
96
99
|
sr.update(contents_to_searchable_resource_attributes(fields, sr.locale))
|
97
100
|
end
|
98
101
|
end
|
99
102
|
elsif searchables_in_org.any?
|
100
103
|
searchables_in_org.destroy_all
|
101
104
|
end
|
105
|
+
|
106
|
+
find_and_update_descendants
|
102
107
|
end
|
103
108
|
|
104
109
|
private
|
105
110
|
|
111
|
+
def find_and_update_descendants
|
112
|
+
Decidim::FindAndUpdateDescendantsJob.perform_later(self)
|
113
|
+
end
|
114
|
+
|
106
115
|
def contents_to_searchable_resource_attributes(fields, locale)
|
107
116
|
contents = fields[:i18n][locale]
|
108
117
|
content_a = I18n.transliterate(contents[:A] || "")
|
@@ -95,7 +95,8 @@ module Decidim
|
|
95
95
|
text: { klass: String, default: nil },
|
96
96
|
array: { klass: Array, default: [] },
|
97
97
|
enum: { klass: String, default: nil },
|
98
|
-
scope: { klass: Integer, default: nil }
|
98
|
+
scope: { klass: Integer, default: nil },
|
99
|
+
time: { klass: Time, default: nil }
|
99
100
|
}.freeze
|
100
101
|
|
101
102
|
attribute :type, Symbol, default: :boolean
|
@@ -43,7 +43,8 @@ module Decidim
|
|
43
43
|
|
44
44
|
define_method attribute_name do
|
45
45
|
field = public_send(name) || {}
|
46
|
-
field[locale.to_s] || field[locale.to_sym]
|
46
|
+
value = field[locale.to_s] || field[locale.to_sym]
|
47
|
+
attribute_set[attribute_name].coerce(value)
|
47
48
|
end
|
48
49
|
|
49
50
|
define_method "#{attribute_name}=" do |value|
|
@@ -73,6 +73,16 @@ module Decidim
|
|
73
73
|
errors.add(field, :invalid)
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
# Public: Returns the original language in which the resource was created or
|
78
|
+
# the organization's default locale.
|
79
|
+
def content_original_language
|
80
|
+
field_name = self.class.translatable_fields_list.first
|
81
|
+
field_value = self[field_name]
|
82
|
+
return field_value.except("machine_translations").keys.first if field_value && field_value.except("machine_translations").keys.count == 1
|
83
|
+
|
84
|
+
organization.default_locale
|
85
|
+
end
|
76
86
|
end
|
77
87
|
end
|
78
88
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# A concern with the components needed when you want a model to be reportable
|
7
|
+
module UserReportable
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
has_one :user_moderation, class_name: "Decidim::UserModeration", foreign_key: :decidim_user_id, dependent: :destroy
|
12
|
+
has_many :user_reports, through: :user_moderation, source: :reports, class_name: "Decidim::UserReport"
|
13
|
+
|
14
|
+
def report_count
|
15
|
+
user_moderation&.report_count.to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
# Public: Check if the user has reported the reportable.
|
19
|
+
#
|
20
|
+
# Returns Boolean.
|
21
|
+
def reported_by?(user)
|
22
|
+
user_reports.where(user: user).any?
|
23
|
+
end
|
24
|
+
|
25
|
+
# Public: Checks if the reportable has been reported or not.
|
26
|
+
#
|
27
|
+
# Returns Boolean.
|
28
|
+
def reported?
|
29
|
+
report_count&.positive?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/decidim/view_model.rb
CHANGED
@@ -13,17 +13,43 @@ module Decidim
|
|
13
13
|
include Decidim::ActionAuthorization
|
14
14
|
include Decidim::ActionAuthorizationHelper
|
15
15
|
include Decidim::ReplaceButtonsHelper
|
16
|
+
include Cell::Caching::Notifications
|
16
17
|
include Decidim::MarkupHelper
|
17
18
|
include Decidim::FilterParamsHelper
|
18
19
|
|
19
20
|
delegate :current_organization, to: :controller
|
20
21
|
|
22
|
+
cache :show, if: :perform_caching? do
|
23
|
+
cache_hash
|
24
|
+
end
|
25
|
+
|
21
26
|
def current_user
|
22
27
|
context&.dig(:current_user) || controller&.current_user
|
23
28
|
end
|
24
29
|
|
30
|
+
def call(*)
|
31
|
+
identifier = self.class.name.sub(/Cell$/, "").underscore
|
32
|
+
instrument(:cell, identifier: identifier) do |_payload|
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
25
37
|
private
|
26
38
|
|
39
|
+
def instrument(name, **options)
|
40
|
+
ActiveSupport::Notifications.instrument("render_#{name}.action_view", options) do |payload|
|
41
|
+
yield payload
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def perform_caching?
|
46
|
+
cache_hash.present?
|
47
|
+
end
|
48
|
+
|
49
|
+
def cache_hash
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
|
27
53
|
def decidim
|
28
54
|
Decidim::Core::Engine.routes.url_helpers
|
29
55
|
end
|
@@ -16,10 +16,10 @@ class Premailer
|
|
16
16
|
# @return [String] a plain text.
|
17
17
|
def to_plain_text
|
18
18
|
html_src = begin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
@doc.at("body").inner_html
|
20
|
+
rescue StandardError
|
21
|
+
""
|
22
|
+
end
|
23
23
|
|
24
24
|
html_src = @doc.to_html unless html_src && html_src.present?
|
25
25
|
|
@@ -12,7 +12,7 @@ namespace :decidim do
|
|
12
12
|
#
|
13
13
|
desc "Deletes User records by ID using a CSV file"
|
14
14
|
task right_to_be_forgotten: :environment do
|
15
|
-
log = ActiveSupport::Logger.new(Rails.root.join("log
|
15
|
+
log = ActiveSupport::Logger.new(Rails.root.join("log/right_to_be_forgotten.log"))
|
16
16
|
begin
|
17
17
|
path = ENV["FILE_PATH"].presence || "tmp/forgotten_users.csv" # Good file
|
18
18
|
file_path = Rails.root.join(path)
|
@@ -74,11 +74,11 @@ namespace :decidim do
|
|
74
74
|
task delete_data_portability_files: :environment do
|
75
75
|
puts "DELETE DATA PORTABILITY FILES: -------------- START"
|
76
76
|
uploader = Decidim::DataPortabilityUploader.new
|
77
|
-
case uploader.
|
78
|
-
when "
|
77
|
+
case uploader.provider
|
78
|
+
when "file" # file system
|
79
79
|
puts "Deleting files from filesystem..."
|
80
80
|
delete_data_portability_files_from_fs(uploader)
|
81
|
-
when "
|
81
|
+
when "aws"
|
82
82
|
puts "Deleting files from aws..."
|
83
83
|
delete_data_portability_files_from_aws(uploader)
|
84
84
|
else
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* Korean translation for foundation-datepicker, language file from bootstrap-datepicker
|
3
|
+
* This is a port from https://github.com/moment/moment/blob/develop/src/locale/ko.js
|
4
|
+
*/
|
5
|
+
;(function($){
|
6
|
+
$.fn.fdatepicker.dates['ko'] = {
|
7
|
+
days: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"],
|
8
|
+
daysShort: ["일", "월", "화", "수", "목", "금", "토"],
|
9
|
+
daysMin: ["일", "월", "화", "수", "목", "금", "토"],
|
10
|
+
months: ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"],
|
11
|
+
monthsShort: ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"],
|
12
|
+
today: "오늘",
|
13
|
+
clear: "삭제",
|
14
|
+
format: "YYYY-MM-DD",
|
15
|
+
titleFormat: "yyyy년mm월",
|
16
|
+
weekStart: 0
|
17
|
+
};
|
18
|
+
}(jQuery));
|