decidim-core 0.22.0 → 0.23.0
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/app/assets/config/decidim_core_manifest.js +5 -0
- data/app/assets/javascripts/decidim.js.es6 +2 -0
- data/app/assets/javascripts/decidim/ajax_modals.js.es6 +3 -3
- data/app/assets/javascripts/decidim/confirm.js.es6 +3 -2
- 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/diff_mode_dropdown.js.es6 +18 -4
- data/app/assets/javascripts/decidim/editor.js.es6 +3 -3
- data/app/assets/javascripts/decidim/geocoding.js.es6 +60 -0
- data/app/assets/javascripts/decidim/geocoding/attach_input.js.es6 +106 -0
- data/app/assets/javascripts/decidim/geocoding/format_address.js.es6 +29 -0
- data/app/assets/javascripts/decidim/geocoding/provider/here.js.es6 +107 -0
- data/app/assets/javascripts/decidim/geocoding/provider/photon.js.es6 +77 -0
- data/app/assets/javascripts/decidim/map.js.es6 +34 -124
- data/app/assets/javascripts/decidim/map/controller.js.es6 +92 -0
- data/app/assets/javascripts/decidim/map/controller/markers.js.es6 +65 -0
- data/app/assets/javascripts/decidim/map/controller/static.es6 +48 -0
- data/app/assets/javascripts/decidim/map/factory.js.es6 +51 -0
- data/app/assets/javascripts/decidim/map/icon.js.es6 +31 -0
- data/app/assets/javascripts/decidim/map/legacy.js.es6 +87 -0
- data/app/assets/javascripts/decidim/map/provider/default.js.es6 +22 -0
- data/app/assets/javascripts/decidim/map/provider/here.js.es6 +22 -0
- data/app/assets/javascripts/decidim/security/selfxss_warning.js.es6 +19 -0
- data/app/assets/stylesheets/decidim/_decidim.scss +2 -0
- data/app/assets/stylesheets/decidim/modules/_cards.scss +15 -0
- data/app/assets/stylesheets/decidim/modules/_forms.scss +14 -0
- data/app/assets/stylesheets/decidim/modules/_layout.scss +11 -3
- data/app/assets/stylesheets/decidim/modules/_map.scss +35 -0
- data/app/assets/stylesheets/decidim/modules/_progress-bar.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_reveal.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +2 -1
- data/app/cells/decidim/author/flag.erb +1 -1
- data/app/cells/decidim/author/profile_inline.erb +2 -2
- data/app/cells/decidim/author_cell.rb +5 -2
- data/app/cells/decidim/card_cell.rb +21 -7
- data/app/cells/decidim/card_m/show.erb +1 -1
- data/app/cells/decidim/card_m_cell.rb +6 -4
- data/app/cells/decidim/collapsible_authors_cell.rb +1 -1
- data/app/cells/decidim/diff/diff_mode_html.erb +5 -5
- data/app/cells/decidim/follow_button/show.erb +6 -6
- data/app/cells/decidim/follow_button_cell.rb +8 -0
- data/app/cells/decidim/progress_bar/show.erb +11 -4
- data/app/cells/decidim/progress_bar_cell.rb +20 -1
- data/app/cells/decidim/translation_bar/show.erb +6 -0
- data/app/cells/decidim/translation_bar_cell.rb +52 -0
- data/app/cells/decidim/version_cell.rb +1 -1
- data/app/cells/decidim/versions_list_cell.rb +1 -1
- data/app/commands/decidim/amendable/accept.rb +9 -3
- data/app/commands/decidim/amendable/create_draft.rb +2 -0
- data/app/commands/decidim/amendable/update_draft.rb +2 -0
- data/app/commands/decidim/attachment_methods.rb +12 -5
- data/app/commands/decidim/destroy_account.rb +1 -0
- data/app/commands/decidim/gallery_methods.rb +16 -9
- data/app/commands/decidim/messaging/reply_to_conversation.rb +1 -1
- data/app/commands/decidim/multiple_attachments_methods.rb +56 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +1 -0
- data/app/controllers/concerns/decidim/filter_resource.rb +24 -6
- data/app/controllers/concerns/decidim/flaggable.rb +20 -0
- data/app/controllers/concerns/decidim/force_authentication.rb +1 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +1 -1
- data/app/controllers/concerns/decidim/needs_snippets.rb +20 -0
- data/app/controllers/concerns/decidim/paginable.rb +5 -1
- data/app/controllers/concerns/decidim/withdrawable.rb +20 -0
- data/app/controllers/decidim/application_controller.rb +16 -0
- data/app/controllers/decidim/components/base_controller.rb +6 -1
- data/app/controllers/decidim/cookie_policy_controller.rb +6 -3
- data/app/controllers/decidim/messaging/conversations_controller.rb +5 -2
- data/app/forms/decidim/account_form.rb +5 -1
- data/app/forms/decidim/amendable/create_form.rb +1 -1
- data/app/forms/decidim/amendable/form.rb +44 -3
- data/app/forms/decidim/attachment_form.rb +5 -1
- data/app/forms/decidim/user_group_form.rb +5 -1
- data/app/helpers/decidim/cells_helper.rb +3 -15
- data/app/helpers/decidim/check_boxes_tree_helper.rb +21 -12
- data/app/helpers/decidim/cookies_helper.rb +1 -1
- data/app/helpers/decidim/decidim_form_helper.rb +1 -1
- data/app/helpers/decidim/filter_params_helper.rb +30 -0
- data/app/helpers/decidim/map_helper.rb +86 -23
- data/app/helpers/decidim/orders_helper.rb +6 -1
- data/app/helpers/decidim/paginate_helper.rb +3 -1
- data/app/helpers/decidim/scopes_helper.rb +4 -4
- data/app/helpers/decidim/translations_helper.rb +7 -1
- data/app/jobs/decidim/machine_translation_fields_job.rb +30 -0
- data/app/jobs/decidim/machine_translation_resource_job.rb +113 -0
- data/app/jobs/decidim/machine_translation_save_job.rb +33 -0
- data/app/mailers/decidim/reported_mailer.rb +8 -1
- data/app/models/decidim/action_log.rb +1 -1
- data/app/models/decidim/area.rb +3 -0
- data/app/models/decidim/area_type.rb +4 -0
- data/app/models/decidim/attachment.rb +30 -2
- data/app/models/decidim/attachment_collection.rb +3 -0
- data/app/models/decidim/authorization.rb +3 -0
- data/app/models/decidim/category.rb +4 -0
- data/app/models/decidim/component.rb +7 -0
- data/app/models/decidim/content_block.rb +11 -1
- data/app/models/decidim/contextual_help_section.rb +4 -0
- data/app/models/decidim/follow.rb +3 -1
- data/app/models/decidim/messaging/message.rb +1 -1
- data/app/models/decidim/moderation.rb +1 -1
- data/app/models/decidim/newsletter.rb +3 -0
- data/app/models/decidim/oauth_application.rb +2 -0
- data/app/models/decidim/organization.rb +53 -9
- data/app/models/decidim/scope.rb +4 -1
- data/app/models/decidim/scope_type.rb +3 -0
- data/app/models/decidim/share_token.rb +49 -0
- data/app/models/decidim/static_page.rb +4 -1
- data/app/models/decidim/static_page_topic.rb +3 -0
- data/app/models/decidim/user_base_entity.rb +6 -2
- data/app/permissions/decidim/permissions.rb +9 -0
- data/app/presenters/decidim/log/base_presenter.rb +1 -1
- data/app/presenters/decidim/log/value_types/default_presenter.rb +1 -1
- data/app/presenters/decidim/official_author_presenter.rb +36 -0
- data/app/presenters/decidim/resource_locator_presenter.rb +63 -12
- data/app/queries/decidim/similar_emendations.rb +4 -4
- data/app/scrubbers/decidim/user_input_scrubber.rb +1 -1
- data/app/serializers/decidim/importers/participatory_space_components_importer.rb +1 -1
- data/app/services/decidim/base_diff_renderer.rb +17 -0
- data/app/services/decidim/open_data_exporter.rb +2 -0
- data/app/services/decidim/resource_search.rb +95 -6
- data/app/services/decidim/static_map_generator.rb +10 -26
- data/app/uploaders/decidim/application_uploader.rb +15 -1
- data/app/uploaders/decidim/attachment_uploader.rb +23 -17
- data/app/uploaders/decidim/banner_image_uploader.rb +1 -1
- data/app/uploaders/decidim/hero_image_uploader.rb +1 -1
- data/app/uploaders/decidim/homepage_image_uploader.rb +1 -1
- data/app/uploaders/decidim/image_uploader.rb +6 -2
- data/app/uploaders/decidim/oauth_application_logo_uploader.rb +1 -1
- data/app/uploaders/decidim/official_image_footer_uploader.rb +1 -1
- data/app/uploaders/decidim/official_image_header_uploader.rb +1 -1
- data/app/uploaders/decidim/organization_logo_uploader.rb +1 -1
- data/app/uploaders/decidim/record_image_uploader.rb +15 -0
- data/app/validators/etiquette_validator.rb +0 -7
- data/app/validators/geocoding_validator.rb +9 -4
- data/app/validators/passthru_validator.rb +111 -0
- data/app/validators/scope_belongs_to_component_validator.rb +16 -0
- data/app/validators/uploader_content_type_validator.rb +44 -0
- data/app/views/decidim/authorization_modals/_content.html.erb +2 -2
- data/app/views/decidim/devise/registrations/new.html.erb +3 -1
- data/app/views/decidim/devise/sessions/new.html.erb +3 -1
- data/app/views/decidim/messaging/conversations/_error_modal.html.erb +21 -0
- data/app/views/decidim/messaging/conversations/error.js.erb +10 -0
- data/app/views/decidim/notification_mailer/event_received.html.erb +2 -2
- data/app/views/decidim/reported_mailer/report.html.erb +49 -3
- data/app/views/decidim/scopes/_scopes_picker_input.html.erb +15 -14
- data/app/views/decidim/searches/_filters.html.erb +1 -0
- data/app/views/decidim/shared/_login_modal.html.erb +14 -3
- data/app/views/decidim/shared/_static_map.html.erb +1 -1
- data/app/views/layouts/decidim/_head.html.erb +2 -0
- data/app/views/layouts/decidim/_js_configuration.html.erb +7 -1
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +3 -4
- data/config/locales/bg.yml +1508 -0
- data/config/locales/ca.yml +35 -8
- data/config/locales/cs.yml +34 -7
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +23 -4
- data/config/locales/el.yml +0 -4
- data/config/locales/en.yml +30 -3
- data/config/locales/eo.yml +92 -0
- data/config/locales/es-MX.yml +28 -1
- data/config/locales/es-PY.yml +28 -1
- data/config/locales/es.yml +44 -17
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +3 -4
- data/config/locales/fi-plain.yml +28 -1
- data/config/locales/fi.yml +29 -2
- data/config/locales/fr-CA.yml +32 -4
- data/config/locales/fr.yml +61 -33
- data/config/locales/ga-IE.yml +0 -8
- data/config/locales/gl.yml +3 -4
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +7 -4
- data/config/locales/id-ID.yml +3 -4
- data/config/locales/is-IS.yml +3 -9
- data/config/locales/is.yml +463 -0
- data/config/locales/it.yml +36 -8
- data/config/locales/ja-JP.yml +25 -16
- data/config/locales/ja.yml +1605 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/{lv-LV.yml → lv.yml} +0 -4
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +25 -3
- data/config/locales/no.yml +133 -6
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +88 -71
- data/config/locales/pt-BR.yml +3 -4
- data/config/locales/pt.yml +10 -4
- data/config/locales/ro-RO.yml +10 -4
- data/config/locales/ru.yml +3 -10
- data/config/locales/sk.yml +3 -4
- data/config/locales/sl.yml +8 -7
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +0 -7
- data/config/locales/sv.yml +17 -6
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +3 -4
- data/config/locales/uk.yml +3 -11
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +1584 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20200525184143_add_enable_machine_translation_to_decidim_organizations.rb +7 -0
- data/db/migrate/20200702073419_create_decidim_share_tokens.rb +16 -0
- data/db/migrate/20200707132401_add_comments_max_length_to_decidim_organization.rb +7 -0
- data/db/migrate/20200730142511_add_file_upload_settings_to_decidim_organizations.rb +36 -0
- data/db/migrate/20200806092109_add_machine_translation_display_priority_to_organizations.rb +17 -0
- data/db/migrate/20201004160335_remove_notifications_with_continuity_badge.rb +9 -0
- data/db/seeds.rb +5 -4
- data/lib/decidim/authorable.rb +22 -1
- data/lib/decidim/authorization_form_builder.rb +7 -0
- data/lib/decidim/coauthorable.rb +22 -0
- data/lib/decidim/component_manifest.rb +1 -1
- data/lib/decidim/content_processor.rb +52 -29
- data/lib/decidim/content_renderers/base_renderer.rb +1 -1
- data/lib/decidim/content_renderers/hashtag_renderer.rb +2 -0
- data/lib/decidim/content_renderers/link_renderer.rb +4 -1
- data/lib/decidim/content_renderers/user_group_renderer.rb +3 -1
- data/lib/decidim/content_renderers/user_renderer.rb +3 -1
- data/lib/decidim/core.rb +67 -12
- data/lib/decidim/core/engine.rb +60 -21
- data/lib/decidim/core/test.rb +6 -0
- data/lib/decidim/core/test/factories.rb +34 -8
- data/lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb +4 -4
- data/lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb +8 -8
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +52 -1
- data/lib/decidim/core/test/shared_examples/embed_resource_examples.rb +49 -0
- data/lib/decidim/core/test/shared_examples/follows_examples.rb +3 -3
- data/lib/decidim/core/test/shared_examples/manage_component_share_tokens.rb +83 -0
- data/lib/decidim/core/test/shared_examples/map_examples.rb +186 -0
- data/lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb +55 -0
- data/lib/decidim/core/test/shared_examples/resource_search_examples.rb +200 -0
- data/lib/decidim/core/test/shared_examples/scopable_resource_examples.rb +43 -0
- data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +12 -1
- data/lib/decidim/core/test/shared_examples/searchable_participatory_space_examples.rb +2 -2
- data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +15 -2
- data/lib/decidim/core/test/shared_examples/simple_event.rb +7 -0
- data/lib/decidim/core/test/shared_examples/system_endorse_resource_examples.rb +1 -0
- data/lib/decidim/core/test/shared_examples/traceable_interface_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/uncommentable_component_examples.rb +1 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/diffy_extension.rb +21 -0
- data/lib/decidim/events/base_event.rb +11 -9
- data/lib/decidim/exporters.rb +7 -0
- data/lib/decidim/exporters/csv.rb +15 -1
- data/lib/decidim/exporters/excel.rb +1 -1
- data/lib/decidim/exporters/export_manifest.rb +29 -0
- data/lib/decidim/exporters/pdf.rb +56 -0
- data/lib/decidim/file_validator_humanizer.rb +98 -0
- data/lib/decidim/form_builder.rb +65 -54
- data/lib/decidim/geocodable.rb +79 -0
- data/lib/decidim/has_attachments.rb +10 -0
- data/lib/decidim/has_upload_validations.rb +36 -0
- data/lib/decidim/map.rb +214 -0
- data/lib/decidim/map/autocomplete.rb +67 -0
- data/lib/decidim/map/dynamic_map.rb +89 -0
- data/lib/decidim/map/frontend.rb +97 -0
- data/lib/decidim/map/geocoding.rb +115 -0
- data/lib/decidim/map/provider.rb +12 -0
- data/lib/decidim/map/provider/autocomplete/here.rb +20 -0
- data/lib/decidim/map/provider/autocomplete/osm.rb +20 -0
- data/lib/decidim/map/provider/dynamic_map/here.rb +51 -0
- data/lib/decidim/map/provider/dynamic_map/osm.rb +13 -0
- data/lib/decidim/map/provider/geocoding/here.rb +58 -0
- data/lib/decidim/map/provider/geocoding/osm.rb +30 -0
- data/lib/decidim/map/provider/here.rb +21 -0
- data/lib/decidim/map/provider/osm.rb +22 -0
- data/lib/decidim/map/provider/static_map/here.rb +35 -0
- data/lib/decidim/map/provider/static_map/osm.rb +29 -0
- data/lib/decidim/map/static_map.rb +133 -0
- data/lib/decidim/map/utility.rb +38 -0
- data/lib/decidim/organization_settings.rb +267 -0
- data/lib/decidim/resource_manifest.rb +1 -1
- data/lib/decidim/scopable.rb +9 -6
- data/lib/decidim/scopable_component.rb +29 -1
- data/lib/decidim/scopable_participatory_space.rb +19 -0
- data/lib/decidim/scopable_resource.rb +21 -0
- data/lib/decidim/search_resource_fields_mapper.rb +15 -2
- data/lib/decidim/searchable.rb +4 -0
- data/lib/decidim/settings_manifest.rb +2 -1
- data/lib/decidim/shareable_with_token.rb +27 -0
- data/lib/decidim/snippets.rb +30 -0
- data/lib/decidim/translatable_attributes.rb +42 -4
- data/lib/decidim/translatable_resource.rb +78 -0
- data/lib/decidim/view_model.rb +1 -0
- data/lib/tasks/decidim_locales_tasks.rake +35 -0
- data/lib/tasks/decidim_tasks.rake +1 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.bg.js +14 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.da.js +14 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.eo.js +17 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.et.js +18 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fr-CA.js +16 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ga.js +15 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.hr.js +13 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.is.js +14 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ja.js +16 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.lt.js +16 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.lv.js +17 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.mt.js +15 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.sl.js +14 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.sr.js +16 -0
- metadata +138 -26
- data/app/helpers/decidim/multi_translation_helper.rb +0 -0
- data/lib/decidim/hashtaggable.rb +0 -24
@@ -60,19 +60,37 @@ module Decidim
|
|
60
60
|
{}
|
61
61
|
end
|
62
62
|
|
63
|
+
def default_filter_category_params
|
64
|
+
return "all" unless current_component.participatory_space.categories.any?
|
65
|
+
|
66
|
+
["all"] + current_component.participatory_space.categories.pluck(:id).map(&:to_s)
|
67
|
+
end
|
68
|
+
|
69
|
+
def default_filter_scope_params
|
70
|
+
return "all" unless current_component.scopes.any?
|
71
|
+
|
72
|
+
if current_component.scope
|
73
|
+
["all", current_component.scope.id] + current_component.scope.children.map { |scope| scope.id.to_s }
|
74
|
+
else
|
75
|
+
%w(all global) + current_component.scopes.pluck(:id).map(&:to_s)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
63
79
|
# If the controller responds to current_component, its search service uses the
|
64
80
|
# base class Decidim::ResourceSearch; else it uses the ParticipatorySpaceSearch.
|
65
81
|
# They need different context_params to set up the base_query:
|
66
82
|
# - ResourceSearch uses `component`
|
67
83
|
# - ParticipatorySpaceSearch uses `organization`
|
68
84
|
# - Both use `current_user`
|
85
|
+
# - Both need `organization` for localized searches in order to fetch the
|
86
|
+
# available locales from the organization in Decidim::ResourceSearch.
|
69
87
|
def context_params
|
70
|
-
context = {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
88
|
+
context = {
|
89
|
+
current_user: current_user,
|
90
|
+
organization: current_organization
|
91
|
+
}
|
92
|
+
context[:component] = current_component if respond_to?(:current_component)
|
93
|
+
|
76
94
|
context
|
77
95
|
end
|
78
96
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# A controller concern to enable flagging capabilities to its resources. Only
|
7
|
+
# affects the UI, so make sure you check the controller resources implement
|
8
|
+
# the `Decidim::Reportable` model concern.
|
9
|
+
module Flaggable
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
helper_method :flaggable_controller?
|
14
|
+
|
15
|
+
def flaggable_controller?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -22,6 +22,7 @@ module Decidim
|
|
22
22
|
# Next stop: Let's check whether auth is ok
|
23
23
|
unless user_signed_in?
|
24
24
|
flash[:warning] = t("actions.login_before_access", scope: "decidim.core")
|
25
|
+
store_location_for(:user, request.path)
|
25
26
|
return redirect_to decidim.new_user_session_path
|
26
27
|
end
|
27
28
|
end
|
@@ -23,7 +23,7 @@ module Decidim
|
|
23
23
|
|
24
24
|
# Returns a manager user if the real user has an active impersonation
|
25
25
|
def current_user
|
26
|
-
managed_user || real_user
|
26
|
+
@current_user ||= managed_user || real_user
|
27
27
|
end
|
28
28
|
|
29
29
|
# Clear the `@real_user` instance variable because otherwise that would be
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# This module provides capability for storing conditional snippets during the
|
7
|
+
# page view that need to be displayed in different part of the view than where
|
8
|
+
# they are registered at.
|
9
|
+
module NeedsSnippets
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
helper_method :snippets
|
14
|
+
end
|
15
|
+
|
16
|
+
def snippets
|
17
|
+
@snippets ||= Decidim::Snippets.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -10,7 +10,7 @@ module Decidim
|
|
10
10
|
OPTIONS = [20, 50, 100].freeze
|
11
11
|
|
12
12
|
included do
|
13
|
-
helper_method :per_page
|
13
|
+
helper_method :per_page, :page_offset
|
14
14
|
helper Decidim::PaginateHelper
|
15
15
|
|
16
16
|
def paginate(resources)
|
@@ -20,6 +20,10 @@ module Decidim
|
|
20
20
|
def per_page
|
21
21
|
params[:per_page] || OPTIONS.first
|
22
22
|
end
|
23
|
+
|
24
|
+
def page_offset
|
25
|
+
[params[:page].to_i - 1, 0].max * per_page
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# A controller concern to enable withawing the controller resources. Only
|
7
|
+
# affects the UI, so the actual logic to withdraw the resource will still need
|
8
|
+
# to be implemented.
|
9
|
+
module Withdrawable
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
helper_method :withdrawable_controller?
|
14
|
+
|
15
|
+
def withdrawable_controller?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -16,6 +16,7 @@ module Decidim
|
|
16
16
|
include ActionAuthorization
|
17
17
|
include ForceAuthentication
|
18
18
|
include SafeRedirect
|
19
|
+
include NeedsSnippets
|
19
20
|
|
20
21
|
helper Decidim::MetaTagsHelper
|
21
22
|
helper Decidim::DecidimFormHelper
|
@@ -38,6 +39,9 @@ module Decidim
|
|
38
39
|
# right page.
|
39
40
|
before_action :store_current_location
|
40
41
|
|
42
|
+
before_action :store_machine_translations_toggle
|
43
|
+
helper_method :machine_translations_toggled?
|
44
|
+
|
41
45
|
protect_from_forgery with: :exception, prepend: true
|
42
46
|
after_action :add_vary_header
|
43
47
|
|
@@ -59,6 +63,18 @@ module Decidim
|
|
59
63
|
store_location_for(:user, value)
|
60
64
|
end
|
61
65
|
|
66
|
+
# We store whether the user is requesting to toggle the translations or not.
|
67
|
+
# We need to store it this way because if we use an instance variable, then
|
68
|
+
# we're not able to access that value from inside the presenters, and we
|
69
|
+
# need it there to translate some attributes.
|
70
|
+
def store_machine_translations_toggle
|
71
|
+
RequestStore.store[:toggle_machine_translations] = params[:toggle_translations].present?
|
72
|
+
end
|
73
|
+
|
74
|
+
def machine_translations_toggled?
|
75
|
+
RequestStore.store[:toggle_machine_translations]
|
76
|
+
end
|
77
|
+
|
62
78
|
def skip_store_location?
|
63
79
|
# Skip if Devise already handles the redirection
|
64
80
|
return true if devise_controller? && redirect_url.blank?
|
@@ -24,13 +24,14 @@ module Decidim
|
|
24
24
|
helper Decidim::AttachmentsHelper
|
25
25
|
helper Decidim::SanitizeHelper
|
26
26
|
helper Decidim::PadHelper
|
27
|
+
helper Decidim::FilterParamsHelper
|
27
28
|
|
28
29
|
helper_method :current_component,
|
29
30
|
:current_participatory_space,
|
30
31
|
:current_manifest
|
31
32
|
|
32
33
|
before_action do
|
33
|
-
enforce_permission_to :read, :component, component: current_component
|
34
|
+
enforce_permission_to :read, :component, component: current_component, share_token: share_token
|
34
35
|
end
|
35
36
|
|
36
37
|
before_action :redirect_unless_feature_private
|
@@ -47,6 +48,10 @@ module Decidim
|
|
47
48
|
@current_manifest ||= current_component.manifest
|
48
49
|
end
|
49
50
|
|
51
|
+
def share_token
|
52
|
+
params[:share_token]
|
53
|
+
end
|
54
|
+
|
50
55
|
def permission_scope
|
51
56
|
:public
|
52
57
|
end
|
@@ -6,9 +6,12 @@ module Decidim
|
|
6
6
|
skip_before_action :store_current_location
|
7
7
|
|
8
8
|
def accept
|
9
|
-
response.set_cookie
|
10
|
-
|
11
|
-
|
9
|
+
response.set_cookie(
|
10
|
+
Decidim.config.consent_cookie_name,
|
11
|
+
value: "true",
|
12
|
+
path: "/",
|
13
|
+
expires: 1.year.from_now.utc
|
14
|
+
)
|
12
15
|
|
13
16
|
respond_to do |format|
|
14
17
|
format.js
|
@@ -77,8 +77,11 @@ module Decidim
|
|
77
77
|
render action: :update, locals: { message: message }
|
78
78
|
end
|
79
79
|
|
80
|
-
on(:invalid) do
|
81
|
-
render
|
80
|
+
on(:invalid) do |messages|
|
81
|
+
render action: :error, locals: {
|
82
|
+
error: I18n.t("messaging.conversations.update.error", scope: "decidim"),
|
83
|
+
messages: messages
|
84
|
+
}, status: :unprocessable_entity
|
82
85
|
end
|
83
86
|
end
|
84
87
|
end
|
@@ -4,6 +4,8 @@ module Decidim
|
|
4
4
|
# The form object that handles the data behind updating a user's
|
5
5
|
# account in her profile page.
|
6
6
|
class AccountForm < Form
|
7
|
+
include Decidim::HasUploadValidations
|
8
|
+
|
7
9
|
mimic :user
|
8
10
|
|
9
11
|
attribute :name
|
@@ -24,12 +26,14 @@ module Decidim
|
|
24
26
|
validates :password, confirmation: true
|
25
27
|
validates :password, password: { name: :name, email: :email, username: :nickname }, if: -> { password.present? }
|
26
28
|
validates :password_confirmation, presence: true, if: :password_present
|
27
|
-
validates :avatar,
|
29
|
+
validates :avatar, passthru: { to: Decidim::User }
|
28
30
|
|
29
31
|
validate :unique_email
|
30
32
|
validate :unique_nickname
|
31
33
|
validate :personal_url_format
|
32
34
|
|
35
|
+
alias organization current_organization
|
36
|
+
|
33
37
|
def personal_url
|
34
38
|
return if super.blank?
|
35
39
|
|
@@ -11,8 +11,8 @@ module Decidim
|
|
11
11
|
attribute :emendation_params, Hash
|
12
12
|
|
13
13
|
validates :amendable_gid, presence: true
|
14
|
-
validate :emendation_must_change_amendable
|
15
14
|
validate :amendable_form_must_be_valid
|
15
|
+
validate :emendation_must_change_amendable
|
16
16
|
|
17
17
|
def amendable
|
18
18
|
@amendable ||= GlobalID::Locator.locate_signed(amendable_gid)
|
@@ -4,6 +4,8 @@ module Decidim
|
|
4
4
|
module Amendable
|
5
5
|
# a form object common for amendments
|
6
6
|
class Form < Decidim::Form
|
7
|
+
include Decidim::TranslatableAttributes
|
8
|
+
|
7
9
|
mimic :amendment
|
8
10
|
|
9
11
|
def amendment
|
@@ -29,7 +31,7 @@ module Decidim
|
|
29
31
|
return unless %w(title body).all? { |attr| attr.in? amendable_fields_as_string }
|
30
32
|
|
31
33
|
emendation = amendable.class.new(emendation_params)
|
32
|
-
return unless amendable.title == emendation.title
|
34
|
+
return unless translated_attribute(amendable.title) == emendation.title
|
33
35
|
return unless normalized_body(amendable) == normalized_body(emendation)
|
34
36
|
|
35
37
|
amendable_form.errors.add(:title, :identical)
|
@@ -38,22 +40,44 @@ module Decidim
|
|
38
40
|
|
39
41
|
# Normalizes the escape sequences used for newlines.
|
40
42
|
def normalized_body(resource)
|
41
|
-
|
43
|
+
body = translated_attribute(resource.body)
|
44
|
+
Decidim::ContentParsers::NewlineParser.new(body, context: {}).rewrite
|
42
45
|
end
|
43
46
|
|
44
47
|
# Validates the emendation using the amendable form.
|
45
48
|
def amendable_form_must_be_valid
|
46
49
|
parse_hashtaggable_params
|
50
|
+
original_form.validate unless defined?(@original_form) # Preserves previously added errors.
|
51
|
+
|
47
52
|
amendable_form.validate unless defined?(@amendable_form) # Preserves previously added errors.
|
53
|
+
|
54
|
+
compare_amendable_form_errors(@amendable_form.errors.dup) if @original_form.present? && @original_form.errors.details.count.positive?
|
55
|
+
|
48
56
|
@errors = @amendable_form.errors
|
49
57
|
end
|
50
58
|
|
59
|
+
# Compare the amendable_form errors and original_form errors
|
60
|
+
# If amendable_form add more errors than original, error is stored in amendable_form errors.
|
61
|
+
#
|
62
|
+
# Params: amendable_form_errors => Duplicated @amendable_form.errors
|
63
|
+
def compare_amendable_form_errors(amendable_form_errors)
|
64
|
+
@amendable_form.errors.clear
|
65
|
+
@original_form.errors.details.keys.each do |key|
|
66
|
+
errors = amendable_form_errors.details[key] - @original_form.errors.details[key]
|
67
|
+
|
68
|
+
errors.map do |hash|
|
69
|
+
@amendable_form.errors.add(key, hash[:error]) unless @amendable_form.errors.details[key].include? error: hash[:error]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
51
74
|
# Parses :title and :body attribute values with HashtagParser.
|
52
75
|
def parse_hashtaggable_params
|
53
76
|
emendation_params.each do |key, value|
|
54
77
|
next unless [:title, :body].include?(key)
|
55
78
|
|
56
|
-
|
79
|
+
clean_value = translated_attribute(value)
|
80
|
+
emendation_params[key] = Decidim::ContentParsers::HashtagParser.new(clean_value, form_context).rewrite
|
57
81
|
end
|
58
82
|
end
|
59
83
|
|
@@ -63,6 +87,23 @@ module Decidim
|
|
63
87
|
@amendable_form ||= amendable.amendable_form.from_params(emendation_params).with_context(form_context)
|
64
88
|
end
|
65
89
|
|
90
|
+
def original_form
|
91
|
+
@original_form ||= i18n_amendable
|
92
|
+
.amendable_form
|
93
|
+
.from_model(@i18n_amendable)
|
94
|
+
.with_context(
|
95
|
+
current_component: @i18n_amendable.component,
|
96
|
+
current_participatory_space: @i18n_amendable.participatory_space
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def i18n_amendable
|
101
|
+
@i18n_amendable ||= amendable
|
102
|
+
@i18n_amendable.title = translated_attribute(amendable.title)
|
103
|
+
@i18n_amendable.body = normalized_body(amendable)
|
104
|
+
@i18n_amendable
|
105
|
+
end
|
106
|
+
|
66
107
|
# Returns the amendable fields keys as String.
|
67
108
|
def amendable_fields_as_string
|
68
109
|
amendable.amendable_fields.map(&:to_s)
|
@@ -4,12 +4,16 @@ module Decidim
|
|
4
4
|
# A form object used to create attachments.
|
5
5
|
#
|
6
6
|
class AttachmentForm < Form
|
7
|
+
include Decidim::HasUploadValidations
|
8
|
+
|
7
9
|
attribute :title, String
|
8
10
|
attribute :file
|
9
11
|
|
10
12
|
mimic :attachment
|
11
13
|
|
12
14
|
validates :title, presence: true, if: ->(form) { form.file.present? }
|
13
|
-
validates :file,
|
15
|
+
validates :file, passthru: { to: Decidim::Attachment }, if: ->(form) { form.file.present? }
|
16
|
+
|
17
|
+
alias organization current_organization
|
14
18
|
end
|
15
19
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Decidim
|
4
4
|
# The form object that handles the data behind creating a user group.
|
5
5
|
class UserGroupForm < Form
|
6
|
+
include Decidim::HasUploadValidations
|
7
|
+
|
6
8
|
mimic :group
|
7
9
|
|
8
10
|
attribute :name
|
@@ -18,13 +20,15 @@ module Decidim
|
|
18
20
|
validates :nickname, presence: true
|
19
21
|
|
20
22
|
validates :nickname, length: { maximum: Decidim::User.nickname_max_length, allow_blank: true }
|
21
|
-
validates :avatar,
|
23
|
+
validates :avatar, passthru: { to: Decidim::UserGroup }
|
22
24
|
|
23
25
|
validate :unique_document_number
|
24
26
|
validate :unique_email
|
25
27
|
validate :unique_name
|
26
28
|
validate :unique_nickname
|
27
29
|
|
30
|
+
alias organization current_organization
|
31
|
+
|
28
32
|
private
|
29
33
|
|
30
34
|
def unique_document_number
|
@@ -6,18 +6,6 @@ module Decidim
|
|
6
6
|
options[:from].presence || context[:from].presence
|
7
7
|
end
|
8
8
|
|
9
|
-
def proposals_controller?
|
10
|
-
context[:controller].class.to_s == "Decidim::Proposals::ProposalsController"
|
11
|
-
end
|
12
|
-
|
13
|
-
def collaborative_drafts_controller?
|
14
|
-
context[:controller].class.to_s == "Decidim::Proposals::CollaborativeDraftsController"
|
15
|
-
end
|
16
|
-
|
17
|
-
def posts_controller?
|
18
|
-
context[:controller].class.to_s == "Decidim::Blogs::PostsController"
|
19
|
-
end
|
20
|
-
|
21
9
|
def index_action?
|
22
10
|
context[:controller].action_name == "index"
|
23
11
|
end
|
@@ -32,15 +20,15 @@ module Decidim
|
|
32
20
|
|
33
21
|
def withdrawable?
|
34
22
|
return unless from_context
|
35
|
-
return unless
|
23
|
+
return unless context[:controller].try(:withdrawable_controller?)
|
36
24
|
return if index_action?
|
37
25
|
|
38
26
|
from_context.withdrawable_by?(current_user)
|
39
27
|
end
|
40
28
|
|
41
|
-
def
|
29
|
+
def flaggable?
|
42
30
|
return unless from_context
|
43
|
-
return unless
|
31
|
+
return unless context[:controller].try(:flaggable_controller?)
|
44
32
|
return if index_action?
|
45
33
|
|
46
34
|
true
|