decidim-core 0.22.0 → 0.23.3
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 +4 -4
- 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/layouts/_home.scss +5 -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/content_blocks/sub_hero/show.erb +3 -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/tos_page/announcement.erb +0 -1
- data/app/cells/decidim/tos_page/form.erb +17 -0
- 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 +20 -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 +6 -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 +1 -8
- data/app/helpers/decidim/sanitize_helper.rb +8 -0
- data/app/helpers/decidim/scopes_helper.rb +5 -5
- data/app/helpers/decidim/translations_helper.rb +7 -1
- data/app/jobs/decidim/data_portability_export_job.rb +3 -3
- 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/jobs/decidim/open_data_job.rb +1 -1
- data/app/mailers/decidim/application_mailer.rb +1 -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 +54 -10
- 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.rb +11 -3
- data/app/models/decidim/user_base_entity.rb +6 -2
- data/app/permissions/decidim/permissions.rb +9 -0
- data/app/presenters/decidim/admin_log/component_presenter.rb +2 -2
- data/app/presenters/decidim/admin_log/moderation_presenter.rb +2 -2
- data/app/presenters/decidim/admin_log/organization_presenter.rb +2 -2
- data/app/presenters/decidim/admin_log/user_presenter.rb +2 -2
- data/app/presenters/decidim/log/base_presenter.rb +10 -2
- 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/newsletter_scrubber.rb +31 -0
- 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/services/decidim/tokenizer.rb +38 -0
- data/app/services/decidim/traceability.rb +3 -0
- data/app/uploaders/decidim/application_uploader.rb +19 -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/newsletter_mailer/newsletter.html.erb +1 -1
- data/app/views/decidim/notification_mailer/event_received.html.erb +2 -2
- data/app/views/decidim/pages/_standalone.html.erb +1 -1
- data/app/views/decidim/pages/_tabbed.html.erb +1 -1
- 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 +36 -9
- data/config/locales/cs.yml +54 -27
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +156 -128
- 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 +29 -2
- 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 +9 -4
- data/config/locales/fi-plain.yml +28 -1
- data/config/locales/fi.yml +34 -7
- data/config/locales/fr-CA.yml +32 -4
- data/config/locales/fr.yml +65 -37
- data/config/locales/ga-IE.yml +0 -8
- data/config/locales/gl.yml +10 -5
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +7 -5
- 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 +37 -9
- 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} +2 -5
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +34 -12
- data/config/locales/no.yml +150 -8
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +89 -72
- data/config/locales/pt-BR.yml +4 -5
- 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/si-LK.yml +1 -0
- data/config/locales/sk.yml +3 -5
- data/config/locales/sl.yml +8 -7
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +0 -9
- data/config/locales/sv.yml +19 -8
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +588 -247
- 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 +12 -6
- 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 +65 -21
- data/lib/decidim/core/test.rb +8 -0
- data/lib/decidim/core/test/factories.rb +34 -8
- data/lib/decidim/core/test/shared_examples/admin_log_presenter_examples.rb +34 -0
- 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/counts_commentators_as_newsletter_participants.rb +31 -0
- 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 +29 -11
- 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 +68 -56
- data/lib/decidim/geocodable.rb +79 -0
- data/lib/decidim/has_attachments.rb +10 -0
- data/lib/decidim/has_private_users.rb +1 -1
- 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/newsletter_participant.rb +2 -4
- data/lib/decidim/organization_settings.rb +267 -0
- data/lib/decidim/paddable.rb +11 -4
- 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 +17 -4
- data/lib/decidim/searchable.rb +6 -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/premailer/adapter/decidim.rb +33 -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 +149 -30
- data/app/cells/decidim/tos_page/sticky_form.erb +0 -29
- data/app/helpers/decidim/multi_translation_helper.rb +0 -0
- data/lib/decidim/hashtaggable.rb +0 -24
@@ -44,7 +44,7 @@ module Decidim
|
|
44
44
|
# Add a white list of extensions which are allowed to be uploaded.
|
45
45
|
# For images you might use something like this:
|
46
46
|
def extension_whitelist
|
47
|
-
|
47
|
+
Decidim.organization_settings(model).upload_allowed_file_extensions_image
|
48
48
|
end
|
49
49
|
|
50
50
|
# A simple check to avoid DoS with maliciously crafted images, or just to
|
@@ -60,7 +60,7 @@ module Decidim
|
|
60
60
|
|
61
61
|
def validate_size
|
62
62
|
manipulate! do |image|
|
63
|
-
validation_error!(I18n.t("carrierwave.errors.image_too_big")) if image.size >
|
63
|
+
validation_error!(I18n.t("carrierwave.errors.image_too_big")) if image.size > maximum_upload_size
|
64
64
|
image
|
65
65
|
end
|
66
66
|
end
|
@@ -82,5 +82,9 @@ module Decidim
|
|
82
82
|
model.errors.add(mounted_as, text)
|
83
83
|
raise CarrierWave::IntegrityError, text
|
84
84
|
end
|
85
|
+
|
86
|
+
def maximum_upload_size
|
87
|
+
Decidim.organization_settings(model).upload_maximum_file_size
|
88
|
+
end
|
85
89
|
end
|
86
90
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This class deals with uploading record specific images that have more
|
5
|
+
# limited content types than the defaults.
|
6
|
+
class RecordImageUploader < ImageUploader
|
7
|
+
def content_type_whitelist
|
8
|
+
%w(image/jpeg image/png)
|
9
|
+
end
|
10
|
+
|
11
|
+
def extension_whitelist
|
12
|
+
%w(jpeg jpg png)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -8,7 +8,6 @@ class EtiquetteValidator < ActiveModel::EachValidator
|
|
8
8
|
|
9
9
|
validate_caps(record, attribute, value)
|
10
10
|
validate_marks(record, attribute, value)
|
11
|
-
validate_long_words(record, attribute, value)
|
12
11
|
validate_caps_first(record, attribute, value)
|
13
12
|
validate_length(record, attribute, value)
|
14
13
|
end
|
@@ -27,12 +26,6 @@ class EtiquetteValidator < ActiveModel::EachValidator
|
|
27
26
|
record.errors.add(attribute, options[:message] || :too_many_marks)
|
28
27
|
end
|
29
28
|
|
30
|
-
def validate_long_words(record, attribute, value)
|
31
|
-
return if value.scan(/[A-z]{35,}/).empty?
|
32
|
-
|
33
|
-
record.errors.add(attribute, options[:message] || :long_words)
|
34
|
-
end
|
35
|
-
|
36
29
|
def validate_caps_first(record, attribute, value)
|
37
30
|
return if value.scan(/\A[a-z]{1}/).empty?
|
38
31
|
|
@@ -4,10 +4,9 @@
|
|
4
4
|
# an existing address and computes its coordinates.
|
5
5
|
class GeocodingValidator < ActiveModel::EachValidator
|
6
6
|
def validate_each(record, attribute, value)
|
7
|
-
if Decidim.
|
8
|
-
|
9
|
-
|
10
|
-
coordinates = Geocoder.coordinates(value)
|
7
|
+
if Decidim::Map.available?(:geocoding) && record.component.present?
|
8
|
+
geocoder = geocoder_for(record.component.organization)
|
9
|
+
coordinates = geocoder.coordinates(value)
|
11
10
|
|
12
11
|
if coordinates.present?
|
13
12
|
record.latitude = coordinates.first
|
@@ -19,4 +18,10 @@ class GeocodingValidator < ActiveModel::EachValidator
|
|
19
18
|
record.errors.add(attribute, :invalid)
|
20
19
|
end
|
21
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def geocoder_for(organization)
|
25
|
+
Decidim::Map.geocoding(organization: organization)
|
26
|
+
end
|
22
27
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This validator passes through the file upload validations on a record
|
4
|
+
# attribute to an associated record. Useful e.g. with the forms that are not
|
5
|
+
# aware of the actual record's validators but they still need to apply the same
|
6
|
+
# validators as in the model they represent. Needs to be configured with the
|
7
|
+
# target class and optionally the target attribute where the validators are
|
8
|
+
# fetched from. By default the attribute name matches the attribute the
|
9
|
+
# validator is set for. Works only for each validators.
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
#
|
13
|
+
# class ParticipantForm < Decidim::Form
|
14
|
+
# # Passes both the validator class only
|
15
|
+
# validates :avatar_image, passthru: { to: Person }
|
16
|
+
#
|
17
|
+
# # Passes both the validator class and attribute
|
18
|
+
# validates :image, passthru: { to: Person, attribute: :avatar_image }
|
19
|
+
# end
|
20
|
+
class PassthruValidator < ActiveModel::EachValidator
|
21
|
+
def validate_each(record, attribute, value)
|
22
|
+
return unless target_class
|
23
|
+
|
24
|
+
dummy_attr = target_attribute(attribute)
|
25
|
+
|
26
|
+
# Create a dummy record for which the validations are actually run on
|
27
|
+
dummy = validation_record(record)
|
28
|
+
|
29
|
+
target_validators(attribute).each do |validator|
|
30
|
+
next unless validator.is_a?(ActiveModel::EachValidator)
|
31
|
+
next unless check_validator_conditions(dummy, validator)
|
32
|
+
|
33
|
+
dummy.errors.clear
|
34
|
+
validator.validate_each(dummy, dummy_attr, value)
|
35
|
+
dummy.errors[dummy_attr].each do |err|
|
36
|
+
record.errors.add(attribute, err)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Creates a dummy validation record that passes the correct file upload
|
42
|
+
# validation context from the original record for the validators.
|
43
|
+
def validation_record(record)
|
44
|
+
dummy = target_instance(record)
|
45
|
+
if dummy.is_a?(Decidim::Attachment)
|
46
|
+
if record.respond_to?(:attached_to)
|
47
|
+
dummy.attached_to = record.attached_to
|
48
|
+
elsif record.respond_to?(:organization)
|
49
|
+
dummy.attached_to = record.organization
|
50
|
+
end
|
51
|
+
elsif dummy.respond_to?(:organization=) && record.respond_to?(:organization)
|
52
|
+
dummy.organization = record.organization
|
53
|
+
end
|
54
|
+
dummy
|
55
|
+
end
|
56
|
+
|
57
|
+
def target_validators(attribute)
|
58
|
+
target_class.validators_on(target_attribute(attribute))
|
59
|
+
end
|
60
|
+
|
61
|
+
def target_class
|
62
|
+
options[:to]
|
63
|
+
end
|
64
|
+
|
65
|
+
def target_attribute(default = nil)
|
66
|
+
options[:attribute] || default
|
67
|
+
end
|
68
|
+
|
69
|
+
def target_instance(record)
|
70
|
+
instance_attributes = begin
|
71
|
+
if options[:with].respond_to?(:call)
|
72
|
+
options[:with].call(record)
|
73
|
+
else
|
74
|
+
options[:with] || {}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
instance_attributes.each do |key, val|
|
78
|
+
instance_attributes[key] = val.call(record) if val.respond_to?(:call)
|
79
|
+
end
|
80
|
+
|
81
|
+
target_class.new(instance_attributes)
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def check_validator_conditions(record, validator)
|
87
|
+
if (condition = validator.options[:if])
|
88
|
+
if_result = begin
|
89
|
+
if condition.respond_to?(:call)
|
90
|
+
condition.call(record)
|
91
|
+
else
|
92
|
+
record.public_send(condition)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
return false unless if_result
|
96
|
+
end
|
97
|
+
|
98
|
+
if (condition = validator.options[:unless])
|
99
|
+
unless_result = begin
|
100
|
+
if condition.respond_to?(:call)
|
101
|
+
condition.call(record)
|
102
|
+
else
|
103
|
+
record.public_send(condition)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
return false if unless_result
|
107
|
+
end
|
108
|
+
|
109
|
+
true
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This validator ensures the scope is a scope of a component scope
|
4
|
+
class ScopeBelongsToComponentValidator < ActiveModel::EachValidator
|
5
|
+
def validate_each(record, attribute, value)
|
6
|
+
return unless component_for(record)
|
7
|
+
|
8
|
+
record.errors.add(attribute, :invalid) if component_for(record).out_of_scope?(Decidim::Scope.find_by(id: value))
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def component_for(record)
|
14
|
+
record.try(:component) || record.try(:current_component)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This validator ensures the files to be uploaded match the attached uploader's
|
4
|
+
# content types. This prevents CarrierWave from uploading the records before
|
5
|
+
# they pass the content type validations.
|
6
|
+
class UploaderContentTypeValidator < ActiveModel::Validations::FileContentTypeValidator
|
7
|
+
def validate_each(record, attribute, value)
|
8
|
+
begin
|
9
|
+
values = parse_values(value)
|
10
|
+
rescue JSON::ParserError
|
11
|
+
record.errors.add attribute, :invalid
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
15
|
+
return if values.empty?
|
16
|
+
|
17
|
+
uploader = record.send(attribute)
|
18
|
+
return unless uploader
|
19
|
+
return unless uploader.is_a?(Decidim::ApplicationUploader)
|
20
|
+
|
21
|
+
mode = option_value(record, :mode)
|
22
|
+
allowed_types = uploader.content_type_whitelist || []
|
23
|
+
forbidden_types = uploader.content_type_blacklist || []
|
24
|
+
|
25
|
+
values.each do |val|
|
26
|
+
val_mode = mode
|
27
|
+
|
28
|
+
# The :strict mode would be more robust for the content type detection if
|
29
|
+
# the value does not know its own content type. However, this would
|
30
|
+
# require the command line utility named `file` which is only available in
|
31
|
+
# *nix. This would also require adding a new gem dependency for running
|
32
|
+
# the CLI utility, Terrapin or Cocaine in older versions of the
|
33
|
+
# file_validators gem. The :relaxed mode detects the content type based on
|
34
|
+
# the file extension through the mime-types gem.
|
35
|
+
val_mode = :relaxed if val_mode.blank? && !val.respond_to?(:content_type)
|
36
|
+
|
37
|
+
content_type = get_content_type(val, val_mode)
|
38
|
+
validate_whitelist(record, attribute, content_type, allowed_types)
|
39
|
+
validate_blacklist(record, attribute, content_type, forbidden_types)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_validity!; end
|
44
|
+
end
|
@@ -17,8 +17,8 @@
|
|
17
17
|
<% authorizations.statuses.each do |status| %>
|
18
18
|
<% next if status.ok? || authorizations.global_code && status.code != base_code %>
|
19
19
|
<p><%= t ".#{status.code}.explanation", authorization: t("#{status.handler_name}.name", scope: "decidim.authorization_handlers") %></p>
|
20
|
-
<%
|
21
|
-
<p><%= t
|
20
|
+
<% [status.data[:extra_explanation]].flatten.compact.each do |extra_explanation| %>
|
21
|
+
<p><%= t extra_explanation[:key], **extra_explanation[:params] %></p>
|
22
22
|
<% end %>
|
23
23
|
<% if status.data[:fields] %>
|
24
24
|
<ul>
|
@@ -19,7 +19,9 @@
|
|
19
19
|
</div>
|
20
20
|
</div>
|
21
21
|
|
22
|
-
|
22
|
+
<% cache current_organization do %>
|
23
|
+
<%= render "decidim/devise/shared/omniauth_buttons" %>
|
24
|
+
<% end %>
|
23
25
|
|
24
26
|
<div class="row">
|
25
27
|
<div class="columns large-6 medium-10 medium-centered">
|
@@ -21,7 +21,9 @@
|
|
21
21
|
<% end %>
|
22
22
|
</div>
|
23
23
|
</div>
|
24
|
-
|
24
|
+
<% cache current_organization do %>
|
25
|
+
<%= render "decidim/devise/shared/omniauth_buttons" %>
|
26
|
+
<% end %>
|
25
27
|
|
26
28
|
<% if current_organization.sign_in_enabled? %>
|
27
29
|
<div class="row">
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="reveal" id="messageErrorModal" data-reveal>
|
2
|
+
<div class="reveal__header">
|
3
|
+
<h2 class="reveal__title"><%= error %></h2>
|
4
|
+
<button class="close-button" data-close aria-label="<%= t(".close") %>"
|
5
|
+
type="button">
|
6
|
+
<span aria-hidden="true">×</span>
|
7
|
+
</button>
|
8
|
+
</div>
|
9
|
+
<div class="reveal__body">
|
10
|
+
<p><%= t(".intro") %></p>
|
11
|
+
<p>
|
12
|
+
<%= messages.join("<br>") %>
|
13
|
+
</p>
|
14
|
+
<p><%= t(".correct_errors") %></p>
|
15
|
+
</div>
|
16
|
+
<div class="reveal__footer">
|
17
|
+
<div class="buttons button--double">
|
18
|
+
<a class="button" role="button" href="#" data-close aria-label="<%= t(".ok") %>"><%= t(".ok") %></a>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
var $messageError = $("#messageErrorModal");
|
2
|
+
if ($messageError.length > 0) {
|
3
|
+
$messageError.foundation("_destroy").remove();
|
4
|
+
}
|
5
|
+
|
6
|
+
$("#messages").append("<%= j(render "error_modal", error: error, messages: messages).html_safe %>");
|
7
|
+
$messageError = $("#messageErrorModal");
|
8
|
+
|
9
|
+
var messageErrorReveal = new Foundation.Reveal($messageError);
|
10
|
+
messageErrorReveal.open();
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
<p><%= @event_instance.email_intro %></p>
|
4
4
|
|
5
|
-
<% if @event_instance.try(:
|
5
|
+
<% if @event_instance.try(:safe_resource_text).present? %>
|
6
6
|
<blockquote>
|
7
7
|
<p>
|
8
|
-
<%= @event_instance.
|
8
|
+
<%= @event_instance.safe_resource_text %>
|
9
9
|
</p>
|
10
10
|
</blockquote>
|
11
11
|
<% end %>
|