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
data/lib/decidim/core/test/shared_examples/participatory_space_resourcable_interface_examples.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
shared_examples_for "participatory space resourcable interface" do
|
6
|
+
let!(:process1) { create(:participatory_process, organization: model.organization) }
|
7
|
+
let!(:process2) { create(:participatory_process, organization: model.organization) }
|
8
|
+
let!(:process3) { create(:participatory_process, organization: model.organization) }
|
9
|
+
let!(:model) { create(:assembly) }
|
10
|
+
|
11
|
+
context "when linked from the model" do
|
12
|
+
describe "linkedParticipatorySpaces" do
|
13
|
+
let(:query) { "{ linkedParticipatorySpaces { participatorySpace { id } } }" }
|
14
|
+
|
15
|
+
before do
|
16
|
+
model.link_participatory_space_resources([process1, process2], :included_participatory_processes)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "includes the linked resources" do
|
20
|
+
ids = response["linkedParticipatorySpaces"].map { |l| l["participatorySpace"]["id"] }
|
21
|
+
expect(ids).to include(process1.id.to_s, process2.id.to_s)
|
22
|
+
expect(ids).not_to include(process3.id.to_s)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when linked towards the model" do
|
28
|
+
describe "linkedParticipatorySpaces" do
|
29
|
+
let(:query) { "{ linkedParticipatorySpaces { participatorySpace { id } } }" }
|
30
|
+
|
31
|
+
before do
|
32
|
+
process1.link_participatory_space_resources(model, :included_participatory_processes)
|
33
|
+
process2.link_participatory_space_resources(model, :included_participatory_processes)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "includes the linked resources" do
|
37
|
+
ids = response["linkedParticipatorySpaces"].map { |l| l["participatorySpace"]["id"] }
|
38
|
+
expect(ids).to include(process1.id.to_s, process2.id.to_s)
|
39
|
+
expect(ids).not_to include(process3.id.to_s)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_examples "having a rich text editor" do |css, toolbar|
|
4
|
+
it "has a form with a rich text editor" do
|
5
|
+
within "form.#{css}" do
|
6
|
+
expect(page).to have_selector("input[toolbar='#{toolbar}']", visible: false)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
shared_context "with rich text editor content" do
|
12
|
+
let(:content) { "<p>" + safe_tags + "</p>" + script }
|
13
|
+
let(:safe_tags) { em + u + strong }
|
14
|
+
let(:em) { "<em>em</em>" }
|
15
|
+
let(:u) { "<u>u</u>" }
|
16
|
+
let(:strong) { "<strong>strong</strong>" }
|
17
|
+
let(:script) { "<script>alert('SCRIPT')</script>" }
|
18
|
+
end
|
19
|
+
|
20
|
+
shared_examples "rendering safe content" do |css|
|
21
|
+
include_context "with rich text editor content"
|
22
|
+
|
23
|
+
it "renders potentially safe HTML tags unescaped" do
|
24
|
+
within css do
|
25
|
+
expect(page).to have_selector("em", text: "em")
|
26
|
+
expect(page).to have_selector("u", text: "u")
|
27
|
+
expect(page).to have_selector("strong", text: "strong")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "sanitizes potentially malicious HTML tags" do
|
32
|
+
within css do
|
33
|
+
expect(page).not_to have_selector("script", visible: false)
|
34
|
+
expect(page).to have_content("alert('SCRIPT')")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
shared_examples "rendering unsafe content" do |css|
|
40
|
+
include_context "with rich text editor content"
|
41
|
+
|
42
|
+
it "sanitizes potentially safe HTML tags" do
|
43
|
+
within css do
|
44
|
+
expect(page).not_to have_selector("em")
|
45
|
+
expect(page).to have_content("em")
|
46
|
+
expect(page).not_to have_selector("u")
|
47
|
+
expect(page).to have_content("u")
|
48
|
+
expect(page).not_to have_selector("strong")
|
49
|
+
expect(page).to have_content("strong")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "strips potentially malicious HTML tags" do
|
54
|
+
within css do
|
55
|
+
expect(page).not_to have_selector("script", visible: false)
|
56
|
+
expect(page).not_to have_content("alert('SCRIPT')")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
shared_examples_for "timestamps interface" do
|
6
|
+
describe "createdAt" do
|
7
|
+
let(:query) { "{ createdAt }" }
|
8
|
+
|
9
|
+
it "returns when was this query created at" do
|
10
|
+
expect(response["createdAt"]).to eq(model.created_at.to_time.iso8601)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "updatedAt" do
|
15
|
+
let(:query) { "{ updatedAt }" }
|
16
|
+
|
17
|
+
it "returns when was this query updated at" do
|
18
|
+
expect(response["updatedAt"]).to eq(model.updated_at.to_time.iso8601)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
shared_examples_for "traceable interface" do
|
6
|
+
describe "traceable", versioning: true do
|
7
|
+
before do
|
8
|
+
Decidim.traceability.update!(model, model.creator_identity, title: "test")
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when field createdAt" do
|
12
|
+
let(:query) { "{ versions { createdAt } }" }
|
13
|
+
|
14
|
+
it "returns created_at field of the version to iso format" do
|
15
|
+
dates = response["versions"].map { |version| version["createdAt"] }
|
16
|
+
expect(dates).to include(*model.versions.map { |version| version.created_at.to_time.iso8601 })
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when field id" do
|
21
|
+
let(:query) { "{ versions { id } }" }
|
22
|
+
|
23
|
+
it "returns ID field of the version" do
|
24
|
+
ids = response["versions"].map { |version| version["id"].to_i }
|
25
|
+
expect(ids).to include(*model.versions.map(&:id))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when field editor" do
|
30
|
+
let(:query) { "{ versions { editor { name } } }" }
|
31
|
+
|
32
|
+
it "returns editor field of the versions" do
|
33
|
+
editors = response["versions"].map { |version| version["editor"]["name"] if version["editor"] }
|
34
|
+
expect(editors).to include(*model.versions.map { |version| version.editor.name if version.respond_to? :editor })
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when field changeset" do
|
39
|
+
let(:query) { "{ versions { changeset } }" }
|
40
|
+
|
41
|
+
it "returns changeset field of the versions" do
|
42
|
+
changesets = response["versions"].map { |version| version["changeset"] }
|
43
|
+
expect(changesets).to include(*model.versions.map(&:changeset))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/decidim/core/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
#
|
5
|
+
# This class handles all logic regarding deprecated methods.
|
6
|
+
#
|
7
|
+
module Deprecations
|
8
|
+
# Define a deprecated alias for a method
|
9
|
+
#
|
10
|
+
# @param [Symbol] old_name - name of the method to deprecate
|
11
|
+
# @param [Symbol] replacement - name of the new method to use
|
12
|
+
def deprecated_alias(old_name, replacement)
|
13
|
+
define_method(old_name) do |*args, &block|
|
14
|
+
ActiveSupport::Deprecation.warn "##{old_name} deprecated (please use ##{replacement})"
|
15
|
+
send replacement, *args, &block
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Extending Diffy gem to accomodate the needs of app/cells/decidim/diff_cell.rb
|
5
|
+
module DiffyExtension
|
6
|
+
# HtmlFormatter that returns basic html output (no inline highlighting)
|
7
|
+
# and does not escape HTML tags.
|
8
|
+
class UnescapedHtmlFormatter < Diffy::HtmlFormatter
|
9
|
+
# We exclude the tags `del` and `ins` so the diffy styling does not apply.
|
10
|
+
TAGS = (UserInputScrubber.new.tags.to_a - %w(del ins)).freeze
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
str = wrap_lines(@diff.map { |line| wrap_line(line) })
|
14
|
+
ActionView::Base.new.sanitize(str, tags: TAGS)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Adding a new method to Diffy::Format so we can pass the
|
19
|
+
# `:unescaped_html` option when calling Diffy::Diff#to_s.
|
20
|
+
Diffy::Format.module_eval do
|
21
|
+
def unescaped_html
|
22
|
+
UnescapedHtmlFormatter.new(self, options).to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -40,8 +40,12 @@ module Decidim
|
|
40
40
|
# `export.collection.call(artifact_type)` and, when evaluated,
|
41
41
|
# will get passed an instance of the parent artifact type,
|
42
42
|
# `Decidim::ParticipatorySpace` or `Decidim::Component` for example,
|
43
|
-
# so you can easily find the elements to export.
|
44
|
-
#
|
43
|
+
# so you can easily find the elements to export. It also receives, as a
|
44
|
+
# second parameter, the user triggering the action, in case you need to
|
45
|
+
# filter the collection based on the user.
|
46
|
+
#
|
47
|
+
# The +collection block+ in the end should return the collection of
|
48
|
+
# elements to be serialized.
|
45
49
|
#
|
46
50
|
# &block - An optional block that returns the collection once evaluated.
|
47
51
|
#
|
@@ -8,7 +8,7 @@ module Decidim
|
|
8
8
|
# Wrap the radio buttons collection in a custom fieldset.
|
9
9
|
# It also renders the inputs inside its labels.
|
10
10
|
def collection_radio_buttons(method, collection, value_method, label_method, options = {}, html_options = {})
|
11
|
-
fieldset_wrapper
|
11
|
+
fieldset_wrapper(options[:legend_title], "#{method}_collection_radio_buttons_filter") do
|
12
12
|
super(method, collection, value_method, label_method, options, html_options) do |builder|
|
13
13
|
if block_given?
|
14
14
|
yield builder
|
@@ -22,7 +22,7 @@ module Decidim
|
|
22
22
|
# Wrap the check_boxes collection in a custom fieldset.
|
23
23
|
# It also renders the inputs inside its labels.
|
24
24
|
def collection_check_boxes(method, collection, value_method, label_method, options = {}, html_options = {})
|
25
|
-
fieldset_wrapper
|
25
|
+
fieldset_wrapper(options[:legend_title], "#{method}_collection_check_boxes_filter") do
|
26
26
|
super(method, collection, value_method, label_method, options, html_options) do |builder|
|
27
27
|
if block_given?
|
28
28
|
yield builder
|
@@ -33,23 +33,37 @@ module Decidim
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
# Wrap the dependant check_boxes in a custom fieldset.
|
37
|
+
# checked parent checks its children
|
38
|
+
def check_boxes_tree(method, collection, options = {})
|
39
|
+
fieldset_wrapper(options[:legend_title], "#{method}_check_boxes_tree_filter") do
|
40
|
+
@template.render("decidim/shared/check_boxes_tree",
|
41
|
+
form: self,
|
42
|
+
attribute: method,
|
43
|
+
collection: collection,
|
44
|
+
check_boxes_tree_id: check_boxes_tree_id(method),
|
45
|
+
hide_node: "false",
|
46
|
+
options: options).html_safe
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
36
50
|
# Wrap the category select in a custom fieldset.
|
37
51
|
def categories_select(method, collection, options = {})
|
38
|
-
fieldset_wrapper
|
52
|
+
fieldset_wrapper(options[:legend_title], "#{method}_categories_select_filter") do
|
39
53
|
super(method, collection, options)
|
40
54
|
end
|
41
55
|
end
|
42
56
|
|
43
57
|
# Wrap the areas select in a custom fieldset.
|
44
58
|
def areas_select(method, collection, options = {})
|
45
|
-
fieldset_wrapper
|
59
|
+
fieldset_wrapper(options[:legend_title], "#{method}_areas_select_filter") do
|
46
60
|
super(method, collection, options)
|
47
61
|
end
|
48
62
|
end
|
49
63
|
|
50
64
|
# Wrap the scopes picker in a custom fieldset.
|
51
65
|
def scopes_picker(method, options = { checkboxes_on_top: true })
|
52
|
-
fieldset_wrapper
|
66
|
+
fieldset_wrapper(options[:legend_title], "#{method}_scopes_picker_filter") do
|
53
67
|
super(method, options)
|
54
68
|
end
|
55
69
|
end
|
@@ -57,8 +71,8 @@ module Decidim
|
|
57
71
|
private
|
58
72
|
|
59
73
|
# Private: Renders a custom fieldset and execute the given block.
|
60
|
-
def fieldset_wrapper(legend_title)
|
61
|
-
@template.content_tag(:div, "", class: "filters__section") do
|
74
|
+
def fieldset_wrapper(legend_title, extra_class)
|
75
|
+
@template.content_tag(:div, "", class: "filters__section #{extra_class}") do
|
62
76
|
@template.content_tag(:fieldset) do
|
63
77
|
@template.content_tag(:legend) do
|
64
78
|
@template.content_tag(:h6, legend_title, class: "heading6")
|
@@ -66,5 +80,9 @@ module Decidim
|
|
66
80
|
end
|
67
81
|
end
|
68
82
|
end
|
83
|
+
|
84
|
+
def check_boxes_tree_id(attribute)
|
85
|
+
"#{attribute}-#{object_id}"
|
86
|
+
end
|
69
87
|
end
|
70
88
|
end
|
data/lib/decidim/form_builder.rb
CHANGED
@@ -95,7 +95,7 @@ module Decidim
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def translated_one_locale(type, name, locale, options = {})
|
98
|
-
return hashtaggable_text_field(type, name, locale, options
|
98
|
+
return hashtaggable_text_field(type, name, locale, options) if options[:hashtaggable]
|
99
99
|
|
100
100
|
send(
|
101
101
|
type,
|
@@ -181,7 +181,7 @@ module Decidim
|
|
181
181
|
|
182
182
|
content_tag(:div, class: "editor #{"hashtags__container" if options[:hashtaggable]}") do
|
183
183
|
template = ""
|
184
|
-
template += label(name, options[:label].to_s || name) if options[:label] != false
|
184
|
+
template += label(name, options[:label].to_s || name) + required_for_attribute(name) if options[:label] != false
|
185
185
|
template += hidden_field(name, options)
|
186
186
|
template += content_tag(:div, nil, class: "editor-container #{"js-hashtags" if options[:hashtaggable]}", data: {
|
187
187
|
toolbar: options[:toolbar],
|
data/lib/decidim/has_settings.rb
CHANGED
@@ -10,6 +10,14 @@ module Decidim
|
|
10
10
|
after_initialize :default_values
|
11
11
|
end
|
12
12
|
|
13
|
+
class_methods do
|
14
|
+
# Returns a Class with the attributes sanitized, coerced and filtered
|
15
|
+
# to the right type. See Decidim::SettingsManifest#schema.
|
16
|
+
def build_settings(manifest, settings_name, data, organization)
|
17
|
+
manifest.settings(settings_name).schema.new(data, organization.default_locale)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
13
21
|
def settings
|
14
22
|
new_settings_schema(:global, self[:settings]["global"])
|
15
23
|
end
|
@@ -59,12 +67,10 @@ module Decidim
|
|
59
67
|
step_settings.fetch(active_step.id.to_s)
|
60
68
|
end
|
61
69
|
|
62
|
-
|
63
|
-
# to the right type. See Decidim::SettingsManifest#schema.
|
64
|
-
def new_settings_schema(name, data)
|
70
|
+
def new_settings_schema(settings_name, data)
|
65
71
|
return {} unless manifest && participatory_space
|
66
72
|
|
67
|
-
|
73
|
+
self.class.build_settings(manifest, settings_name, data, participatory_space.organization)
|
68
74
|
end
|
69
75
|
|
70
76
|
def default_values
|
@@ -24,6 +24,8 @@ module Decidim
|
|
24
24
|
attribute :route_name, String
|
25
25
|
|
26
26
|
attribute :query_type, String, default: "Decidim::Core::ParticipatorySpaceType"
|
27
|
+
attribute :query_finder, String, default: "Decidim::Core::ParticipatorySpaceFinder"
|
28
|
+
attribute :query_list, String, default: "Decidim::Core::ParticipatorySpaceList"
|
27
29
|
|
28
30
|
# An array with the name of the classes that will be exported with
|
29
31
|
# the data portability feature for this component. For example, `Decidim::<MyModule>::<MyClass>``
|
@@ -113,6 +115,24 @@ module Decidim
|
|
113
115
|
permissions_class_name&.constantize
|
114
116
|
end
|
115
117
|
|
118
|
+
# Public: Stores an instance of StatsRegistry
|
119
|
+
def stats
|
120
|
+
@stats ||= StatsRegistry.new
|
121
|
+
end
|
122
|
+
|
123
|
+
# Public: Registers a stat inside a participatory_space manifest.
|
124
|
+
#
|
125
|
+
# name - The name of the stat
|
126
|
+
# options - A hash of options
|
127
|
+
# * primary: Whether the stat is primary or not.
|
128
|
+
# * priority: The priority of the stat used for render issues.
|
129
|
+
# block - A block that receive the components to filter out the stat.
|
130
|
+
#
|
131
|
+
# Returns nothing.
|
132
|
+
def register_stat(name, options = {}, &block)
|
133
|
+
stats.register(name, options, &block)
|
134
|
+
end
|
135
|
+
|
116
136
|
# Public: Registers a resource. Exposes a DSL defined by
|
117
137
|
# `Decidim::ResourceManifest`.
|
118
138
|
#
|
@@ -20,6 +20,8 @@ module Decidim
|
|
20
20
|
extend ActiveSupport::Concern
|
21
21
|
|
22
22
|
included do
|
23
|
+
extend Decidim::Deprecations
|
24
|
+
|
23
25
|
# An association with all the links that point to this model.
|
24
26
|
has_many :participatory_space_resource_links_to, as: :to, class_name: "Decidim::ParticipatorySpaceLink"
|
25
27
|
|
@@ -64,7 +66,7 @@ module Decidim
|
|
64
66
|
# data - An optional Hash to add to the link.
|
65
67
|
#
|
66
68
|
# Returns nothing.
|
67
|
-
def
|
69
|
+
def link_participatory_space_resources(resources, link_name, data = {})
|
68
70
|
transaction do
|
69
71
|
participatory_space_resource_links_from.where(name: link_name).delete_all
|
70
72
|
Array.wrap(resources).each do |resource|
|
@@ -77,6 +79,7 @@ module Decidim
|
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
82
|
+
deprecated_alias :link_participatory_spaces_resources, :link_participatory_space_resources
|
80
83
|
|
81
84
|
# Public: This method will be used to represent this participatory space in other contexts, like cards
|
82
85
|
# or search results.
|
@@ -97,6 +100,37 @@ module Decidim
|
|
97
100
|
def visible?
|
98
101
|
published? && !try(:private_space?)
|
99
102
|
end
|
103
|
+
|
104
|
+
# Defines a way to get the user roles for the current participatory space.
|
105
|
+
# You should overwrite this method in the implementer class to define how
|
106
|
+
# to get the correct values.
|
107
|
+
#
|
108
|
+
# role_name - A symbol or string identifying the role name
|
109
|
+
#
|
110
|
+
# Returns an ActiveRecord::Relation with one role for each combination of
|
111
|
+
# `ParticipatorySpace` and `*UserRole`. `*` meaning that the concrete
|
112
|
+
# implementation of the `UserRole` may change depending on the
|
113
|
+
# `ParticipatorySpace` where it belongs to.
|
114
|
+
def user_roles(_role_name = nil)
|
115
|
+
self.class.none
|
116
|
+
end
|
117
|
+
|
118
|
+
def user_role_config_for(user, role_name)
|
119
|
+
case role_name.to_sym
|
120
|
+
when :organization_admin
|
121
|
+
Decidim::ParticipatorySpaceRoleConfig::Admin.new(user)
|
122
|
+
when :admin # ParticipatorySpace admin
|
123
|
+
Decidim::ParticipatorySpaceRoleConfig::ParticipatorySpaceAdmin.new(user)
|
124
|
+
when :valuator
|
125
|
+
Decidim::ParticipatorySpaceRoleConfig::Valuator.new(user)
|
126
|
+
when :moderator
|
127
|
+
Decidim::ParticipatorySpaceRoleConfig::Moderator.new(user)
|
128
|
+
when :collaborator
|
129
|
+
Decidim::ParticipatorySpaceRoleConfig::Collaborator.new(user)
|
130
|
+
else
|
131
|
+
Decidim::ParticipatorySpaceRoleConfig::NullObject.new(user)
|
132
|
+
end
|
133
|
+
end
|
100
134
|
end
|
101
135
|
|
102
136
|
class_methods do
|