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
@@ -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,8 +10,8 @@ module Decidim
|
|
10
10
|
include Decidim::DataPortability
|
11
11
|
include Decidim::Searchable
|
12
12
|
include Decidim::ActsAsAuthor
|
13
|
-
|
14
|
-
|
13
|
+
include Decidim::UserReportable
|
14
|
+
include Decidim::Traceable
|
15
15
|
|
16
16
|
class Roles
|
17
17
|
def self.all
|
@@ -32,12 +32,10 @@ module Decidim
|
|
32
32
|
has_many :access_grants, class_name: "Doorkeeper::AccessGrant", foreign_key: :resource_owner_id, dependent: :destroy
|
33
33
|
has_many :access_tokens, class_name: "Doorkeeper::AccessToken", foreign_key: :resource_owner_id, dependent: :destroy
|
34
34
|
|
35
|
+
has_one :blocking, class_name: "Decidim::UserBlock", foreign_key: :id, primary_key: :block_id, dependent: :destroy
|
36
|
+
|
35
37
|
validates :name, presence: true, unless: -> { deleted? }
|
36
|
-
validates :nickname,
|
37
|
-
presence: true,
|
38
|
-
format: { with: REGEXP_NICKNAME },
|
39
|
-
length: { maximum: Decidim::User.nickname_max_length },
|
40
|
-
unless: -> { deleted? || managed? }
|
38
|
+
validates :nickname, presence: true, unless: -> { deleted? || managed? }, length: { maximum: Decidim::User.nickname_max_length }
|
41
39
|
validates :locale, inclusion: { in: :available_locales }, allow_blank: true
|
42
40
|
validates :tos_agreement, acceptance: true, allow_nil: false, on: :create
|
43
41
|
validates :tos_agreement, acceptance: true, if: :user_invited?
|
@@ -58,6 +56,9 @@ module Decidim
|
|
58
56
|
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
59
57
|
scope :not_confirmed, -> { where(confirmed_at: nil) }
|
60
58
|
|
59
|
+
scope :blocked, -> { where(blocked: true) }
|
60
|
+
scope :not_blocked, -> { where(blocked: false) }
|
61
|
+
|
61
62
|
scope :interested_in_scopes, lambda { |scope_ids|
|
62
63
|
actual_ids = scope_ids.select(&:presence)
|
63
64
|
if actual_ids.count.positive?
|
@@ -207,7 +208,7 @@ module Decidim
|
|
207
208
|
end
|
208
209
|
|
209
210
|
def being_impersonated?
|
210
|
-
ImpersonationLog.active.
|
211
|
+
ImpersonationLog.active.exists?(user: self)
|
211
212
|
end
|
212
213
|
|
213
214
|
def interested_scopes_ids
|
@@ -218,6 +219,10 @@ module Decidim
|
|
218
219
|
@interested_scopes ||= organization.scopes.where(id: interested_scopes_ids)
|
219
220
|
end
|
220
221
|
|
222
|
+
def user_name
|
223
|
+
extended_data["user_name"] || name
|
224
|
+
end
|
225
|
+
|
221
226
|
# Caches a Decidim::DataPortabilityUploader with the retrieved file.
|
222
227
|
def data_portability_file(filename)
|
223
228
|
@data_portability_file ||= DataPortabilityUploader.new(self).tap do |uploader|
|
@@ -18,12 +18,12 @@ module Decidim
|
|
18
18
|
has_many :following_follows, foreign_key: "decidim_user_id", class_name: "Decidim::Follow", dependent: :destroy
|
19
19
|
|
20
20
|
# Regex for name & nickname format validations
|
21
|
-
REGEXP_NAME = /\A(?!.*[
|
21
|
+
REGEXP_NAME = /\A(?!.*[<>?%&\^*#@()\[\]=+:;"{}\\|])/.freeze
|
22
22
|
|
23
23
|
validates_avatar
|
24
24
|
mount_uploader :avatar, Decidim::AvatarUploader
|
25
25
|
|
26
|
-
validates :name, format: { with: REGEXP_NAME }
|
26
|
+
validates :name, :nickname, format: { with: REGEXP_NAME }
|
27
27
|
|
28
28
|
# Public: Returns a collection with all the entities this user is following.
|
29
29
|
#
|
@@ -34,17 +34,17 @@ module Decidim
|
|
34
34
|
# Returns an Array of Decidim::Followable
|
35
35
|
def following
|
36
36
|
@following ||= begin
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
followings = following_follows.pluck(:decidim_followable_type, :decidim_followable_id)
|
38
|
+
grouped_followings = followings.each_with_object({}) do |(type, following_id), all|
|
39
|
+
all[type] ||= []
|
40
|
+
all[type] << following_id
|
41
|
+
all
|
42
|
+
end
|
43
|
+
|
44
|
+
grouped_followings.flat_map do |type, ids|
|
45
|
+
type.constantize.where(id: ids)
|
46
|
+
end
|
47
|
+
end
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class UserBlock < ApplicationRecord
|
5
|
+
MINIMUM_JUSTIFICATION_LENGTH = 15
|
6
|
+
|
7
|
+
belongs_to :user, class_name: "Decidim::User", foreign_key: :decidim_user_id
|
8
|
+
belongs_to :blocking_user, class_name: "Decidim::User"
|
9
|
+
end
|
10
|
+
end
|
@@ -9,6 +9,7 @@ module Decidim
|
|
9
9
|
include Decidim::Traceable
|
10
10
|
include Decidim::DataPortability
|
11
11
|
include Decidim::ActsAsAuthor
|
12
|
+
include Decidim::UserReportable
|
12
13
|
|
13
14
|
has_many :memberships, class_name: "Decidim::UserGroupMembership", foreign_key: :decidim_user_group_id, dependent: :destroy
|
14
15
|
has_many :users, through: :memberships, class_name: "Decidim::User", foreign_key: :decidim_user_id
|
@@ -36,10 +37,6 @@ module Decidim
|
|
36
37
|
.where("extended_data->>'document_number' = ?", number)
|
37
38
|
end
|
38
39
|
|
39
|
-
def non_deleted_memberships
|
40
|
-
memberships.where(decidim_users: { deleted_at: nil })
|
41
|
-
end
|
42
|
-
|
43
40
|
# Returns the presenter for this author, to be used in the views.
|
44
41
|
# Required by ActsAsAuthor.
|
45
42
|
def presenter
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class UserModeration < ApplicationRecord
|
5
|
+
include Traceable
|
6
|
+
include Loggable
|
7
|
+
|
8
|
+
belongs_to :user, foreign_key: :decidim_user_id, class_name: "Decidim::UserBaseEntity"
|
9
|
+
has_many :reports, class_name: "Decidim::UserReport", dependent: :destroy
|
10
|
+
|
11
|
+
scope :blocked, -> { joins(:user).where(decidim_users: { blocked: true }) }
|
12
|
+
scope :unblocked, -> { joins(:user).where(decidim_users: { blocked: false }) }
|
13
|
+
|
14
|
+
delegate :organization, to: :user
|
15
|
+
scope :blocked, -> { joins(:user).where(decidim_users: { blocked: true }) }
|
16
|
+
scope :unblocked, -> { joins(:user).where(decidim_users: { blocked: false }) }
|
17
|
+
|
18
|
+
def self.log_presenter_class_for(_log)
|
19
|
+
Decidim::AdminLog::UserModerationPresenter
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class UserReport < ApplicationRecord
|
5
|
+
include Decidim::DataPortability
|
6
|
+
|
7
|
+
REASONS = %w(spam offensive does_not_belong).freeze
|
8
|
+
|
9
|
+
belongs_to :moderation, foreign_key: :user_moderation_id, class_name: "Decidim::UserModeration"
|
10
|
+
belongs_to :user, class_name: "Decidim::User"
|
11
|
+
|
12
|
+
validates :reason, presence: true
|
13
|
+
validates :reason, inclusion: { in: REASONS }
|
14
|
+
validates :user, uniqueness: { scope: :user_moderation_id }
|
15
|
+
validate :user_and_moderation_same_organization
|
16
|
+
|
17
|
+
def self.export_serializer
|
18
|
+
raise NotImplementedError
|
19
|
+
# Decidim::DataPortabilitySerializers::DataPortabilityReportSerializer
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
# Private: check if the moderation and the user have the same organization
|
25
|
+
def user_and_moderation_same_organization
|
26
|
+
return if !moderation || !user
|
27
|
+
|
28
|
+
errors.add(:moderation, :invalid) unless user.organization == moderation.organization
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -127,9 +127,7 @@ module Decidim
|
|
127
127
|
conversation = context.fetch(:conversation)
|
128
128
|
interlocutor = context.fetch(:interlocutor, user)
|
129
129
|
|
130
|
-
if [:create, :update].include?(permission_action.action)
|
131
|
-
return disallow! unless conversation&.accept_user? interlocutor
|
132
|
-
end
|
130
|
+
return disallow! if [:create, :update].include?(permission_action.action) && !conversation&.accept_user?(interlocutor)
|
133
131
|
|
134
132
|
toggle_allow(conversation&.participating?(interlocutor))
|
135
133
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ReportUserPermissions < DefaultPermissions
|
5
|
+
def permissions
|
6
|
+
return permission_action unless user
|
7
|
+
|
8
|
+
allow! if permission_action.subject == :user_report && permission_action.action == :create
|
9
|
+
|
10
|
+
permission_action
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class holds the logic to present a `Decidim::ImpersonationLog`
|
6
|
+
# for the `AdminLog` log.
|
7
|
+
#
|
8
|
+
# Usage should be automatic and you shouldn't need to call this class
|
9
|
+
# directly, but here's an example:
|
10
|
+
#
|
11
|
+
# action_log = Decidim::ActionLog.last
|
12
|
+
# view_helpers # => this comes from the views
|
13
|
+
# ImpersonationLogPresenter.new(action_log, view_helpers).present
|
14
|
+
class ImpersonationLogPresenter < Decidim::Log::BasePresenter
|
15
|
+
alias h view_helpers
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def action_string
|
20
|
+
case action
|
21
|
+
when "manage"
|
22
|
+
"decidim.admin_log.impersonation_log.#{action}"
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def i18n_params
|
29
|
+
super.merge(
|
30
|
+
reason: action_log.extra["reason"]
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def resource_presenter
|
35
|
+
@resource_presenter ||= Decidim::Log::UserPresenter.new(action_log.resource.user, h, action_log.extra["resource"])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|