decidim-core 0.23.3 → 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.js.es6 +1 -0
- 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.js.es6 +15 -4
- 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/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/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_cell.rb +11 -8
- 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/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 -0
- 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 +1 -1
- 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 -2
- 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 +12 -1
- data/app/models/decidim/user_base_entity.rb +12 -12
- data/app/models/decidim/user_block.rb +10 -0
- data/app/models/decidim/user_group.rb +1 -0
- 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/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/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 +8 -8
- 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 -9
- data/config/locales/bg.yml +1 -15
- data/config/locales/ca.yml +42 -15
- data/config/locales/cs.yml +79 -14
- data/config/locales/de.yml +78 -13
- data/config/locales/el.yml +1 -16
- data/config/locales/en.yml +79 -14
- data/config/locales/eo.yml +0 -1
- data/config/locales/es-MX.yml +30 -15
- data/config/locales/es-PY.yml +30 -15
- data/config/locales/es.yml +30 -15
- data/config/locales/eu.yml +1 -9
- data/config/locales/fi-plain.yml +76 -12
- data/config/locales/fi.yml +76 -12
- 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 -14
- data/config/locales/id-ID.yml +1 -9
- data/config/locales/is-IS.yml +0 -2
- data/config/locales/it.yml +65 -14
- data/config/locales/ja.yml +1 -16
- data/config/locales/lv.yml +1 -14
- data/config/locales/nl.yml +38 -15
- data/config/locales/no.yml +7 -16
- data/config/locales/pl.yml +98 -23
- data/config/locales/pt-BR.yml +1 -9
- data/config/locales/pt.yml +1 -16
- data/config/locales/ro-RO.yml +20 -16
- data/config/locales/ru.yml +1 -10
- data/config/locales/sk.yml +1 -14
- data/config/locales/sr-CS.yml +0 -9
- data/config/locales/sv.yml +5 -16
- data/config/locales/tr-TR.yml +62 -13
- data/config/locales/uk.yml +1 -7
- data/config/locales/zh-CN.yml +1 -16
- 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.rb +1 -0
- data/lib/decidim/attributes/clean_string.rb +37 -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.rb +11 -3
- data/lib/decidim/core/api.rb +71 -16
- data/lib/decidim/core/engine.rb +35 -6
- data/lib/decidim/core/test.rb +2 -0
- 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/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/version.rb +1 -1
- 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 +192 -101
- data/app/functions/decidim/core/participatory_space_finder.rb +0 -11
- data/app/functions/decidim/core/participatory_space_list.rb +0 -11
- 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/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
@@ -28,6 +28,35 @@ module Decidim
|
|
28
28
|
resource.update_column field_name.to_sym, resource[field_name]
|
29
29
|
# rubocop:enable Rails/SkipsModelValidations
|
30
30
|
end
|
31
|
+
|
32
|
+
send_translated_report_notifications(resource) if reported_resource_in_organization_language?(resource, target_locale)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def send_translated_report_notifications(reportable)
|
38
|
+
reportable.moderation.reports.each do |report|
|
39
|
+
reportable.moderation.participatory_space.moderators.each do |moderator|
|
40
|
+
Decidim::ReportedMailer.report(moderator, report).deliver_later
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def reported_resource_in_organization_language?(resource, target_locale)
|
46
|
+
return unless resource.try(:organization)
|
47
|
+
|
48
|
+
resource_reported?(resource) && target_locale == resource.organization.default_locale && resource_completely_translated?(resource, target_locale)
|
49
|
+
end
|
50
|
+
|
51
|
+
def resource_reported?(resource)
|
52
|
+
resource.class.included_modules.include?(Decidim::Reportable) && resource.reported?
|
53
|
+
end
|
54
|
+
|
55
|
+
def resource_completely_translated?(resource, target_locale)
|
56
|
+
reported_translatable_fields = resource.reported_attributes & resource.class.translatable_fields_list
|
57
|
+
reported_translatable_fields.all? do |field|
|
58
|
+
resource[field]&.dig("machine_translations", target_locale).present?
|
59
|
+
end
|
31
60
|
end
|
32
61
|
end
|
33
62
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A custom mailer for Decidim so we can notify users
|
5
|
+
# when their account was blocked
|
6
|
+
class BlockUserMailer < ApplicationMailer
|
7
|
+
def notify(user, justification)
|
8
|
+
@user = user
|
9
|
+
@organization = user.organization
|
10
|
+
@justification = justification
|
11
|
+
mail(
|
12
|
+
to: user.email,
|
13
|
+
subject: I18n.t(
|
14
|
+
"decidim.block_user_mailer.notify.subject",
|
15
|
+
organization_name: @organization.name,
|
16
|
+
justification: @justification
|
17
|
+
)
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -6,16 +6,17 @@ module Decidim
|
|
6
6
|
helper Decidim::ResourceHelper
|
7
7
|
helper Decidim::TranslationsHelper
|
8
8
|
|
9
|
-
helper_method :reported_content_url, :manage_moderations_url, :author_profile_url
|
9
|
+
helper_method :reported_content_url, :report_url, :manage_moderations_url, :author_profile_url, :reported_content_cell
|
10
10
|
|
11
11
|
def report(user, report)
|
12
12
|
with_user(user) do
|
13
13
|
@report = report
|
14
|
+
@reportable = @report.moderation.reportable
|
14
15
|
@participatory_space = @report.moderation.participatory_space
|
15
16
|
@organization = user.organization
|
16
17
|
@user = user
|
17
|
-
@author = @
|
18
|
-
@
|
18
|
+
@author = @reportable.try(:creator_identity) || @reportable.try(:author)
|
19
|
+
@original_language = original_language(@reportable)
|
19
20
|
subject = I18n.t("report.subject", scope: "decidim.reported_mailer")
|
20
21
|
mail(to: user.email, subject: subject)
|
21
22
|
end
|
@@ -32,12 +33,21 @@ module Decidim
|
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
36
|
+
# See comment for reported_content_cell
|
37
|
+
def current_organization
|
38
|
+
@organization
|
39
|
+
end
|
40
|
+
|
35
41
|
private
|
36
42
|
|
37
43
|
def reported_content_url
|
38
44
|
@reported_content_url ||= @report.moderation.reportable.reported_content_url
|
39
45
|
end
|
40
46
|
|
47
|
+
def report_url
|
48
|
+
@report_url ||= EngineRouter.admin_proxy(@participatory_space).moderation_report_url(host: @organization.host, moderation_id: @report.moderation.id, id: @report.id)
|
49
|
+
end
|
50
|
+
|
41
51
|
def manage_moderations_url
|
42
52
|
@manage_moderations_url ||= EngineRouter.admin_proxy(@participatory_space).moderations_url(host: @organization.host)
|
43
53
|
end
|
@@ -45,5 +55,25 @@ module Decidim
|
|
45
55
|
def author_profile_url
|
46
56
|
@author_profile_url ||= @author.is_a?(Decidim::UserBaseEntity) ? decidim.profile_url(@author.nickname, host: @organization.host) : nil
|
47
57
|
end
|
58
|
+
|
59
|
+
def original_language(reportable)
|
60
|
+
return reportable.content_original_language if reportable.respond_to?(:content_original_language)
|
61
|
+
|
62
|
+
@organization.default_locale
|
63
|
+
end
|
64
|
+
|
65
|
+
# This is needed to be able to use a cell in an ActionMailer, which is not supported out of the box by cells-rails.
|
66
|
+
# We're are passing the current object as if it was a controller.
|
67
|
+
# We also need to define a 'current_organization' method, which is expected by Decidim::ViewModel.
|
68
|
+
# A similar approach is used in Decidim::NewsletterMailer
|
69
|
+
def reported_content_cell
|
70
|
+
@reported_content_cell ||= ::Decidim::ViewModel.cell(
|
71
|
+
"decidim/reported_content",
|
72
|
+
@reportable,
|
73
|
+
context: {
|
74
|
+
controller: self
|
75
|
+
}
|
76
|
+
)
|
77
|
+
end
|
48
78
|
end
|
49
79
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A custom mailer to notify Decidim users
|
5
|
+
# that they have been reported
|
6
|
+
class UserReportMailer < ApplicationMailer
|
7
|
+
def notify(admin, token, reason, user)
|
8
|
+
@user = user
|
9
|
+
@organization = user.organization
|
10
|
+
@token = token
|
11
|
+
@reason = reason
|
12
|
+
@admin = admin
|
13
|
+
mail(to: admin.email, subject: I18n.t(
|
14
|
+
"decidim.user_report_mailer.notify.subject",
|
15
|
+
organization_name: @organization.name,
|
16
|
+
reason: @reason,
|
17
|
+
token: @token
|
18
|
+
))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/app/models/decidim/area.rb
CHANGED
@@ -13,7 +13,7 @@ module Decidim
|
|
13
13
|
class_name: "Decidim::Organization",
|
14
14
|
inverse_of: :area_types
|
15
15
|
|
16
|
-
has_many :areas,
|
16
|
+
has_many :areas, class_name: "Decidim::Area", inverse_of: :area_type, dependent: :nullify
|
17
17
|
|
18
18
|
validates :name, presence: true
|
19
19
|
|
@@ -11,10 +11,11 @@ module Decidim
|
|
11
11
|
belongs_to :attachment_collection, class_name: "Decidim::AttachmentCollection", optional: true
|
12
12
|
belongs_to :attached_to, polymorphic: true
|
13
13
|
|
14
|
-
validates :file, :content_type, presence: true
|
15
|
-
validates_upload :file
|
16
14
|
mount_uploader :file, Decidim::AttachmentUploader
|
17
15
|
|
16
|
+
validates_upload :file
|
17
|
+
validates :file, :content_type, presence: true
|
18
|
+
|
18
19
|
default_scope { order(arel_table[:weight].asc, arel_table[:id].asc) }
|
19
20
|
|
20
21
|
# Returns the organization related to this attachment in case the
|
@@ -8,7 +8,7 @@ module Decidim
|
|
8
8
|
|
9
9
|
translatable_fields :name, :description
|
10
10
|
belongs_to :collection_for, polymorphic: true
|
11
|
-
has_many :attachments,
|
11
|
+
has_many :attachments, class_name: "Decidim::Attachment", dependent: :nullify
|
12
12
|
|
13
13
|
default_scope { order(arel_table[:weight].asc) }
|
14
14
|
|
@@ -13,6 +13,10 @@ module Decidim
|
|
13
13
|
class Authorization < ApplicationRecord
|
14
14
|
include Decidim::Traceable
|
15
15
|
include Decidim::HasUploadValidations
|
16
|
+
include Decidim::RecordEncryptor
|
17
|
+
|
18
|
+
encrypt_attribute :metadata, type: :hash
|
19
|
+
encrypt_attribute :verification_metadata, type: :hash
|
16
20
|
|
17
21
|
validates_upload :verification_attachment
|
18
22
|
mount_uploader :verification_attachment, Decidim::Verifications::AttachmentUploader
|
@@ -10,7 +10,7 @@ module Decidim
|
|
10
10
|
|
11
11
|
belongs_to :participatory_space, foreign_key: "decidim_participatory_space_id", foreign_type: "decidim_participatory_space_type", polymorphic: true
|
12
12
|
has_many :subcategories, foreign_key: "parent_id", class_name: "Decidim::Category", dependent: :destroy, inverse_of: :parent
|
13
|
-
belongs_to :parent, class_name: "Decidim::Category",
|
13
|
+
belongs_to :parent, class_name: "Decidim::Category", inverse_of: :subcategories, optional: true
|
14
14
|
has_many :categorizations, foreign_key: "decidim_category_id", class_name: "Decidim::Categorization", dependent: :destroy
|
15
15
|
|
16
16
|
default_scope { order(arel_table[:parent_id].asc, arel_table[:weight].asc) }
|
@@ -38,6 +38,11 @@ module Decidim
|
|
38
38
|
categorizations.empty?
|
39
39
|
end
|
40
40
|
|
41
|
+
# Allow ransacker to search for a key in a hstore column (`name`.`en`)
|
42
|
+
ransacker :name do |parent|
|
43
|
+
Arel::Nodes::InfixOperation.new("->>", parent.table[:name], Arel::Nodes.build_quoted(I18n.locale.to_s))
|
44
|
+
end
|
45
|
+
|
41
46
|
private
|
42
47
|
|
43
48
|
# This is done since we only allow one level of subcategories.
|
@@ -8,7 +8,7 @@ module Decidim
|
|
8
8
|
belongs_to :admin, foreign_key: "decidim_admin_id", class_name: "Decidim::User"
|
9
9
|
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
|
10
10
|
|
11
|
-
validate :same_organization
|
11
|
+
validate :same_organization
|
12
12
|
|
13
13
|
scope :active, -> { where(ended_at: nil, expired_at: nil) }
|
14
14
|
scope :expired, -> { where(ended_at: nil).where.not(expired_at: nil) }
|
@@ -21,6 +21,10 @@ module Decidim
|
|
21
21
|
expired_at.present?
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.log_presenter_class_for(_log)
|
25
|
+
Decidim::AdminLog::ImpersonationLogPresenter
|
26
|
+
end
|
27
|
+
|
24
28
|
private
|
25
29
|
|
26
30
|
def same_organization
|
@@ -28,11 +32,5 @@ module Decidim
|
|
28
32
|
|
29
33
|
errors.add(:admin, :invalid)
|
30
34
|
end
|
31
|
-
|
32
|
-
def non_active_impersonation
|
33
|
-
return if ended? || expired?
|
34
|
-
|
35
|
-
errors.add(:admin, :invalid) if Decidim::ImpersonationLog.where(admin: admin).active.any?
|
36
|
-
end
|
37
35
|
end
|
38
36
|
end
|
@@ -6,8 +6,8 @@ module Decidim
|
|
6
6
|
# ParticipatorySpace, RelatedObject and Category are optional relationships because not all metric objects need them
|
7
7
|
# For example, User is only related to an organization, but a Proposal can have all of them
|
8
8
|
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
|
9
|
-
belongs_to :participatory_space,
|
10
|
-
belongs_to :related_object,
|
9
|
+
belongs_to :participatory_space, foreign_type: "participatory_space_type", polymorphic: true, optional: true
|
10
|
+
belongs_to :related_object, foreign_type: "related_object_type", polymorphic: true, optional: true
|
11
11
|
belongs_to :category, foreign_key: "decidim_category_id", class_name: "Decidim::Category", optional: true
|
12
12
|
|
13
13
|
validates :day, uniqueness: { scope:
|
@@ -15,5 +15,17 @@ module Decidim
|
|
15
15
|
def self.log_presenter_class_for(_log)
|
16
16
|
Decidim::AdminLog::ModerationPresenter
|
17
17
|
end
|
18
|
+
|
19
|
+
ransacker :reported_id_string do
|
20
|
+
Arel.sql(%{cast("decidim_moderations"."decidim_reportable_id" as text)})
|
21
|
+
end
|
22
|
+
|
23
|
+
ransacker :reported_content do
|
24
|
+
Arel.sql(%{cast("decidim_moderations"."reported_content" as text)})
|
25
|
+
end
|
26
|
+
|
27
|
+
ransacker :reportable_type_string do
|
28
|
+
Arel.sql(%{cast("decidim_moderations"."decidim_reportable_type" as text)})
|
29
|
+
end
|
18
30
|
end
|
19
31
|
end
|
@@ -21,7 +21,7 @@ module Decidim
|
|
21
21
|
:admin_terms_of_use_body
|
22
22
|
|
23
23
|
has_many :static_pages, foreign_key: "decidim_organization_id", class_name: "Decidim::StaticPage", inverse_of: :organization, dependent: :destroy
|
24
|
-
has_many :static_page_topics,
|
24
|
+
has_many :static_page_topics, class_name: "Decidim::StaticPageTopic", inverse_of: :organization, dependent: :destroy
|
25
25
|
has_many :scopes, -> { order(name: :asc) }, foreign_key: "decidim_organization_id", class_name: "Decidim::Scope", inverse_of: :organization
|
26
26
|
has_many :scope_types, -> { order(name: :asc) }, foreign_key: "decidim_organization_id", class_name: "Decidim::ScopeType", inverse_of: :organization
|
27
27
|
has_many :areas, -> { order(name: :asc) }, foreign_key: "decidim_organization_id", class_name: "Decidim::Area", inverse_of: :organization
|
@@ -153,6 +153,10 @@ module Decidim
|
|
153
153
|
Decidim::Debates::OfficialAuthorPresenter.new
|
154
154
|
end
|
155
155
|
|
156
|
+
def static_pages_accessible_for(user)
|
157
|
+
static_pages.accessible_for(self, user)
|
158
|
+
end
|
159
|
+
|
156
160
|
private
|
157
161
|
|
158
162
|
def tenant_disabled_providers_keys
|
data/app/models/decidim/scope.rb
CHANGED
@@ -17,13 +17,11 @@ module Decidim
|
|
17
17
|
inverse_of: :scopes
|
18
18
|
|
19
19
|
belongs_to :scope_type,
|
20
|
-
foreign_key: "scope_type_id",
|
21
20
|
class_name: "Decidim::ScopeType",
|
22
21
|
inverse_of: :scopes,
|
23
22
|
optional: true
|
24
23
|
|
25
24
|
belongs_to :parent,
|
26
|
-
foreign_key: "parent_id",
|
27
25
|
class_name: "Decidim::Scope",
|
28
26
|
inverse_of: :children,
|
29
27
|
optional: true
|
@@ -74,6 +72,11 @@ module Decidim
|
|
74
72
|
organization.scopes.where(id: scope_ids).sort { |s1, s2| part_of.index(s2.id) <=> part_of.index(s1.id) }
|
75
73
|
end
|
76
74
|
|
75
|
+
# Allow ransacker to search for a key in a hstore column (`name`.`en`)
|
76
|
+
ransacker :name do |parent|
|
77
|
+
Arel::Nodes::InfixOperation.new("->>", parent.table[:name], Arel::Nodes.build_quoted(I18n.locale.to_s))
|
78
|
+
end
|
79
|
+
|
77
80
|
private
|
78
81
|
|
79
82
|
def forbid_cycles
|
@@ -12,7 +12,7 @@ module Decidim
|
|
12
12
|
class_name: "Decidim::Organization",
|
13
13
|
inverse_of: :scope_types
|
14
14
|
|
15
|
-
has_many :scopes,
|
15
|
+
has_many :scopes, class_name: "Decidim::Scope", inverse_of: :scope_type, dependent: :nullify
|
16
16
|
|
17
17
|
validates :name, presence: true
|
18
18
|
end
|
@@ -8,7 +8,7 @@ module Decidim
|
|
8
8
|
|
9
9
|
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
|
10
10
|
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
|
11
|
-
belongs_to :token_for,
|
11
|
+
belongs_to :token_for, foreign_type: "token_for_type", polymorphic: true
|
12
12
|
|
13
13
|
after_initialize :generate, :set_default_expiration
|
14
14
|
|
@@ -15,7 +15,7 @@ module Decidim
|
|
15
15
|
translatable_fields :title, :content
|
16
16
|
|
17
17
|
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization", inverse_of: :static_pages
|
18
|
-
belongs_to :topic,
|
18
|
+
belongs_to :topic, class_name: "Decidim::StaticPageTopic", optional: true
|
19
19
|
|
20
20
|
validates :slug, presence: true, uniqueness: { scope: :organization }
|
21
21
|
validates :slug, format: { with: /\A[a-z0-9-]+/ }
|
@@ -30,6 +30,16 @@ module Decidim
|
|
30
30
|
|
31
31
|
default_scope { order(arel_table[:weight].asc) }
|
32
32
|
|
33
|
+
scope :accessible_for, lambda { |organization, user|
|
34
|
+
collection = where(organization: organization)
|
35
|
+
|
36
|
+
if user.blank? && organization.force_users_to_authenticate_before_access_organization
|
37
|
+
collection.where(allow_public_access: true)
|
38
|
+
else
|
39
|
+
collection
|
40
|
+
end
|
41
|
+
}
|
42
|
+
|
33
43
|
# Whether this is slug of a default page or not.
|
34
44
|
#
|
35
45
|
# slug - The String with the value of the slug.
|
@@ -11,5 +11,9 @@ module Decidim
|
|
11
11
|
|
12
12
|
belongs_to :organization, class_name: "Decidim::Organization"
|
13
13
|
has_many :pages, class_name: "Decidim::StaticPage", foreign_key: "topic_id", dependent: :nullify
|
14
|
+
|
15
|
+
def accessible_pages_for(user)
|
16
|
+
pages.accessible_for(organization, user)
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
data/app/models/decidim/user.rb
CHANGED
@@ -10,6 +10,8 @@ module Decidim
|
|
10
10
|
include Decidim::DataPortability
|
11
11
|
include Decidim::Searchable
|
12
12
|
include Decidim::ActsAsAuthor
|
13
|
+
include Decidim::UserReportable
|
14
|
+
include Decidim::Traceable
|
13
15
|
|
14
16
|
class Roles
|
15
17
|
def self.all
|
@@ -30,6 +32,8 @@ module Decidim
|
|
30
32
|
has_many :access_grants, class_name: "Doorkeeper::AccessGrant", foreign_key: :resource_owner_id, dependent: :destroy
|
31
33
|
has_many :access_tokens, class_name: "Doorkeeper::AccessToken", foreign_key: :resource_owner_id, dependent: :destroy
|
32
34
|
|
35
|
+
has_one :blocking, class_name: "Decidim::UserBlock", foreign_key: :id, primary_key: :block_id, dependent: :destroy
|
36
|
+
|
33
37
|
validates :name, presence: true, unless: -> { deleted? }
|
34
38
|
validates :nickname, presence: true, unless: -> { deleted? || managed? }, length: { maximum: Decidim::User.nickname_max_length }
|
35
39
|
validates :locale, inclusion: { in: :available_locales }, allow_blank: true
|
@@ -52,6 +56,9 @@ module Decidim
|
|
52
56
|
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
53
57
|
scope :not_confirmed, -> { where(confirmed_at: nil) }
|
54
58
|
|
59
|
+
scope :blocked, -> { where(blocked: true) }
|
60
|
+
scope :not_blocked, -> { where(blocked: false) }
|
61
|
+
|
55
62
|
scope :interested_in_scopes, lambda { |scope_ids|
|
56
63
|
actual_ids = scope_ids.select(&:presence)
|
57
64
|
if actual_ids.count.positive?
|
@@ -201,7 +208,7 @@ module Decidim
|
|
201
208
|
end
|
202
209
|
|
203
210
|
def being_impersonated?
|
204
|
-
ImpersonationLog.active.
|
211
|
+
ImpersonationLog.active.exists?(user: self)
|
205
212
|
end
|
206
213
|
|
207
214
|
def interested_scopes_ids
|
@@ -212,6 +219,10 @@ module Decidim
|
|
212
219
|
@interested_scopes ||= organization.scopes.where(id: interested_scopes_ids)
|
213
220
|
end
|
214
221
|
|
222
|
+
def user_name
|
223
|
+
extended_data["user_name"] || name
|
224
|
+
end
|
225
|
+
|
215
226
|
# Caches a Decidim::DataPortabilityUploader with the retrieved file.
|
216
227
|
def data_portability_file(filename)
|
217
228
|
@data_portability_file ||= DataPortabilityUploader.new(self).tap do |uploader|
|