decidim-core 0.20.1 → 0.21.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/fonts/decidim/Roboto-Regular.eot +0 -0
- data/app/assets/fonts/decidim/Roboto-Regular.svg +10520 -0
- data/app/assets/fonts/decidim/Roboto-Regular.ttf +0 -0
- data/app/assets/fonts/decidim/Roboto-Regular.woff +0 -0
- data/app/assets/fonts/decidim/Roboto-Regular.woff2 +0 -0
- data/app/assets/images/decidim/brands/google.svg +1 -0
- data/app/assets/javascripts/decidim.js.es6 +5 -0
- data/app/assets/javascripts/decidim/check_boxes_tree.js.es6 +190 -0
- data/app/assets/javascripts/decidim/core/bundle.js +1 -1
- data/app/assets/javascripts/decidim/core/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/delayed.js.es6 +26 -0
- data/app/assets/javascripts/decidim/diff_mode_dropdown.js.es6 +25 -4
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +86 -38
- data/app/assets/javascripts/decidim/form_filter.component.test.js +40 -6
- data/app/assets/javascripts/decidim/history.js.es6 +16 -1
- data/app/assets/javascripts/decidim/vizzs/orgchart.js.es6 +1 -1
- data/app/assets/stylesheets/decidim/_variables.scss +1 -1
- data/app/assets/stylesheets/decidim/extras/_results-per-page.scss +0 -1
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +76 -3
- data/app/assets/stylesheets/decidim/modules/_comments.scss +78 -2
- data/app/assets/stylesheets/decidim/modules/_filters.scss +36 -2
- data/app/assets/stylesheets/decidim/modules/_layout.scss +13 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +11 -5
- data/app/assets/stylesheets/decidim/modules/_process-stats.scss +53 -0
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_tags.scss +7 -1
- data/app/assets/stylesheets/decidim/modules/_typography.scss +49 -4
- data/app/assets/stylesheets/decidim/utils/_fontface.scss +10 -0
- data/app/assets/stylesheets/decidim/utils/_toggle-expand.scss +14 -0
- data/app/cells/decidim/activity/show.erb +1 -1
- data/app/cells/decidim/author/profile_inline.erb +2 -2
- data/app/cells/decidim/diff/attribute.erb +15 -5
- data/app/cells/decidim/diff/diff_mode_html.erb +31 -0
- data/app/cells/decidim/diff/diff_split.erb +1 -1
- data/app/cells/decidim/diff/diff_unified.erb +1 -1
- data/app/cells/decidim/diff/show.erb +1 -0
- data/app/cells/decidim/diff_cell.rb +21 -8
- data/app/cells/decidim/follow_button/show.erb +20 -7
- data/app/cells/decidim/navbar_admin_link/show.erb +6 -0
- data/app/cells/decidim/navbar_admin_link_cell.rb +43 -0
- data/app/cells/decidim/tags_cell.rb +2 -2
- data/app/commands/decidim/amendable/accept.rb +9 -4
- data/app/commands/decidim/amendable/publish_draft.rb +5 -0
- data/app/commands/decidim/amendable/reject.rb +5 -0
- data/app/commands/decidim/amendable/withdraw.rb +3 -12
- data/app/commands/decidim/create_registration.rb +5 -6
- data/app/controllers/concerns/decidim/use_organization_time_zone.rb +32 -0
- data/app/controllers/decidim/application_controller.rb +3 -0
- data/app/controllers/decidim/components/base_controller.rb +1 -0
- data/app/controllers/decidim/data_portability_controller.rb +12 -19
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -1
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -0
- data/app/controllers/decidim/scopes_controller.rb +41 -7
- data/app/forms/decidim/registration_form.rb +5 -0
- data/app/functions/decidim/core/component_finder_base.rb +33 -0
- data/app/functions/decidim/core/component_list.rb +38 -0
- data/app/functions/decidim/core/component_list_base.rb +61 -0
- data/app/functions/decidim/core/needs_api_filter_and_order.rb +52 -0
- data/app/functions/decidim/core/participatory_space_finder.rb +11 -0
- data/app/functions/decidim/core/participatory_space_finder_base.rb +29 -0
- data/app/functions/decidim/core/participatory_space_list.rb +11 -0
- data/app/functions/decidim/core/participatory_space_list_base.rb +34 -0
- data/app/helpers/decidim/amendments_helper.rb +27 -1
- data/app/helpers/decidim/application_helper.rb +31 -3
- data/app/helpers/decidim/categories_helper.rb +26 -0
- data/app/helpers/decidim/check_boxes_tree_helper.rb +115 -0
- data/app/helpers/decidim/omniauth_helper.rb +6 -13
- data/app/helpers/decidim/resource_versions_helper.rb +29 -0
- data/app/helpers/decidim/rich_text_editor_helper.rb +22 -0
- data/app/helpers/decidim/sanitize_helper.rb +3 -1
- data/app/helpers/decidim/scopes_helper.rb +3 -2
- data/app/jobs/decidim/data_portability_export_job.rb +18 -10
- data/app/jobs/decidim/export_job.rb +1 -1
- data/app/mailers/decidim/export_mailer.rb +9 -5
- data/app/models/decidim/omniauth_provider.rb +28 -0
- data/app/models/decidim/organization.rb +41 -0
- data/app/models/decidim/participatory_space_role_config/admin.rb +8 -0
- data/app/models/decidim/participatory_space_role_config/base.rb +31 -0
- data/app/models/decidim/participatory_space_role_config/collaborator.rb +8 -0
- data/app/models/decidim/participatory_space_role_config/moderator.rb +11 -0
- data/app/models/decidim/participatory_space_role_config/null_object.rb +11 -0
- data/app/models/decidim/participatory_space_role_config/participatory_space_admin.rb +8 -0
- data/app/models/decidim/participatory_space_role_config/valuator.rb +11 -0
- data/app/models/decidim/scope.rb +4 -2
- data/app/models/decidim/user.rb +19 -3
- data/app/presenters/decidim/home_stats_presenter.rb +5 -2
- data/app/presenters/decidim/resource_locator_presenter.rb +9 -0
- data/app/serializers/decidim/exporters/participatory_space_components_serializer.rb +1 -1
- data/app/serializers/decidim/importers/participatory_space_components_importer.rb +14 -5
- data/app/services/decidim/data_portability_exporter.rb +72 -0
- data/app/services/decidim/resource_search.rb +29 -13
- data/app/services/decidim/zip_stream/zip_stream_writer.rb +56 -0
- data/app/types/decidim/core/amendment_type.rb +26 -0
- data/app/types/decidim/core/area_api_type.rb +16 -0
- data/app/types/decidim/core/area_type_type.rb +14 -0
- data/app/types/decidim/core/base_input_filter.rb +8 -0
- data/app/types/decidim/core/base_input_sort.rb +22 -0
- data/app/types/decidim/core/component_input_filter.rb +50 -0
- data/app/types/decidim/core/component_input_sort.rb +32 -0
- data/app/types/decidim/core/fingerprint_type.rb +15 -0
- data/app/types/decidim/core/has_hastaggable_input_filter.rb +15 -0
- data/app/types/decidim/core/has_localized_input_filter.rb +21 -0
- data/app/types/decidim/core/has_localized_input_sort.rb +21 -0
- data/app/types/decidim/core/has_publishable_input_filter.rb +34 -0
- data/app/types/decidim/core/has_publishable_input_sort.rb +13 -0
- data/app/types/decidim/core/participatory_space_input_filter.rb +26 -0
- data/app/types/decidim/core/participatory_space_input_sort.rb +14 -0
- data/app/types/decidim/core/participatory_space_link_type.rb +24 -0
- data/app/types/decidim/core/trace_version_type.rb +29 -0
- data/app/uploaders/decidim/data_portability_uploader.rb +2 -7
- data/app/validators/time_zone_validator.rb +10 -0
- data/app/views/decidim/amendments/_edit_form_fields.html.erb +5 -13
- data/app/views/decidim/amendments/preview_draft.html.erb +1 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +10 -12
- data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +6 -8
- data/app/views/decidim/export_mailer/data_portability_export.html.erb +2 -2
- data/app/views/decidim/scopes/picker.html.erb +7 -3
- data/app/views/decidim/shared/_check_boxes_tree.html.erb +54 -0
- data/app/views/decidim/shared/_extended_navigation_bar.html.erb +1 -1
- data/app/views/decidim/widgets/show.html.erb +4 -0
- data/app/views/layouts/decidim/_admin_links.html.erb +2 -0
- data/app/views/layouts/decidim/_wrapper.html.erb +4 -3
- data/app/views/layouts/decidim/widget.html.erb +1 -43
- data/config/initializers/browser.rb +5 -0
- data/config/initializers/devise.rb +0 -22
- data/config/initializers/omniauth.rb +50 -0
- data/config/locales/ar.yml +6 -3
- data/config/locales/ca.yml +15 -6
- data/config/locales/cs.yml +12 -3
- data/config/locales/de.yml +5 -3
- data/config/locales/el-GR.yml +0 -2
- data/config/locales/el.yml +153 -0
- data/config/locales/en.yml +16 -7
- data/config/locales/eo-UY.yml +2 -2
- data/config/locales/es-MX.yml +12 -3
- data/config/locales/es-PY.yml +12 -3
- data/config/locales/es.yml +15 -6
- data/config/locales/eu.yml +4 -3
- data/config/locales/fi-plain.yml +12 -3
- data/config/locales/fi.yml +12 -3
- data/config/locales/fr.yml +5 -3
- data/config/locales/gl.yml +4 -3
- data/config/locales/hu.yml +12 -3
- data/config/locales/id-ID.yml +4 -3
- data/config/locales/it.yml +11 -3
- data/config/locales/nl.yml +8 -3
- data/config/locales/no.yml +12 -3
- data/config/locales/pl.yml +4 -3
- data/config/locales/pt-BR.yml +4 -3
- data/config/locales/pt.yml +4 -3
- data/config/locales/ru.yml +5 -3
- data/config/locales/sv.yml +5 -3
- data/config/locales/tr-TR.yml +4 -3
- data/config/locales/uk.yml +1 -3
- data/db/migrate/20191113092826_add_omniauth_settings_to_decidim_organization.rb +7 -0
- data/db/migrate/20191113144432_add_rich_text_editor_in_public_views_to_organizations.rb +10 -0
- data/db/migrate/20191118123154_add_admin_terms_of_use_body_field_to_organization.rb +9 -0
- data/db/migrate/20200107142226_add_organization_timezone.rb +7 -0
- data/db/seeds.rb +2 -1
- data/lib/decidim/amendable.rb +7 -4
- data/lib/decidim/api/amendable_entity_interface.rb +18 -0
- data/lib/decidim/api/amendable_interface.rb +18 -0
- data/lib/decidim/api/attachable_interface.rb +1 -1
- data/lib/decidim/api/categorizable_interface.rb +1 -1
- data/lib/decidim/api/coauthorable_interface.rb +29 -0
- data/lib/decidim/api/fingerprint_interface.rb +13 -0
- data/lib/decidim/api/participatory_space_interface.rb +9 -9
- data/lib/decidim/api/participatory_space_resourceable_interface.rb +21 -0
- data/lib/decidim/api/scopable_interface.rb +1 -1
- data/lib/decidim/api/timestamps_interface.rb +21 -0
- data/lib/decidim/api/traceable_interface.rb +14 -0
- data/lib/decidim/coauthorable.rb +9 -2
- data/lib/decidim/component_manifest.rb +1 -1
- data/lib/decidim/content_processor.rb +4 -2
- data/lib/decidim/content_renderers/link_renderer.rb +1 -1
- data/lib/decidim/core.rb +3 -3
- data/lib/decidim/core/api.rb +7 -0
- data/lib/decidim/core/test.rb +1 -0
- data/lib/decidim/core/test/factories.rb +16 -0
- data/lib/decidim/core/test/shared_examples/amendable_interface_examples.rb +14 -0
- data/lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb +50 -0
- data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +3 -0
- data/lib/decidim/core/test/shared_examples/coauthorable_interface_examples.rb +60 -0
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +8 -8
- data/lib/decidim/core/test/shared_examples/fingerprintable_interface_examples.rb +17 -0
- data/lib/decidim/core/test/shared_examples/follows_examples.rb +16 -0
- data/lib/decidim/core/test/shared_examples/input_filter_examples.rb +118 -0
- data/lib/decidim/core/test/shared_examples/input_sort_examples.rb +105 -0
- data/lib/decidim/core/test/shared_examples/participatory_space_resourcable_interface_examples.rb +43 -0
- data/lib/decidim/core/test/shared_examples/rich_text_editor_examples.rb +59 -0
- data/lib/decidim/core/test/shared_examples/timestamps_interface_examples.rb +21 -0
- data/lib/decidim/core/test/shared_examples/traceable_interface_examples.rb +47 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/deprecations.rb +19 -0
- data/lib/decidim/diffy_extension.rb +26 -0
- data/lib/decidim/exporters/export_manifest.rb +6 -2
- data/lib/decidim/filter_form_builder.rb +25 -7
- data/lib/decidim/form_builder.rb +2 -2
- data/lib/decidim/has_settings.rb +10 -4
- data/lib/decidim/participatory_space_manifest.rb +20 -0
- data/lib/decidim/participatory_space_resourceable.rb +35 -1
- data/lib/decidim/query_extensions.rb +9 -23
- data/lib/decidim/scopable.rb +10 -0
- data/lib/tasks/decidim_data_portability_tasks.rake +66 -5
- data/lib/tasks/decidim_metrics_tasks.rake +18 -7
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.el.js +14 -0
- metadata +142 -16
- data/app/models/decidim/participatory_process_user_role.rb +0 -32
- data/app/views/layouts/decidim/_edit_link.html.erb +0 -8
- data/lib/decidim/data_portability_file_reader.rb +0 -56
- data/lib/decidim/data_portability_file_zipper.rb +0 -67
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This cell renders a link in the top navbar
|
5
|
+
# so admins can easily manage data without having to look for it at the admin
|
6
|
+
# panel when they're at a public page.
|
7
|
+
# example use:
|
8
|
+
# <%= cell("decidim/navbar_admin_link", { link_url: link_url, link_options: link_options }) %>
|
9
|
+
#
|
10
|
+
class NavbarAdminLinkCell < Decidim::ViewModel
|
11
|
+
include Decidim::IconHelper
|
12
|
+
|
13
|
+
def show
|
14
|
+
render if link_url
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def link_url
|
20
|
+
return if model[:link_url].blank?
|
21
|
+
|
22
|
+
model[:link_url]
|
23
|
+
end
|
24
|
+
|
25
|
+
def link_icon_name
|
26
|
+
return "pencil" if model[:link_options][:icon].blank?
|
27
|
+
|
28
|
+
model[:link_options][:icon]
|
29
|
+
end
|
30
|
+
|
31
|
+
def link_name
|
32
|
+
return t("layouts.decidim.edit_link.edit") if model[:link_options][:name].blank?
|
33
|
+
|
34
|
+
model[:link_options][:name]
|
35
|
+
end
|
36
|
+
|
37
|
+
def link_class
|
38
|
+
return if model[:link_options][:class].blank?
|
39
|
+
|
40
|
+
model[:link_options][:class]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -40,7 +40,7 @@ module Decidim
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def category_path
|
43
|
-
resource_locator(model).index(filter: { category_id: model.category.id })
|
43
|
+
resource_locator(model).index(filter: { category_id: [model.category.id.to_s] })
|
44
44
|
end
|
45
45
|
|
46
46
|
def scope?
|
@@ -56,7 +56,7 @@ module Decidim
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def scope_path
|
59
|
-
resource_locator(model).index(filter: { scope_id: model.scope.id })
|
59
|
+
resource_locator(model).index(filter: { scope_id: [model.scope.id] })
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -29,6 +29,7 @@ module Decidim
|
|
29
29
|
transaction do
|
30
30
|
accept_amendment!
|
31
31
|
update_amendable!
|
32
|
+
notify_emendation_state_change!
|
32
33
|
notify_amendable_and_emendation_authors_and_followers
|
33
34
|
end
|
34
35
|
|
@@ -37,7 +38,7 @@ module Decidim
|
|
37
38
|
|
38
39
|
private
|
39
40
|
|
40
|
-
attr_reader :form
|
41
|
+
attr_reader :form, :emendation
|
41
42
|
|
42
43
|
def accept_amendment!
|
43
44
|
@amendment = Decidim.traceability.update!(
|
@@ -58,14 +59,18 @@ module Decidim
|
|
58
59
|
@amendable.add_coauthor(@amender, user_group: @user_group)
|
59
60
|
end
|
60
61
|
|
62
|
+
def notify_emendation_state_change!
|
63
|
+
emendation.process_amendment_state_change!
|
64
|
+
end
|
65
|
+
|
61
66
|
def notify_amendable_and_emendation_authors_and_followers
|
62
|
-
affected_users =
|
63
|
-
followers =
|
67
|
+
affected_users = emendation.authors + @amendable.notifiable_identities
|
68
|
+
followers = emendation.followers + @amendable.followers - affected_users
|
64
69
|
|
65
70
|
Decidim::EventsManager.publish(
|
66
71
|
event: "decidim.events.amendments.amendment_accepted",
|
67
72
|
event_class: Decidim::Amendable::AmendmentAcceptedEvent,
|
68
|
-
resource:
|
73
|
+
resource: emendation,
|
69
74
|
affected_users: affected_users.uniq,
|
70
75
|
followers: followers.uniq
|
71
76
|
)
|
@@ -30,6 +30,7 @@ module Decidim
|
|
30
30
|
set_first_emendation_version
|
31
31
|
publish_emendation
|
32
32
|
change_amendment_state_to_evaluating
|
33
|
+
notify_emendation_state_change!
|
33
34
|
notify_amendable_authors_and_followers
|
34
35
|
end
|
35
36
|
|
@@ -62,6 +63,10 @@ module Decidim
|
|
62
63
|
emendation.amendment.update(state: "evaluating")
|
63
64
|
end
|
64
65
|
|
66
|
+
def notify_emendation_state_change!
|
67
|
+
emendation.process_amendment_state_change!
|
68
|
+
end
|
69
|
+
|
65
70
|
def notify_amendable_authors_and_followers
|
66
71
|
Decidim::EventsManager.publish(
|
67
72
|
event: "decidim.events.amendments.amendment_created",
|
@@ -26,6 +26,7 @@ module Decidim
|
|
26
26
|
|
27
27
|
transaction do
|
28
28
|
reject_amendment!
|
29
|
+
notify_emendation_state_change!
|
29
30
|
notify_emendation_authors_and_followers
|
30
31
|
end
|
31
32
|
|
@@ -43,6 +44,10 @@ module Decidim
|
|
43
44
|
)
|
44
45
|
end
|
45
46
|
|
47
|
+
def notify_emendation_state_change!
|
48
|
+
@emendation.process_amendment_state_change!
|
49
|
+
end
|
50
|
+
|
46
51
|
def notify_emendation_authors_and_followers
|
47
52
|
affected_users = @emendation.authors + @amendable.notifiable_identities
|
48
53
|
followers = @emendation.followers + @amendable.followers - affected_users
|
@@ -26,7 +26,7 @@ module Decidim
|
|
26
26
|
|
27
27
|
transaction do
|
28
28
|
withdraw_amendment!
|
29
|
-
|
29
|
+
notify_emendation_state_change!
|
30
30
|
end
|
31
31
|
|
32
32
|
broadcast(:ok, emendation)
|
@@ -45,17 +45,8 @@ module Decidim
|
|
45
45
|
)
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
# to be able to retrieve rejected emendations.
|
51
|
-
#
|
52
|
-
# Because we are modifying the emendation itself, we need to prevent
|
53
|
-
# PaperTrail from creating an additional version to ensure that this
|
54
|
-
# change does not appear in the diff renderer of the emendation page.
|
55
|
-
def withdraw_emendation!
|
56
|
-
PaperTrail.request(enabled: false) do
|
57
|
-
emendation.update!(state: "withdrawn")
|
58
|
-
end
|
48
|
+
def notify_emendation_state_change!
|
49
|
+
emendation.process_amendment_state_change!
|
59
50
|
end
|
60
51
|
end
|
61
52
|
end
|
@@ -17,9 +17,12 @@ module Decidim
|
|
17
17
|
#
|
18
18
|
# Returns nothing.
|
19
19
|
def call
|
20
|
-
|
20
|
+
if form.invalid?
|
21
|
+
user = User.has_pending_invitations?(form.current_organization.id, form.email)
|
22
|
+
user.invite!(user.invited_by) if user
|
23
|
+
return broadcast(:invalid)
|
24
|
+
end
|
21
25
|
|
22
|
-
delete_pending_invited_user
|
23
26
|
create_user
|
24
27
|
|
25
28
|
broadcast(:ok, @user)
|
@@ -31,10 +34,6 @@ module Decidim
|
|
31
34
|
|
32
35
|
attr_reader :form
|
33
36
|
|
34
|
-
def delete_pending_invited_user
|
35
|
-
User.invitation_not_accepted.where(email: form.email).delete_all
|
36
|
-
end
|
37
|
-
|
38
37
|
def create_user
|
39
38
|
@user = User.create!(
|
40
39
|
email: form.email,
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# When included in a controller this concern will wrap any action
|
7
|
+
# in the context of the organization configured time zone
|
8
|
+
module UseOrganizationTimeZone
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
around_action :use_organization_time_zone
|
13
|
+
helper_method :organization_time_zone
|
14
|
+
|
15
|
+
# Executes a block of code in the context of the the organization's time zone
|
16
|
+
#
|
17
|
+
# &action - a block of code to be wrapped around the time zone
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def use_organization_time_zone(&action)
|
21
|
+
Time.use_zone(organization_time_zone, &action)
|
22
|
+
end
|
23
|
+
|
24
|
+
# The current time zone from the organization. Available as a helper for the views.
|
25
|
+
#
|
26
|
+
# Returns a String.
|
27
|
+
def organization_time_zone
|
28
|
+
@organization_time_zone ||= current_organization.time_zone
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -3,8 +3,11 @@
|
|
3
3
|
module Decidim
|
4
4
|
# The main application controller that inherits from Rails.
|
5
5
|
class ApplicationController < ::DecidimController
|
6
|
+
include Browser::ActionController
|
7
|
+
|
6
8
|
include NeedsOrganization
|
7
9
|
include LocaleSwitcher
|
10
|
+
include UseOrganizationTimeZone
|
8
11
|
include NeedsPermission
|
9
12
|
include PayloadInfo
|
10
13
|
include ImpersonateUsers
|
@@ -15,6 +15,7 @@ module Decidim
|
|
15
15
|
helper Decidim::FiltersHelper
|
16
16
|
helper Decidim::OrdersHelper
|
17
17
|
helper Decidim::ResourceReferenceHelper
|
18
|
+
helper Decidim::ResourceVersionsHelper
|
18
19
|
helper Decidim::TranslationsHelper
|
19
20
|
helper Decidim::IconHelper
|
20
21
|
helper Decidim::ResourceHelper
|
@@ -16,40 +16,33 @@ module Decidim
|
|
16
16
|
def export
|
17
17
|
enforce_permission_to :export, :user, current_user: current_user
|
18
18
|
|
19
|
-
DataPortabilityExportJob.perform_later(current_user
|
19
|
+
DataPortabilityExportJob.perform_later(current_user)
|
20
20
|
|
21
21
|
flash[:notice] = t("decidim.account.data_portability_export.notice")
|
22
|
-
|
23
22
|
redirect_back(fallback_location: data_portability_path)
|
24
23
|
end
|
25
24
|
|
26
25
|
def download_file
|
27
26
|
enforce_permission_to :download, :user, current_user: current_user
|
28
27
|
|
29
|
-
if
|
30
|
-
|
31
|
-
if file_reader.valid_token?
|
32
|
-
file = File.open(file_reader.file_path)
|
33
|
-
if File.exist?(file)
|
34
|
-
send_file file, type: "application/zip", disposition: "attachment"
|
35
|
-
else
|
36
|
-
flash[:error] = t("decidim.account.data_portability_export.file_no_exists")
|
37
|
-
redirect_to data_portability_path
|
38
|
-
end
|
39
|
-
else
|
40
|
-
flash[:error] = t("decidim.account.data_portability_export.invalid_token")
|
41
|
-
redirect_to data_portability_path
|
42
|
-
end
|
28
|
+
if data_portability_file_exists?
|
29
|
+
redirect_to uploader.url
|
43
30
|
else
|
44
|
-
flash[:error] = t("decidim.account.data_portability_export.
|
31
|
+
flash[:error] = t("decidim.account.data_portability_export.file_no_exists")
|
45
32
|
redirect_to data_portability_path
|
46
33
|
end
|
47
34
|
end
|
48
35
|
|
49
36
|
private
|
50
37
|
|
51
|
-
def
|
52
|
-
|
38
|
+
def data_portability_file_exists?
|
39
|
+
uploader.file.exists?
|
40
|
+
rescue StandardError
|
41
|
+
false
|
42
|
+
end
|
43
|
+
|
44
|
+
def uploader
|
45
|
+
current_user.data_portability_file(params[:filename])
|
53
46
|
end
|
54
47
|
end
|
55
48
|
end
|
@@ -66,7 +66,7 @@ module Decidim
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def action_missing(action_name)
|
69
|
-
return send(:create) if devise_mapping.omniauthable? &&
|
69
|
+
return send(:create) if devise_mapping.omniauthable? && current_organization.enabled_omniauth_providers.keys.include?(action_name.to_sym)
|
70
70
|
|
71
71
|
raise AbstractController::ActionNotFound, "The action '#{action_name}' could not be found for Decidim::Devise::OmniauthCallbacksController"
|
72
72
|
end
|
@@ -8,21 +8,33 @@ module Decidim
|
|
8
8
|
def picker
|
9
9
|
enforce_permission_to :pick, :scope
|
10
10
|
|
11
|
-
context = root ? { root: root.id, title: title } : { title: title }
|
11
|
+
context = root ? { root: root.id, title: title, max_depth: max_depth } : { title: title, max_depth: max_depth }
|
12
12
|
required = params[:required] && params[:required] != "false"
|
13
|
-
current = (root&.descendants || current_organization.scopes).find_by(id: params[:current]) if params[:current].present?
|
14
13
|
|
15
14
|
if current
|
16
|
-
scopes = current.children
|
15
|
+
scopes = current.children unless scope_depth_limit?
|
17
16
|
parent_scopes = current.part_of_scopes(root)
|
18
17
|
else
|
19
|
-
|
20
|
-
|
18
|
+
scopes = root&.children || current_organization.scopes.top_level unless scope_depth_limit?
|
19
|
+
|
21
20
|
parent_scopes = [root].compact
|
22
21
|
end
|
23
22
|
|
24
|
-
render
|
25
|
-
|
23
|
+
render(
|
24
|
+
:picker,
|
25
|
+
layout: nil,
|
26
|
+
locals: {
|
27
|
+
required: required,
|
28
|
+
title: title,
|
29
|
+
root: root,
|
30
|
+
current: (current || root),
|
31
|
+
scopes: scopes&.order(name: :asc),
|
32
|
+
parent_scopes: parent_scopes,
|
33
|
+
global_value: params[:global_value],
|
34
|
+
max_depth: max_depth,
|
35
|
+
context: context
|
36
|
+
}
|
37
|
+
)
|
26
38
|
end
|
27
39
|
|
28
40
|
private
|
@@ -36,5 +48,27 @@ module Decidim
|
|
36
48
|
|
37
49
|
@root ||= current_organization.scopes.find(params[:root])
|
38
50
|
end
|
51
|
+
|
52
|
+
def current
|
53
|
+
return if params[:current].blank?
|
54
|
+
|
55
|
+
@current ||= (root&.descendants || current_organization.scopes).find_by(id: params[:current])
|
56
|
+
end
|
57
|
+
|
58
|
+
def filter_scope_depth?
|
59
|
+
@filter_scope_depth ||= params[:max_depth].present?
|
60
|
+
end
|
61
|
+
|
62
|
+
def scope_depth_limit?
|
63
|
+
return unless filter_scope_depth?
|
64
|
+
|
65
|
+
@scope_depth_limit ||= current&.scope_type == max_depth
|
66
|
+
end
|
67
|
+
|
68
|
+
def max_depth
|
69
|
+
return unless filter_scope_depth?
|
70
|
+
|
71
|
+
@max_depth ||= current_organization.scope_types.find(params[:max_depth])
|
72
|
+
end
|
39
73
|
end
|
40
74
|
end
|
@@ -23,6 +23,7 @@ module Decidim
|
|
23
23
|
|
24
24
|
validate :email_unique_in_organization
|
25
25
|
validate :nickname_unique_in_organization
|
26
|
+
validate :no_pending_invitations_exist
|
26
27
|
|
27
28
|
def newsletter_at
|
28
29
|
return nil unless newsletter?
|
@@ -39,5 +40,9 @@ module Decidim
|
|
39
40
|
def nickname_unique_in_organization
|
40
41
|
errors.add :nickname, :taken if User.no_active_invitation.find_by(nickname: nickname, organization: current_organization).present?
|
41
42
|
end
|
43
|
+
|
44
|
+
def no_pending_invitations_exist
|
45
|
+
errors.add :base, I18n.t("devise.failure.invited") if User.has_pending_invitations?(current_organization.id, email)
|
46
|
+
end
|
42
47
|
end
|
43
48
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Core
|
5
|
+
# An abstract class with the logic for the GraphQL endpoint for a single component to be searchable.
|
6
|
+
# Normal components (such as Proposal) can inherit from this class and just
|
7
|
+
# add the needed search arguments
|
8
|
+
#
|
9
|
+
# Usually something like:
|
10
|
+
#
|
11
|
+
# class ProposalFinderHelper < Decidim::Core::ComponentFinderBase
|
12
|
+
# argument :id, !types.ID, "The ID of the proposal"
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# For an example check
|
16
|
+
# decidim-proposals/app/types/decidim/proposals/proposals_type.rb
|
17
|
+
class ComponentFinderBase < GraphQL::Function
|
18
|
+
attr_reader :model_class
|
19
|
+
|
20
|
+
def initialize(model_class:)
|
21
|
+
@model_class = model_class
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(component, args, _ctx)
|
25
|
+
query = { component: component }
|
26
|
+
args.keys.each do |key|
|
27
|
+
query[key] = args[key]
|
28
|
+
end
|
29
|
+
model_class.published.find_by(query)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|