decidim-core 0.18.1 → 0.19.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 +3 -0
- data/app/assets/javascripts/decidim/social_share.js +2 -0
- data/app/assets/stylesheets/decidim/extras/_social_share.css.scss +36 -0
- data/app/assets/stylesheets/decidim/modules/_input-gallery.scss +24 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +1 -1
- data/app/cells/decidim/activities_cell.rb +13 -8
- data/app/cells/decidim/activity_cell.rb +19 -5
- data/app/cells/decidim/address/details.erb +2 -2
- data/app/cells/decidim/amendable/amenders_list/show.erb +1 -1
- data/app/cells/decidim/amendable/amenders_list_cell.rb +5 -1
- data/app/cells/decidim/amendable/announcement_cell.rb +22 -9
- data/app/cells/decidim/amendable/wizard_step_form_cell.rb +121 -0
- data/app/cells/decidim/announcement_cell.rb +1 -0
- data/app/cells/decidim/author_cell.rb +7 -0
- data/app/cells/decidim/card_m_cell.rb +3 -1
- data/app/cells/decidim/coauthorships_cell.rb +3 -1
- data/app/cells/decidim/collapsible_authors_cell.rb +1 -0
- data/app/cells/decidim/collapsible_list_cell.rb +1 -0
- data/app/cells/decidim/content_blocks/highlighted_content_banner_cell.rb +1 -0
- data/app/cells/decidim/content_blocks/last_activity_cell.rb +3 -2
- data/app/cells/decidim/content_blocks/metrics_cell.rb +1 -0
- data/app/cells/decidim/content_blocks/stats_cell.rb +1 -0
- data/app/cells/decidim/content_blocks/sub_hero_cell.rb +1 -0
- data/app/cells/decidim/diff_cell.rb +1 -1
- data/app/cells/decidim/fingerprint/show.erb +1 -1
- data/app/cells/decidim/follow_button_cell.rb +3 -0
- data/app/cells/decidim/members_cell.rb +1 -0
- data/app/cells/decidim/notifications/show.erb +1 -1
- data/app/cells/decidim/profile_cell.rb +1 -0
- data/app/cells/decidim/profile_sidebar_cell.rb +4 -0
- data/app/cells/decidim/search_results_cell.rb +1 -0
- data/app/cells/decidim/search_results_section/show.erb +1 -1
- data/app/cells/decidim/tos_page_cell.rb +1 -0
- data/app/cells/decidim/user_group_pending_invitations_list_cell.rb +1 -0
- data/app/cells/decidim/user_group_pending_requests_list_cell.rb +1 -0
- data/app/cells/decidim/wizard_step_form/wizard_aside.erb +14 -0
- data/app/cells/decidim/wizard_step_form/wizard_header.erb +18 -0
- data/app/cells/decidim/wizard_step_form_cell.rb +112 -0
- data/app/commands/decidim/amendable/accept.rb +1 -1
- data/app/commands/decidim/amendable/create_draft.rb +70 -0
- data/app/commands/decidim/amendable/destroy_draft.rb +40 -0
- data/app/commands/decidim/amendable/promote.rb +13 -11
- data/app/commands/decidim/amendable/publish_draft.rb +76 -0
- data/app/commands/decidim/amendable/update_draft.rb +54 -0
- data/app/commands/decidim/amendable/withdraw.rb +31 -15
- data/app/commands/decidim/create_follow.rb +1 -0
- data/app/commands/decidim/create_omniauth_registration.rb +22 -4
- data/app/commands/decidim/create_registration.rb +5 -0
- data/app/commands/decidim/delete_follow.rb +1 -0
- data/app/commands/decidim/search.rb +1 -0
- data/app/controllers/concerns/decidim/action_authorization.rb +2 -0
- data/app/controllers/concerns/decidim/amendments_controller.rb +148 -28
- data/app/controllers/concerns/decidim/devise_controllers.rb +3 -2
- data/app/controllers/concerns/decidim/force_authentication.rb +38 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +1 -0
- data/app/controllers/concerns/decidim/locale_switcher.rb +44 -17
- data/app/controllers/concerns/decidim/needs_tos_accepted.rb +8 -0
- data/app/controllers/concerns/decidim/orderable.rb +36 -0
- data/app/controllers/concerns/decidim/participatory_space_context.rb +2 -0
- data/app/controllers/concerns/decidim/safe_redirect.rb +24 -0
- data/app/controllers/decidim/application_controller.rb +19 -2
- data/app/controllers/decidim/devise/confirmations_controller.rb +6 -0
- data/app/controllers/decidim/devise/invitations_controller.rb +8 -4
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +4 -1
- data/app/controllers/decidim/errors_controller.rb +3 -0
- data/app/controllers/decidim/follows_controller.rb +2 -2
- data/app/controllers/decidim/messaging/conversations_controller.rb +2 -2
- data/app/controllers/decidim/profiles_controller.rb +4 -1
- data/app/controllers/decidim/scopes_controller.rb +16 -4
- data/app/events/decidim/amendable/amendment_base_event.rb +4 -0
- data/app/forms/decidim/account_form.rb +1 -1
- data/app/forms/decidim/amendable/create_form.rb +3 -19
- data/app/forms/decidim/amendable/edit_form.rb +22 -0
- data/app/forms/decidim/amendable/form.rb +42 -20
- data/app/forms/decidim/amendable/promote_form.rb +4 -7
- data/app/forms/decidim/amendable/publish_form.rb +21 -0
- data/app/forms/decidim/amendable/reject_form.rb +1 -1
- data/app/forms/decidim/amendable/review_form.rb +9 -4
- data/app/forms/decidim/invite_user_form.rb +1 -0
- data/app/forms/decidim/notifications_settings_form.rb +1 -0
- data/app/forms/decidim/registration_form.rb +4 -3
- data/app/forms/decidim/user_group_form.rb +1 -0
- data/app/forms/decidim/user_interests_form.rb +1 -0
- data/app/helpers/decidim/amendments_helper.rb +33 -19
- data/app/helpers/decidim/cells_helper.rb +2 -0
- data/app/helpers/decidim/layout_helper.rb +1 -0
- data/app/helpers/decidim/map_helper.rb +1 -1
- data/app/helpers/decidim/meta_tags_helper.rb +1 -0
- data/app/helpers/decidim/resource_reference_helper.rb +1 -0
- data/app/jobs/decidim/event_publisher_job.rb +60 -0
- data/app/jobs/decidim/metric_job.rb +1 -0
- data/app/models/decidim/action_log.rb +12 -0
- data/app/models/decidim/amendment.rb +31 -2
- data/app/models/decidim/attachment.rb +2 -0
- data/app/models/decidim/authorization.rb +1 -0
- data/app/models/decidim/category.rb +1 -0
- data/app/models/decidim/component.rb +7 -0
- data/app/models/decidim/content_block.rb +1 -0
- data/app/models/decidim/follow.rb +3 -0
- data/app/models/decidim/identity.rb +1 -0
- data/app/models/decidim/impersonation_log.rb +2 -0
- data/app/models/decidim/newsletter.rb +1 -0
- data/app/models/decidim/participatory_process_user_role.rb +1 -0
- data/app/models/decidim/participatory_space_private_user.rb +1 -0
- data/app/models/decidim/permission_action.rb +2 -0
- data/app/models/decidim/report.rb +1 -0
- data/app/models/decidim/scope.rb +1 -0
- data/app/models/decidim/searchable_resource.rb +1 -1
- data/app/models/decidim/static_page.rb +1 -0
- data/app/models/decidim/user.rb +2 -0
- data/app/permissions/decidim/permissions.rb +18 -14
- data/app/permissions/decidim/user_manager_permissions.rb +9 -2
- data/app/presenters/decidim/admin_log/organization_presenter.rb +1 -0
- data/app/presenters/decidim/admin_log/participatory_space_private_user_presenter.rb +1 -1
- data/app/presenters/decidim/admin_log/user_presenter.rb +1 -1
- data/app/presenters/decidim/hashtag_presenter.rb +1 -1
- data/app/presenters/decidim/log/base_presenter.rb +1 -0
- data/app/presenters/decidim/log/diff_presenter.rb +1 -1
- data/app/presenters/decidim/log/value_types/area_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/area_type_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/currency_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/date_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/locale_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/percentage_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/scope_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/scope_type_presenter.rb +1 -0
- data/app/presenters/decidim/metric_charts_presenter.rb +1 -0
- data/app/presenters/decidim/metric_object_presenter.rb +4 -0
- data/app/queries/decidim/metric_manage.rb +3 -0
- data/app/queries/decidim/metric_measure.rb +1 -0
- data/app/queries/decidim/metrics/followers_metric_manage.rb +3 -0
- data/app/queries/decidim/metrics/participants_metric_manage.rb +4 -0
- data/app/queries/decidim/similar_emendations.rb +56 -0
- data/app/resolvers/decidim/core/metric_resolver.rb +1 -0
- data/app/services/decidim/action_authorizer.rb +1 -0
- data/app/services/decidim/action_logger.rb +1 -0
- data/app/services/decidim/activity_search.rb +1 -0
- data/app/services/decidim/email_notification_generator.rb +4 -0
- data/app/services/decidim/notification_generator.rb +2 -0
- data/app/services/decidim/notification_generator_for_recipient.rb +0 -1
- data/app/services/decidim/resource_search.rb +1 -1
- data/app/services/decidim/traceability.rb +1 -0
- data/app/uploaders/decidim/application_uploader.rb +1 -0
- data/app/uploaders/decidim/attachment_uploader.rb +16 -0
- data/app/uploaders/decidim/avatar_uploader.rb +0 -2
- data/app/uploaders/decidim/data_portability_uploader.rb +1 -0
- data/app/uploaders/decidim/homepage_image_uploader.rb +0 -2
- data/app/uploaders/decidim/image_uploader.rb +15 -1
- data/app/uploaders/decidim/oauth_application_logo_uploader.rb +0 -1
- data/app/uploaders/decidim/official_image_footer_uploader.rb +0 -1
- data/app/uploaders/decidim/official_image_header_uploader.rb +0 -1
- data/app/uploaders/decidim/open_data_uploader.rb +1 -0
- data/app/validators/etiquette_validator.rb +5 -0
- data/app/views/decidim/account/delete.html.erb +2 -2
- data/app/views/decidim/account/show.html.erb +1 -1
- data/app/views/decidim/amendments/_edit_form_fields.html.erb +16 -13
- data/app/views/decidim/amendments/_similar_emendation.html.erb +24 -0
- data/app/views/decidim/amendments/compare_draft.html.erb +21 -0
- data/app/views/decidim/amendments/edit_draft.html.erb +31 -0
- data/app/views/decidim/amendments/new.html.erb +5 -17
- data/app/views/decidim/amendments/preview_draft.html.erb +32 -0
- data/app/views/decidim/amendments/review.html.erb +5 -3
- data/app/views/decidim/application/_document.html.erb +1 -1
- data/app/views/decidim/application/_photos.html.erb +1 -1
- data/app/views/decidim/data_portability/show.html.erb +1 -1
- data/app/views/decidim/devise/invitations/edit.html.erb +2 -2
- data/app/views/decidim/devise/sessions/new.html.erb +1 -1
- data/app/views/decidim/doorkeeper/authorizations/new.html.erb +3 -3
- data/app/views/decidim/export_mailer/data_portability_export.html.erb +1 -1
- data/app/views/decidim/searches/index.js.erb +6 -0
- data/app/views/decidim/shared/_address_details.html.erb +2 -2
- data/app/views/decidim/shared/_embed_modal.html.erb +1 -1
- data/app/views/decidim/shared/_share_modal.html.erb +7 -4
- data/app/views/layouts/decidim/_application.html.erb +0 -1
- data/app/views/layouts/decidim/_head.html.erb +13 -12
- data/app/views/layouts/decidim/_logo.html.erb +1 -1
- data/app/views/layouts/decidim/_social_media_links.html.erb +5 -5
- data/app/views/layouts/decidim/_user_menu.html.erb +1 -1
- data/app/views/layouts/decidim/_wrapper.html.erb +2 -2
- data/app/views/layouts/decidim/mailer.html.erb +2 -2
- data/config/locales/ar.yml +27 -17
- data/config/locales/ca.yml +79 -15
- data/config/locales/cs.yml +73 -14
- data/config/locales/de.yml +62 -12
- data/config/locales/en.yml +80 -16
- data/config/locales/eo-UY.yml +16 -0
- data/config/locales/es-MX.yml +73 -11
- data/config/locales/es-PY.yml +73 -11
- data/config/locales/es.yml +79 -15
- data/config/locales/eu.yml +6 -13
- data/config/locales/fi-plain.yml +75 -11
- data/config/locales/fi.yml +80 -16
- data/config/locales/fr.yml +70 -16
- data/config/locales/gl.yml +6 -13
- data/config/locales/hu.yml +80 -17
- data/config/locales/id-ID.yml +6 -12
- data/config/locales/it.yml +56 -14
- data/config/locales/nl.yml +76 -12
- data/config/locales/no.yml +11 -2
- data/config/locales/pl.yml +6 -15
- data/config/locales/pt-BR.yml +6 -13
- data/config/locales/pt.yml +6 -13
- data/config/locales/ru.yml +7 -2
- data/config/locales/sv.yml +34 -18
- data/config/locales/tr-TR.yml +15 -12
- data/config/locales/uk.yml +7 -2
- data/config/routes.rb +7 -0
- data/db/migrate/20180226140756_add_version_to_action_logs.rb +1 -0
- data/db/migrate/20180305132906_rename_features_to_components.rb +1 -0
- data/db/migrate/20190412131728_fix_user_names.rb +1 -1
- data/db/migrate/20190610093742_add_force_users_to_authenticate_before_access_organization.rb +10 -0
- data/db/migrate/20190618075906_add_confidential_to_doorkeeper_application.rb +13 -0
- data/db/migrate/{20190925091507_add_uniq_index_to_decidim_metrics.rb → 20190829092826_add_uniq_index_to_decidim_metrics.rb} +0 -0
- data/lib/decidim/amendable.rb +87 -13
- data/lib/decidim/attributes/localized_date.rb +5 -0
- data/lib/decidim/attributes/time_with_zone.rb +5 -0
- data/lib/decidim/authorable.rb +3 -0
- data/lib/decidim/authorization_form_builder.rb +2 -2
- data/lib/decidim/component_manifest.rb +2 -0
- data/lib/decidim/content_parsers.rb +2 -0
- data/lib/decidim/content_parsers/hashtag_parser.rb +1 -1
- data/lib/decidim/content_parsers/link_parser.rb +10 -0
- data/lib/decidim/content_parsers/newline_parser.rb +20 -0
- data/lib/decidim/content_parsers/user_parser.rb +1 -1
- data/lib/decidim/content_processor.rb +2 -0
- data/lib/decidim/content_renderers.rb +1 -0
- data/lib/decidim/content_renderers/hashtag_renderer.rb +1 -1
- data/lib/decidim/content_renderers/link_renderer.rb +24 -0
- data/lib/decidim/content_renderers/user_renderer.rb +2 -2
- data/lib/decidim/core.rb +11 -0
- data/lib/decidim/core/engine.rb +2 -28
- data/lib/decidim/core/test.rb +4 -1
- data/lib/decidim/core/test/factories.rb +35 -8
- data/lib/decidim/core/test/shared_examples/amendable/create_amendment_draft_examples.rb +50 -0
- data/lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb +39 -0
- data/lib/decidim/core/test/shared_examples/amendable/promote_amendment_examples.rb +27 -3
- data/lib/decidim/core/test/shared_examples/amendable/{create_amendment_examples.rb → publish_amendment_draft_examples.rb} +26 -17
- data/lib/decidim/core/test/shared_examples/amendable/update_amendment_draft_examples.rb +42 -0
- data/lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb +19 -11
- data/lib/decidim/core/test/shared_examples/has_attachment_collections.rb +1 -1
- data/lib/decidim/core/test/shared_examples/has_attachments.rb +1 -1
- data/lib/decidim/core/test/shared_examples/simple_event.rb +4 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/data_portability_file_zipper.rb +3 -0
- data/lib/decidim/events/author_event.rb +1 -0
- data/lib/decidim/events/base_event.rb +12 -22
- data/lib/decidim/events/coauthor_event.rb +1 -0
- data/lib/decidim/events/simple_event.rb +3 -0
- data/lib/decidim/exporters/csv.rb +1 -0
- data/lib/decidim/fingerprintable.rb +1 -0
- data/lib/decidim/followable.rb +8 -0
- data/lib/decidim/form_builder.rb +24 -3
- data/lib/decidim/gamification.rb +4 -0
- data/lib/decidim/gamification/badge_status.rb +1 -0
- data/lib/decidim/has_category.rb +2 -0
- data/lib/decidim/has_component.rb +2 -7
- data/lib/decidim/has_private_users.rb +8 -1
- data/lib/decidim/has_settings.rb +12 -8
- data/lib/decidim/hashtaggable.rb +4 -0
- data/lib/decidim/metric_operation_manifest.rb +1 -0
- data/lib/decidim/nicknamizable.rb +1 -0
- data/lib/decidim/participable.rb +1 -0
- data/lib/decidim/participatory_space_resourceable.rb +1 -0
- data/lib/decidim/randomable.rb +20 -0
- data/lib/decidim/search_resource_fields_mapper.rb +2 -0
- data/lib/decidim/searchable.rb +2 -0
- data/lib/decidim/settings_manifest.rb +10 -1
- data/lib/decidim/stats_registry.rb +1 -0
- data/lib/decidim/view_model.rb +1 -1
- data/lib/tasks/decidim_data_portability_tasks.rake +1 -0
- data/lib/tasks/decidim_metrics_tasks.rake +2 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.no.js +12 -12
- metadata +140 -82
- data/app/commands/decidim/amendable/create.rb +0 -80
@@ -3,8 +3,10 @@
|
|
3
3
|
module Decidim
|
4
4
|
class UserManagerPermissions < DefaultPermissions
|
5
5
|
def permissions
|
6
|
-
|
7
|
-
|
6
|
+
if user_manager?
|
7
|
+
allow! if read_admin_dashboard_action?
|
8
|
+
allow! if impersonate_managed_user_action?
|
9
|
+
end
|
8
10
|
|
9
11
|
permission_action
|
10
12
|
end
|
@@ -20,5 +22,10 @@ module Decidim
|
|
20
22
|
permission_action.subject == :managed_user &&
|
21
23
|
permission_action.action == :impersonate
|
22
24
|
end
|
25
|
+
|
26
|
+
# Whether the user has the user_manager role or not.
|
27
|
+
def user_manager?
|
28
|
+
user && !user.admin? && user.role?("user_manager")
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def display_hashtag
|
30
|
-
link_to name, decidim.search_path(term: name), target: "_blank", class: "hashtag-mention"
|
30
|
+
link_to name, decidim.search_path(term: name), target: "_blank", class: "hashtag-mention", rel: "noopener"
|
31
31
|
end
|
32
32
|
|
33
33
|
def display_hashtag_name
|
@@ -7,21 +7,25 @@ module Decidim
|
|
7
7
|
class MetricObjectPresenter < SimpleDelegator
|
8
8
|
def attr_int(attr, default: 0)
|
9
9
|
return default unless __getobj__
|
10
|
+
|
10
11
|
__getobj__[attr] || default
|
11
12
|
end
|
12
13
|
|
13
14
|
def attr_string(attr, default: "")
|
14
15
|
return default unless __getobj__
|
16
|
+
|
15
17
|
__getobj__[attr].presence || default
|
16
18
|
end
|
17
19
|
|
18
20
|
def attr_date(attr, default: "")
|
19
21
|
return default unless __getobj__
|
22
|
+
|
20
23
|
__getobj__[attr].try(:strftime, "%Y-%m-%d") || default
|
21
24
|
end
|
22
25
|
|
23
26
|
def attr_translated(attr, locale: I18n.locale, default: "")
|
24
27
|
return default unless __getobj__
|
28
|
+
|
25
29
|
__getobj__[attr].try(:[], locale.to_s).presence || default
|
26
30
|
end
|
27
31
|
end
|
@@ -11,6 +11,7 @@ module Decidim
|
|
11
11
|
def initialize(day_string, organization)
|
12
12
|
@day = day_string.present? ? Date.parse(day_string) : Time.zone.yesterday
|
13
13
|
raise ArgumentError, "[ERROR] Malformed `day` argument. Format must be `YYYY-MM-DD` and in the past" if @day > Time.zone.today
|
14
|
+
|
14
15
|
@day ||= Time.zone.yesterday
|
15
16
|
@organization = organization
|
16
17
|
@metric_name = metric_name
|
@@ -28,6 +29,7 @@ module Decidim
|
|
28
29
|
return @registry if @registry
|
29
30
|
|
30
31
|
return if cumulative.zero?
|
32
|
+
|
31
33
|
@registry = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name, organization: @organization)
|
32
34
|
@registry.assign_attributes(cumulative: cumulative, quantity: quantity)
|
33
35
|
@registry.save!
|
@@ -61,6 +63,7 @@ module Decidim
|
|
61
63
|
def retrieve_participatory_spaces
|
62
64
|
Decidim.participatory_space_manifests.map do |space_manifest|
|
63
65
|
next unless space_manifest.name == :participatory_processes # Temporal limitation
|
66
|
+
|
64
67
|
space_manifest.participatory_spaces.call(@organization)
|
65
68
|
end.flatten.compact
|
66
69
|
end
|
@@ -9,6 +9,7 @@ module Decidim
|
|
9
9
|
def initialize(day, resource)
|
10
10
|
@day = day.try(:to_date) || Time.zone.yesterday
|
11
11
|
raise ArgumentError, "[ERROR] Malformed `day` argument. Format must be `YYYY-MM-DD` and in the past" if @day > Time.zone.today
|
12
|
+
|
12
13
|
@day ||= Time.zone.yesterday
|
13
14
|
@resource = resource
|
14
15
|
end
|
@@ -11,10 +11,12 @@ module Decidim
|
|
11
11
|
|
12
12
|
def save
|
13
13
|
return @registry if @registry
|
14
|
+
|
14
15
|
@registry = []
|
15
16
|
query.each do |key, results|
|
16
17
|
cumulative_value = results[:cumulative_users].count
|
17
18
|
next if cumulative_value.zero?
|
19
|
+
|
18
20
|
quantity_value = results[:quantity_users].count || 0
|
19
21
|
space_type, space_id = key
|
20
22
|
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
|
@@ -49,6 +51,7 @@ module Decidim
|
|
49
51
|
components.each do |component|
|
50
52
|
operation_manifest = Decidim.metrics_operation.for(:followers, component.manifest_name)
|
51
53
|
next grouped_participants unless operation_manifest
|
54
|
+
|
52
55
|
component_participants = operation_manifest.calculate(@day, component)
|
53
56
|
grouped_participants[key].merge!(component_participants || {}) do |_key, grouped_users, component_users|
|
54
57
|
grouped_users | component_users
|
@@ -14,10 +14,12 @@ module Decidim
|
|
14
14
|
|
15
15
|
def save
|
16
16
|
return @registry if @registry
|
17
|
+
|
17
18
|
@registry = []
|
18
19
|
query.each do |key, results|
|
19
20
|
cumulative_value = results[:cumulative_users].count
|
20
21
|
next if cumulative_value.zero?
|
22
|
+
|
21
23
|
quantity_value = results[:quantity_users].count || 0
|
22
24
|
space_type, space_id = key
|
23
25
|
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
|
@@ -45,6 +47,7 @@ module Decidim
|
|
45
47
|
components.each do |component|
|
46
48
|
operation_manifest = Decidim.metrics_operation.for(:participants, component.manifest_name)
|
47
49
|
next grouped_participants unless operation_manifest
|
50
|
+
|
48
51
|
component_participants = operation_manifest.calculate(@day, component)
|
49
52
|
grouped_participants[key].merge!(component_participants || {}) do |_key, grouped_users, component_users|
|
50
53
|
grouped_users | component_users
|
@@ -54,6 +57,7 @@ module Decidim
|
|
54
57
|
# Special case for comments ONLY
|
55
58
|
operation_manifest = Decidim.metrics_operation.for(:participants, :comments)
|
56
59
|
next grouped_participants unless operation_manifest
|
60
|
+
|
57
61
|
comments_participants = operation_manifest.calculate(@day, participatory_space)
|
58
62
|
grouped_participants[key].merge!(comments_participants || {}) do |_key, grouped_users, comment_users|
|
59
63
|
grouped_users | comment_users
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Class used to retrieve similar emendations, scoped to the current component.
|
5
|
+
class SimilarEmendations < Rectify::Query
|
6
|
+
include Decidim::TranslationsHelper
|
7
|
+
|
8
|
+
# Syntactic sugar to initialize the class and return the queried objects.
|
9
|
+
#
|
10
|
+
# amendment - Decidim::Amendment
|
11
|
+
def self.for(amendment)
|
12
|
+
new(amendment).query
|
13
|
+
end
|
14
|
+
|
15
|
+
# Initializes the class.
|
16
|
+
#
|
17
|
+
# amendment - Decidim::Amendment
|
18
|
+
def initialize(amendment)
|
19
|
+
@component = amendment.amendable.component
|
20
|
+
@emendation = amendment.emendation
|
21
|
+
@amender = amendment.amender
|
22
|
+
end
|
23
|
+
|
24
|
+
# Retrieves similar emendations
|
25
|
+
def query
|
26
|
+
emendation.class
|
27
|
+
.where(component: component)
|
28
|
+
.only_visible_emendations_for(amender, component)
|
29
|
+
.published
|
30
|
+
.not_hidden
|
31
|
+
.where(
|
32
|
+
"GREATEST(#{title_similarity}, #{body_similarity}) >= ?",
|
33
|
+
emendation.title,
|
34
|
+
emendation.body,
|
35
|
+
amendable_module.similarity_threshold
|
36
|
+
)
|
37
|
+
.limit(amendable_module.similarity_limit)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
attr_reader :component, :emendation, :amender
|
43
|
+
|
44
|
+
def amendable_module
|
45
|
+
emendation.class.parent
|
46
|
+
end
|
47
|
+
|
48
|
+
def title_similarity
|
49
|
+
"similarity(title, ?)"
|
50
|
+
end
|
51
|
+
|
52
|
+
def body_similarity
|
53
|
+
"similarity(body, ?)"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -39,11 +39,13 @@ module Decidim
|
|
39
39
|
followers.each do |recipient|
|
40
40
|
next unless ["all", "followed-only"].include?(recipient.notification_types)
|
41
41
|
next unless participatory_space.present? && participatory_space.is_a?(Decidim::Participable) && participatory_space.can_participate?(recipient)
|
42
|
+
|
42
43
|
send_email_to(recipient, user_role: :follower)
|
43
44
|
end
|
44
45
|
|
45
46
|
affected_users.each do |recipient|
|
46
47
|
next unless ["all", "own-only"].include?(recipient.notification_types)
|
48
|
+
|
47
49
|
send_email_to(recipient, user_role: :affected_user)
|
48
50
|
end
|
49
51
|
end
|
@@ -63,6 +65,7 @@ module Decidim
|
|
63
65
|
def send_email_to(recipient, user_role:)
|
64
66
|
return unless recipient
|
65
67
|
return unless recipient.email_on_notification?
|
68
|
+
return if resource.respond_to?(:can_participate?) && !resource.can_participate?(recipient)
|
66
69
|
|
67
70
|
NotificationMailer
|
68
71
|
.event_received(
|
@@ -83,6 +86,7 @@ module Decidim
|
|
83
86
|
|
84
87
|
def participatory_space
|
85
88
|
return resource if resource.is_a?(Decidim::ParticipatorySpaceResourceable)
|
89
|
+
|
86
90
|
component&.participatory_space
|
87
91
|
end
|
88
92
|
end
|
@@ -50,6 +50,8 @@ module Decidim
|
|
50
50
|
attr_reader :event, :event_class, :resource, :followers, :affected_users, :extra
|
51
51
|
|
52
52
|
def generate_notification_for(recipient, user_role:)
|
53
|
+
return if resource.respond_to?(:can_participate?) && !resource.can_participate?(recipient)
|
54
|
+
|
53
55
|
NotificationGeneratorForRecipientJob.perform_later(
|
54
56
|
event,
|
55
57
|
event_class.name,
|
@@ -45,7 +45,7 @@ module Decidim
|
|
45
45
|
end
|
46
46
|
|
47
47
|
conditions = []
|
48
|
-
conditions << "decidim_scope_id IS NULL" if clean_scope_ids.delete("global")
|
48
|
+
conditions << "#{query.model_name.plural}.decidim_scope_id IS NULL" if clean_scope_ids.delete("global")
|
49
49
|
conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any?
|
50
50
|
|
51
51
|
query.includes(:scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i))
|
@@ -7,6 +7,7 @@ module Decidim
|
|
7
7
|
|
8
8
|
process :set_content_type_and_size_in_model
|
9
9
|
process :validate_dimensions
|
10
|
+
process :strip
|
10
11
|
|
11
12
|
version :thumbnail, if: :image? do
|
12
13
|
process resize_to_fit: [nil, 237]
|
@@ -18,6 +19,20 @@ module Decidim
|
|
18
19
|
|
19
20
|
protected
|
20
21
|
|
22
|
+
def extension_white_list
|
23
|
+
%w(jpg jpeg gif png bmp pdf doc docx xls xlsx ppt ppx rtf txt odt ott odf otg ods ots)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Strips out all embedded information from the image
|
27
|
+
def strip
|
28
|
+
return unless image?(self)
|
29
|
+
|
30
|
+
manipulate! do |img|
|
31
|
+
img.strip
|
32
|
+
img
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
21
36
|
# CarrierWave automatically calls this method and validates the content
|
22
37
|
# type fo the temp file to match against any of these options.
|
23
38
|
def content_type_whitelist
|
@@ -62,6 +77,7 @@ module Decidim
|
|
62
77
|
|
63
78
|
manipulate! do |image|
|
64
79
|
raise CarrierWave::IntegrityError, I18n.t("carrierwave.errors.image_too_big") if image.dimensions.any? { |dimension| dimension > max_image_height_or_width }
|
80
|
+
|
65
81
|
image
|
66
82
|
end
|
67
83
|
end
|