decidim-core 0.11.2 → 0.12.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/notifications.js.es6 +8 -6
- data/app/assets/javascripts/decidim/user_registrations.js.es6 +25 -1
- data/app/assets/stylesheets/decidim/application.scss.erb +4 -0
- data/app/assets/stylesheets/decidim/layouts/_home.scss +79 -0
- data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_cards.scss +82 -38
- data/app/assets/stylesheets/decidim/modules/_collapsible-list.scss +16 -0
- data/app/assets/stylesheets/decidim/modules/_definition-data.scss +27 -0
- data/app/assets/stylesheets/decidim/modules/_fingerprint.scss +8 -0
- data/app/assets/stylesheets/decidim/modules/_horizontal-tabs.scss +51 -0
- data/app/assets/stylesheets/decidim/modules/_inline-filters.scss +5 -3
- data/app/assets/stylesheets/decidim/modules/_margins.scss +6 -4
- data/app/assets/stylesheets/decidim/modules/_modules.scss +3 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +113 -7
- data/app/assets/stylesheets/decidim/modules/_signup.scss +22 -5
- data/app/assets/stylesheets/decidim/modules/_toggle.scss +9 -0
- data/app/assets/stylesheets/decidim/modules/_typography.scss +5 -1
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +42 -0
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +6 -0
- data/app/assets/stylesheets/decidim/utils/_settings.scss +3 -2
- data/app/cells/decidim/announcement/show.erb +11 -0
- data/app/cells/decidim/announcement_cell.rb +32 -0
- data/app/cells/decidim/author/comments.erb +6 -0
- data/app/cells/decidim/author/contact.erb +3 -0
- data/app/cells/decidim/author/date.erb +5 -0
- data/app/cells/decidim/author/flag.erb +5 -0
- data/app/cells/decidim/author/profile.erb +9 -0
- data/app/cells/decidim/{profile → author}/profile_inline.erb +1 -1
- data/app/cells/decidim/author/show.erb +18 -0
- data/app/cells/decidim/author/withdraw.erb +6 -0
- data/app/cells/decidim/author_cell.rb +109 -0
- data/app/cells/decidim/card/show.erb +18 -16
- data/app/cells/decidim/card_cell.rb +17 -4
- data/app/cells/decidim/card_m/author.erb +3 -0
- data/app/cells/decidim/card_m/badge.erb +1 -0
- data/app/cells/decidim/card_m/comments_counter.erb +3 -0
- data/app/cells/decidim/card_m/data.erb +0 -0
- data/app/cells/decidim/card_m/footer.erb +0 -0
- data/app/cells/decidim/card_m/header.erb +17 -0
- data/app/cells/decidim/card_m/image.erb +5 -0
- data/app/cells/decidim/card_m/label.erb +3 -0
- data/app/cells/decidim/card_m/show.erb +24 -0
- data/app/cells/decidim/card_m/status.erb +9 -0
- data/app/cells/decidim/card_m/tags.erb +0 -0
- data/app/cells/decidim/card_m_cell.rb +136 -0
- data/app/cells/decidim/collapsible_list/show.erb +20 -0
- data/app/cells/decidim/collapsible_list_cell.rb +66 -0
- data/app/cells/decidim/fingerprint/show.erb +22 -0
- data/app/cells/decidim/fingerprint_cell.rb +17 -0
- data/app/cells/decidim/follow_button/show.erb +34 -0
- data/app/cells/decidim/follow_button_cell.rb +40 -0
- data/app/cells/decidim/followers/show.erb +9 -0
- data/app/cells/decidim/followers_cell.rb +18 -0
- data/app/cells/decidim/following/show.erb +9 -0
- data/app/cells/decidim/following_cell.rb +24 -0
- data/app/cells/decidim/notifications/show.erb +48 -0
- data/app/cells/decidim/notifications_cell.rb +21 -0
- data/app/cells/decidim/progress_bar/show.erb +17 -0
- data/app/cells/decidim/progress_bar_cell.rb +68 -0
- data/app/cells/decidim/tags/category.erb +1 -0
- data/app/cells/decidim/tags/scope.erb +1 -0
- data/app/cells/decidim/tags/show.erb +5 -0
- data/app/cells/decidim/tags_cell.rb +62 -0
- data/app/cells/decidim/tos_page/announcement.erb +2 -0
- data/app/cells/decidim/tos_page/refuse_btn_modal.erb +23 -0
- data/app/cells/decidim/tos_page/sticky_form.erb +29 -0
- data/app/cells/decidim/tos_page_cell.rb +39 -0
- data/app/cells/decidim/user_profile/footer.erb +5 -0
- data/app/cells/decidim/user_profile/header.erb +20 -0
- data/app/cells/decidim/user_profile_cell.rb +26 -0
- data/app/commands/decidim/create_omniauth_registration.rb +1 -1
- data/app/commands/decidim/create_registration.rb +2 -1
- data/app/commands/decidim/search.rb +45 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +15 -12
- data/app/controllers/concerns/decidim/http_caching_disabler.rb +21 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +1 -6
- data/app/controllers/concerns/decidim/locale_switcher.rb +1 -1
- data/app/controllers/concerns/decidim/needs_permission.rb +70 -0
- data/app/controllers/concerns/decidim/needs_tos_accepted.rb +42 -0
- data/app/controllers/concerns/decidim/participatory_space_context.rb +1 -7
- data/app/controllers/concerns/decidim/user_profile.rb +3 -1
- data/app/controllers/decidim/account_controller.rb +4 -4
- data/app/controllers/decidim/application_controller.rb +17 -8
- data/app/controllers/decidim/components/base_controller.rb +14 -9
- data/app/controllers/decidim/cookie_policy_controller.rb +0 -2
- data/app/controllers/decidim/devise/confirmations_controller.rb +13 -0
- data/app/controllers/decidim/devise/invitations_controller.rb +3 -1
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +9 -3
- data/app/controllers/decidim/devise/passwords_controller.rb +1 -1
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -7
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +0 -2
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +0 -1
- data/app/controllers/decidim/errors_controller.rb +0 -2
- data/app/controllers/decidim/follows_controller.rb +4 -2
- data/app/controllers/decidim/locales_controller.rb +1 -1
- data/app/controllers/decidim/messaging/conversations_controller.rb +5 -5
- data/app/controllers/decidim/newsletters_controller.rb +0 -2
- data/app/controllers/decidim/notifications_controller.rb +3 -19
- data/app/controllers/decidim/notifications_settings_controller.rb +2 -2
- data/app/controllers/decidim/pages_controller.rb +12 -10
- data/app/controllers/decidim/profiles_controller.rb +10 -4
- data/app/controllers/decidim/reports_controller.rb +14 -1
- data/app/controllers/decidim/scopes_controller.rb +3 -3
- data/app/controllers/decidim/searches_controller.rb +39 -0
- data/app/controllers/decidim/static_map_controller.rb +0 -2
- data/app/controllers/decidim/tos_controller.rb +20 -0
- data/app/controllers/decidim/widgets_controller.rb +0 -1
- data/app/forms/decidim/follow_form.rb +1 -0
- data/app/forms/decidim/registration_form.rb +2 -1
- data/app/helpers/decidim/card_helper.rb +2 -0
- data/app/helpers/decidim/cells_paginate_helper.rb +16 -0
- data/app/helpers/decidim/cta_button_helper.rb +1 -1
- data/app/helpers/decidim/decidim_form_helper.rb +4 -0
- data/app/helpers/decidim/icon_helper.rb +2 -0
- data/app/helpers/decidim/resource_helper.rb +1 -2
- data/app/helpers/decidim/scopes_helper.rb +17 -10
- data/app/helpers/decidim/searches_helper.rb +16 -0
- data/app/helpers/decidim/tooltip_helper.rb +12 -0
- data/app/models/decidim/organization.rb +10 -0
- data/app/models/decidim/permission_action.rb +40 -0
- data/app/models/decidim/searchable_resource.rb +37 -0
- data/app/models/decidim/static_page.rb +4 -0
- data/app/models/decidim/user.rb +39 -3
- data/app/permissions/decidim/default_permissions.rb +61 -0
- data/app/permissions/decidim/permissions.rb +106 -0
- data/app/permissions/decidim/user_manager_permissions.rb +24 -0
- data/app/presenters/decidim/admin_log/organization_presenter.rb +2 -1
- data/app/presenters/decidim/home_stats_presenter.rb +2 -8
- data/app/presenters/decidim/user_presenter.rb +8 -0
- data/app/services/decidim/traceability.rb +6 -9
- data/app/types/decidim/core/user_type.rb +1 -1
- data/app/views/decidim/devise/invitations/edit.html.erb +56 -10
- data/app/views/decidim/devise/registrations/new.html.erb +36 -14
- data/app/views/decidim/devise/shared/_newsletter_modal.html.erb +25 -0
- data/app/views/decidim/follows/update_button.js.erb +2 -2
- data/app/views/decidim/messaging/conversations/_message.html.erb +1 -1
- data/app/views/{pages → decidim/pages}/decidim_page.html.erb +5 -0
- data/app/views/decidim/pages/home.html.erb +17 -0
- data/app/views/{pages → decidim/pages}/home/_extended.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_footer_sub_hero.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_hero.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_highlighted_content_banner.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_highlighted_processes.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_statistics.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_sub_hero.html.erb +0 -0
- data/app/views/decidim/profiles/_followers.html.erb +5 -0
- data/app/views/decidim/profiles/_following.html.erb +5 -0
- data/app/views/decidim/profiles/_notifications.html.erb +0 -0
- data/app/views/decidim/profiles/_user.html.erb +59 -0
- data/app/views/decidim/profiles/_user_follow.erb +32 -0
- data/app/views/decidim/profiles/show.html.erb +32 -59
- data/app/views/decidim/searches/_count.html.erb +1 -0
- data/app/views/decidim/searches/_filters.html.erb +20 -0
- data/app/views/decidim/searches/_filters_small_view.html.erb +18 -0
- data/app/views/decidim/searches/_results.html.erb +5 -0
- data/app/views/decidim/searches/index.html.erb +20 -0
- data/app/views/decidim/searches/index.js.erb +5 -0
- data/app/views/decidim/shared/_address_details.html.erb +7 -9
- data/app/views/decidim/shared/_announcement.html.erb +1 -6
- data/app/views/decidim/shared/_author_reference.html.erb +1 -1
- data/app/views/decidim/shared/_follow_button.html.erb +1 -34
- data/app/views/decidim/shared/_static_map.html.erb +3 -1
- data/app/views/decidim/shared/_tags.html.erb +1 -11
- data/app/views/kaminari/decidim/_paginator.html.erb +16 -15
- data/app/views/layouts/decidim/_head.html.erb +1 -0
- data/app/views/layouts/decidim/_topbar_search.html.erb +8 -0
- data/app/views/layouts/decidim/_user_menu.html.erb +2 -2
- data/app/views/layouts/decidim/_wrapper.html.erb +3 -2
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/rack_attack.rb +28 -0
- data/config/locales/ca.yml +136 -55
- data/config/locales/en.yml +135 -54
- data/config/locales/es.yml +136 -55
- data/config/locales/eu.yml +136 -54
- data/config/locales/fi.yml +135 -54
- data/config/locales/fr.yml +136 -54
- data/config/locales/gl.yml +136 -54
- data/config/locales/it.yml +136 -54
- data/config/locales/nl.yml +136 -54
- data/config/locales/pl.yml +144 -54
- data/config/locales/pt-BR.yml +136 -54
- data/config/locales/pt.yml +136 -54
- data/config/locales/ru.yml +150 -60
- data/config/locales/sv.yml +136 -54
- data/config/locales/uk.yml +146 -57
- data/config/routes.rb +11 -1
- data/db/migrate/20180209122819_create_decidim_searchable_resource.rb +21 -0
- data/db/migrate/20180508111640_add_tos_version_to_organization.rb +19 -0
- data/db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb +25 -0
- data/db/seeds.rb +33 -26
- data/lib/decidim/component_manifest.rb +35 -27
- data/lib/decidim/content_processor.rb +21 -3
- data/lib/decidim/core.rb +27 -16
- data/lib/decidim/core/engine.rb +8 -19
- data/lib/decidim/core/test.rb +2 -0
- data/lib/decidim/core/test/factories.rb +34 -4
- data/lib/decidim/core/test/shared_examples/fingerprint_examples.rb +15 -0
- data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +27 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/events/base_event.rb +5 -1
- data/lib/decidim/fingerprint_calculator.rb +42 -0
- data/lib/decidim/fingerprintable.rb +63 -0
- data/lib/decidim/form_builder.rb +1 -0
- data/lib/decidim/manifest_registry.rb +4 -10
- data/lib/decidim/participable.rb +4 -0
- data/lib/decidim/participatory_space_manifest.rb +36 -0
- data/lib/decidim/participatory_space_resourceable.rb +11 -0
- data/lib/decidim/resource_manifest.rb +10 -11
- data/lib/decidim/resourceable.rb +3 -2
- data/lib/decidim/search_resource_fields_mapper.rb +93 -0
- data/lib/decidim/searchable.rb +85 -0
- data/lib/decidim/settings_manifest.rb +3 -2
- data/lib/decidim/traceable.rb +2 -0
- data/lib/decidim/view_model.rb +9 -0
- data/lib/tasks/decidim_tasks.rake +79 -1
- metadata +149 -76
- data/app/assets/stylesheets/decidim/extras/_register_form.scss +0 -9
- data/app/cells/decidim/author_box/show.erb +0 -10
- data/app/cells/decidim/author_box_cell.rb +0 -21
- data/app/cells/decidim/profile/show.erb +0 -13
- data/app/cells/decidim/profile_cell.rb +0 -17
- data/app/controllers/concerns/decidim/needs_authorization.rb +0 -46
- data/app/models/decidim/abilities/admin_ability.rb +0 -29
- data/app/models/decidim/abilities/base_ability.rb +0 -56
- data/app/models/decidim/abilities/everyone_ability.rb +0 -25
- data/app/models/decidim/abilities/participatory_process_admin_ability.rb +0 -28
- data/app/models/decidim/abilities/participatory_process_collaborator_ability.rb +0 -28
- data/app/models/decidim/abilities/participatory_process_moderator_ability.rb +0 -15
- data/app/models/decidim/abilities/user_manager_ability.rb +0 -35
- data/app/views/decidim/notifications/_notification.html.erb +0 -20
- data/app/views/decidim/notifications/index.html.erb +0 -36
- data/app/views/decidim/shared/_author.html.erb +0 -21
- data/app/views/pages/home.html.erb +0 -17
- data/db/migrate/20180613080638_rename_missing_features_to_components.rb +0 -15
- data/lib/decidim/abilities.rb +0 -7
- data/lib/decidim/abilities/participatory_process_role_ability.rb +0 -60
- data/lib/decidim/page_finder.rb +0 -49
data/config/routes.rb
CHANGED
@@ -39,7 +39,7 @@ Decidim::Core::Engine.routes.draw do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
resources :conversations, only: [:new, :create, :index, :show, :update], controller: "messaging/conversations"
|
42
|
-
resources :notifications, only: [:
|
42
|
+
resources :notifications, only: [:destroy] do
|
43
43
|
collection do
|
44
44
|
delete :read_all
|
45
45
|
end
|
@@ -49,13 +49,23 @@ Decidim::Core::Engine.routes.draw do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
resources :profiles, only: [:show], param: :nickname
|
52
|
+
scope "/profiles/:nickname" do
|
53
|
+
get "notifications", to: "profiles#show", as: "profile_notifications", active: "notifications"
|
54
|
+
get "following", to: "profiles#show", as: "profile_following", active: "following"
|
55
|
+
get "followers", to: "profiles#show", as: "profile_followers", active: "followers"
|
56
|
+
end
|
52
57
|
|
53
58
|
resources :pages, only: [:index, :show], format: false
|
54
59
|
|
60
|
+
get "/search", to: "searches#index", as: :search
|
61
|
+
|
62
|
+
get :organization_users, to: "users#index"
|
63
|
+
|
55
64
|
get "/scopes/picker", to: "scopes#picker", as: :scopes_picker
|
56
65
|
|
57
66
|
get "/static_map", to: "static_map#show", as: :static_map
|
58
67
|
get "/cookies/accept", to: "cookie_policy#accept", as: :accept_cookies
|
68
|
+
put "/pages/terms-and-conditions/accept", to: "tos#accept_tos", as: :accept_tos
|
59
69
|
|
60
70
|
match "/404", to: "errors#not_found", via: :all
|
61
71
|
match "/500", to: "errors#internal_server_error", via: :all
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDecidimSearchableResource < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :decidim_searchable_resources do |t|
|
6
|
+
t.text :content_a
|
7
|
+
t.text :content_b
|
8
|
+
t.text :content_c
|
9
|
+
t.text :content_d
|
10
|
+
t.string :locale, null: false
|
11
|
+
t.datetime :datetime
|
12
|
+
|
13
|
+
t.belongs_to :decidim_scope
|
14
|
+
t.belongs_to :decidim_participatory_space, polymorphic: true, index: { name: "index_decidim_searchable_resource_on_pspace_type_and_pspace_id" }
|
15
|
+
t.belongs_to :decidim_organization
|
16
|
+
|
17
|
+
t.belongs_to :resource, polymorphic: true, index: { name: "index_decidim_searchable_rsrcs_on_s_type_and_s_id" }
|
18
|
+
t.timestamps null: false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddTosVersionToOrganization < ActiveRecord::Migration[5.1]
|
4
|
+
class Organization < ApplicationRecord
|
5
|
+
self.table_name = :decidim_organizations
|
6
|
+
end
|
7
|
+
|
8
|
+
def up
|
9
|
+
add_column :decidim_organizations, :tos_version, :datetime
|
10
|
+
Organization.find_each do |organization|
|
11
|
+
tos_version = Decidim::StaticPage.find_by(slug: "terms-and-conditions", organization: organization).updated_at
|
12
|
+
organization.update(tos_version: tos_version)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
remove_columns :decidim_organizations, :tos_version
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddAcceptedTosVersionFieldToUsers < ActiveRecord::Migration[5.1]
|
4
|
+
class Organization < ApplicationRecord
|
5
|
+
self.table_name = :decidim_organizations
|
6
|
+
has_many :users, foreign_key: "decidim_organization_id", class_name: "Decidim::User", dependent: :destroy
|
7
|
+
end
|
8
|
+
class User < ApplicationRecord
|
9
|
+
self.table_name = :decidim_users
|
10
|
+
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
|
11
|
+
end
|
12
|
+
|
13
|
+
def up
|
14
|
+
add_column :decidim_users, :accepted_tos_version, :datetime
|
15
|
+
Organization.find_each do |organization|
|
16
|
+
# rubocop:disable Rails/SkipsModelValidations
|
17
|
+
organization.users.update_all(accepted_tos_version: organization.tos_version)
|
18
|
+
# rubocop:enable Rails/SkipsModelValidations
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def down
|
23
|
+
remove_columns :decidim_users, :accepted_tos_version
|
24
|
+
end
|
25
|
+
end
|
data/db/seeds.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
if !Rails.env.production? || ENV["SEED"]
|
4
|
+
print "Creating seeds for decidim-core...\n" unless Rails.env.test?
|
5
|
+
|
4
6
|
require "decidim/faker/localized"
|
5
7
|
|
6
8
|
seeds_root = File.join(__dir__, "seeds")
|
@@ -21,37 +23,40 @@ if !Rails.env.production? || ENV["SEED"]
|
|
21
23
|
default_locale: Decidim.default_locale,
|
22
24
|
available_locales: Decidim.available_locales,
|
23
25
|
reference_prefix: Faker::Name.suffix,
|
24
|
-
available_authorizations: Decidim.authorization_workflows.map(&:name)
|
26
|
+
available_authorizations: Decidim.authorization_workflows.map(&:name),
|
27
|
+
tos_version: Time.current
|
25
28
|
)
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
municipality = Decidim::ScopeType.create!(
|
34
|
-
name: Decidim::Faker::Localized.literal("municipality"),
|
35
|
-
plural: Decidim::Faker::Localized.literal("municipalities"),
|
36
|
-
organization: organization
|
37
|
-
)
|
30
|
+
if organization.top_scopes.none?
|
31
|
+
province = Decidim::ScopeType.create!(
|
32
|
+
name: Decidim::Faker::Localized.literal("province"),
|
33
|
+
plural: Decidim::Faker::Localized.literal("provinces"),
|
34
|
+
organization: organization
|
35
|
+
)
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
code: Faker::Address.unique.country_code,
|
43
|
-
scope_type: province,
|
37
|
+
municipality = Decidim::ScopeType.create!(
|
38
|
+
name: Decidim::Faker::Localized.literal("municipality"),
|
39
|
+
plural: Decidim::Faker::Localized.literal("municipalities"),
|
44
40
|
organization: organization
|
45
41
|
)
|
46
42
|
|
47
|
-
|
48
|
-
Decidim::Scope.create!(
|
49
|
-
name: Decidim::Faker::Localized.literal(Faker::Address.unique.
|
50
|
-
code:
|
51
|
-
scope_type:
|
52
|
-
organization: organization
|
53
|
-
parent: parent
|
43
|
+
3.times do
|
44
|
+
parent = Decidim::Scope.create!(
|
45
|
+
name: Decidim::Faker::Localized.literal(Faker::Address.unique.state),
|
46
|
+
code: Faker::Address.unique.country_code,
|
47
|
+
scope_type: province,
|
48
|
+
organization: organization
|
54
49
|
)
|
50
|
+
|
51
|
+
5.times do
|
52
|
+
Decidim::Scope.create!(
|
53
|
+
name: Decidim::Faker::Localized.literal(Faker::Address.unique.city),
|
54
|
+
code: parent.code + "-" + Faker::Address.unique.state_abbr,
|
55
|
+
scope_type: municipality,
|
56
|
+
organization: organization,
|
57
|
+
parent: parent
|
58
|
+
)
|
59
|
+
end
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
@@ -96,7 +101,8 @@ if !Rails.env.production? || ENV["SEED"]
|
|
96
101
|
admin: true,
|
97
102
|
tos_agreement: true,
|
98
103
|
personal_url: Faker::Internet.url,
|
99
|
-
about: Faker::Lorem.paragraph(2)
|
104
|
+
about: Faker::Lorem.paragraph(2),
|
105
|
+
accepted_tos_version: organization.tos_version
|
100
106
|
)
|
101
107
|
|
102
108
|
regular_user = Decidim::User.find_or_initialize_by(email: "user@example.org")
|
@@ -111,7 +117,8 @@ if !Rails.env.production? || ENV["SEED"]
|
|
111
117
|
organization: organization,
|
112
118
|
tos_agreement: true,
|
113
119
|
personal_url: Faker::Internet.url,
|
114
|
-
about: Faker::Lorem.paragraph(2)
|
120
|
+
about: Faker::Lorem.paragraph(2),
|
121
|
+
accepted_tos_version: organization.tos_version
|
115
122
|
)
|
116
123
|
|
117
124
|
Decidim::Messaging::Conversation.start!(
|
@@ -46,8 +46,9 @@ module Decidim
|
|
46
46
|
# as well that allows checking for those permissions.
|
47
47
|
attribute :actions, Array[String]
|
48
48
|
|
49
|
-
# The
|
50
|
-
|
49
|
+
# The name of the class that handles the permissions for this component. It will
|
50
|
+
# probably have the form of `Decidim::<MyComponent>::Permissions`.
|
51
|
+
attribute :permissions_class_name, String, default: "Decidim::DefaultPermissions"
|
51
52
|
|
52
53
|
validates :name, presence: true
|
53
54
|
|
@@ -98,6 +99,7 @@ module Decidim
|
|
98
99
|
#
|
99
100
|
# Returns nothing.
|
100
101
|
def seed!(participatory_space)
|
102
|
+
print "-- Creating #{name} component seeds for the participatory space with ID: #{participatory_space.id}...\n" unless Rails.env.test?
|
101
103
|
@seeds&.call(participatory_space)
|
102
104
|
end
|
103
105
|
|
@@ -122,23 +124,6 @@ module Decidim
|
|
122
124
|
settings
|
123
125
|
end
|
124
126
|
|
125
|
-
# Public: Registers a resource inside a component manifest. Exposes a DSL
|
126
|
-
# defined by `Decidim::ResourceManifest`.
|
127
|
-
#
|
128
|
-
# Resource manifests are a way to expose a resource from one engine to
|
129
|
-
# the whole system. This was resoruces can be linked between them.
|
130
|
-
#
|
131
|
-
# block - A Block that will be called to set the Resource attributes.
|
132
|
-
#
|
133
|
-
# Returns nothing.
|
134
|
-
def register_resource
|
135
|
-
manifest = ResourceManifest.new
|
136
|
-
manifest.component_manifest = self
|
137
|
-
yield(manifest)
|
138
|
-
manifest.validate!
|
139
|
-
resource_manifests << manifest
|
140
|
-
end
|
141
|
-
|
142
127
|
# Public: Registers an export artifact with a name and its properties
|
143
128
|
# defined in `Decidim::Components::ExportManifest`.
|
144
129
|
#
|
@@ -169,14 +154,6 @@ module Decidim
|
|
169
154
|
end
|
170
155
|
end
|
171
156
|
|
172
|
-
# Public: Finds all the registered resource manifest's via the
|
173
|
-
# `register_resource` method.
|
174
|
-
#
|
175
|
-
# Returns an Array[ResourceManifest].
|
176
|
-
def resource_manifests
|
177
|
-
@resource_manifests ||= []
|
178
|
-
end
|
179
|
-
|
180
157
|
# Public: Stores an instance of StatsRegistry
|
181
158
|
def stats
|
182
159
|
@stats ||= StatsRegistry.new
|
@@ -194,5 +171,36 @@ module Decidim
|
|
194
171
|
def register_stat(name, options = {}, &block)
|
195
172
|
stats.register(name, options, &block)
|
196
173
|
end
|
174
|
+
|
175
|
+
# Public: Finds the permission class from its name, using the
|
176
|
+
# `permissions_class_name` attribute. If the class does not exist,
|
177
|
+
# it raises an exception. If the class name is not set, it returns nil.
|
178
|
+
#
|
179
|
+
# Returns a Class.
|
180
|
+
def permissions_class
|
181
|
+
permissions_class_name&.constantize
|
182
|
+
end
|
183
|
+
|
184
|
+
# Public: Registers a resource. Exposes a DSL defined by
|
185
|
+
# `Decidim::ResourceManifest`. Automatically sets the component manifest
|
186
|
+
# for that resource to the current one.
|
187
|
+
#
|
188
|
+
# Resource manifests are a way to expose a resource from one engine to
|
189
|
+
# the whole system. This way resources can be linked between them.
|
190
|
+
#
|
191
|
+
# name - A name for that resource. Should be singular (ie not plural).
|
192
|
+
# block - A Block that will be called to set the Resource attributes.
|
193
|
+
#
|
194
|
+
# Returns nothing.
|
195
|
+
def register_resource(name)
|
196
|
+
my_component_manifest = self
|
197
|
+
|
198
|
+
my_block = proc do |resource|
|
199
|
+
resource.component_manifest = my_component_manifest
|
200
|
+
yield(resource)
|
201
|
+
end
|
202
|
+
|
203
|
+
Decidim.register_resource(name, &my_block)
|
204
|
+
end
|
197
205
|
end
|
198
206
|
end
|
@@ -30,6 +30,10 @@ module Decidim
|
|
30
30
|
# rendered = Decidim::ContentProcessor.render(content)
|
31
31
|
# puts rendered
|
32
32
|
module ContentProcessor
|
33
|
+
extend ActionView::Helpers::SanitizeHelper
|
34
|
+
extend ActionView::Helpers::TagHelper
|
35
|
+
extend ActionView::Helpers::TextHelper
|
36
|
+
|
33
37
|
# Class that represents the result of processing a text
|
34
38
|
#
|
35
39
|
# @!attribute rewrite
|
@@ -61,9 +65,23 @@ module Decidim
|
|
61
65
|
#
|
62
66
|
# @return [String] the content processed and ready to display (it is expected to include HTML)
|
63
67
|
def self.render(content)
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
simple_format(
|
69
|
+
Decidim.content_processors.reduce(content) do |result, type|
|
70
|
+
renderer_klass(type).constantize.new(result).render
|
71
|
+
end
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
# This method overwrites the views `sanitize` method. This is required to
|
76
|
+
# ensure the content does not include any weird HTML that could harm the end
|
77
|
+
# user.
|
78
|
+
#
|
79
|
+
# @return [String] sanitized content.
|
80
|
+
def self.sanitize(text, options = {})
|
81
|
+
Rails::Html::WhiteListSanitizer.new.sanitize(
|
82
|
+
text,
|
83
|
+
{ scrubber: Decidim::UserInputScrubber.new }.merge(options)
|
84
|
+
).try(:html_safe)
|
67
85
|
end
|
68
86
|
|
69
87
|
# Guess the class name of the parser for a processor
|
data/lib/decidim/core.rb
CHANGED
@@ -45,15 +45,18 @@ module Decidim
|
|
45
45
|
autoload :MenuRegistry, "decidim/menu_registry"
|
46
46
|
autoload :Messaging, "decidim/messaging"
|
47
47
|
autoload :ManifestRegistry, "decidim/manifest_registry"
|
48
|
-
autoload :Abilities, "decidim/abilities"
|
49
48
|
autoload :EngineRouter, "decidim/engine_router"
|
50
49
|
autoload :Events, "decidim/events"
|
51
50
|
autoload :ViewHooks, "decidim/view_hooks"
|
52
51
|
autoload :NewsletterEncryptor, "decidim/newsletter_encryptor"
|
52
|
+
autoload :Searchable, "decidim/searchable"
|
53
|
+
autoload :SearchResourceFieldsMapper, "decidim/search_resource_fields_mapper"
|
53
54
|
autoload :QueryExtensions, "decidim/query_extensions"
|
54
55
|
autoload :ParticipatorySpaceResourceable, "decidim/participatory_space_resourceable"
|
55
56
|
autoload :HasPrivateUsers, "decidim/has_private_users"
|
56
57
|
autoload :ViewModel, "decidim/view_model"
|
58
|
+
autoload :FingerprintCalculator, "decidim/fingerprint_calculator"
|
59
|
+
autoload :Fingerprintable, "decidim/fingerprintable"
|
57
60
|
|
58
61
|
include ActiveSupport::Configurable
|
59
62
|
|
@@ -82,20 +85,6 @@ module Decidim
|
|
82
85
|
# the mails.
|
83
86
|
config_accessor :mailer_sender
|
84
87
|
|
85
|
-
# Exposes a configuration option: an Array of `cancancan`'s Ability classes
|
86
|
-
# that will be automatically included to the base `Decidim::Abilities::BaseAbility`
|
87
|
-
# class.
|
88
|
-
config_accessor :abilities do
|
89
|
-
[]
|
90
|
-
end
|
91
|
-
|
92
|
-
# Exposes a configuration option: an Array of `cancancan`'s Ability classes
|
93
|
-
# that will be automatically included to the `Decidim::Admin::Abilities::BaseAbility`
|
94
|
-
# class.
|
95
|
-
config_accessor :admin_abilities do
|
96
|
-
[]
|
97
|
-
end
|
98
|
-
|
99
88
|
# Exposes a configuration option: The application available locales.
|
100
89
|
config_accessor :available_locales do
|
101
90
|
%w(en ca es eu fi fr gl it nl pt pt-BR ru sv uk)
|
@@ -187,6 +176,16 @@ module Decidim
|
|
187
176
|
true
|
188
177
|
end
|
189
178
|
|
179
|
+
# Max requests in a time period to prevent DoS attacks. Only applied on production.
|
180
|
+
config_accessor :throttling_max_requests do
|
181
|
+
100
|
182
|
+
end
|
183
|
+
|
184
|
+
# Time window in which the throttling is applied.
|
185
|
+
config_accessor :throttling_period do
|
186
|
+
1.minute
|
187
|
+
end
|
188
|
+
|
190
189
|
# A base path for the uploads. If set, make sure it ends in a slash.
|
191
190
|
# Uploads will be set to `<base_path>/uploads/`. This can be useful if you
|
192
191
|
# want to use the same uploads place for both staging and production
|
@@ -259,6 +258,13 @@ module Decidim
|
|
259
258
|
participatory_space_registry.register(name, &block)
|
260
259
|
end
|
261
260
|
|
261
|
+
# Public: Registers a resource.
|
262
|
+
#
|
263
|
+
# Returns nothing.
|
264
|
+
def self.register_resource(name, &block)
|
265
|
+
resource_registry.register(name, &block)
|
266
|
+
end
|
267
|
+
|
262
268
|
# Public: Finds all registered component manifest's via the `register_component`
|
263
269
|
# method.
|
264
270
|
#
|
@@ -301,7 +307,7 @@ module Decidim
|
|
301
307
|
#
|
302
308
|
# Returns a ResourceManifest if found, nil otherwise.
|
303
309
|
def self.find_resource_manifest(resource_name_or_klass)
|
304
|
-
|
310
|
+
resource_registry.find(resource_name_or_klass)
|
305
311
|
end
|
306
312
|
|
307
313
|
# Public: Stores the registry of components
|
@@ -314,6 +320,11 @@ module Decidim
|
|
314
320
|
@participatory_space_registry ||= ManifestRegistry.new(:participatory_spaces)
|
315
321
|
end
|
316
322
|
|
323
|
+
# Public: Stores the registry of resource spaces
|
324
|
+
def self.resource_registry
|
325
|
+
@resource_registry ||= ManifestRegistry.new(:resources)
|
326
|
+
end
|
327
|
+
|
317
328
|
# Public: Stores an instance of StatsRegistry
|
318
329
|
def self.stats
|
319
330
|
@stats ||= StatsRegistry.new
|
data/lib/decidim/core/engine.rb
CHANGED
@@ -22,11 +22,9 @@ require "rectify"
|
|
22
22
|
require "decidim/rectify_ext"
|
23
23
|
|
24
24
|
require "carrierwave"
|
25
|
-
require "high_voltage"
|
26
25
|
require "rails-i18n"
|
27
26
|
require "date_validator"
|
28
27
|
require "sprockets/es6"
|
29
|
-
require "cancancan"
|
30
28
|
require "truncato"
|
31
29
|
require "file_validators"
|
32
30
|
require "omniauth"
|
@@ -39,6 +37,7 @@ require "geocoder"
|
|
39
37
|
require "paper_trail"
|
40
38
|
require "cells/rails"
|
41
39
|
require "cells-erb"
|
40
|
+
require "kaminari"
|
42
41
|
require "doorkeeper"
|
43
42
|
require "doorkeeper-i18n"
|
44
43
|
|
@@ -72,12 +71,6 @@ module Decidim
|
|
72
71
|
app.config.assets.debug = true if Rails.env.test?
|
73
72
|
end
|
74
73
|
|
75
|
-
initializer "decidim.high_voltage" do |_app|
|
76
|
-
HighVoltage.configure do |config|
|
77
|
-
config.routes = false
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
74
|
initializer "decidim.default_form_builder" do |_app|
|
82
75
|
ActionView::Base.default_form_builder = Decidim::FormBuilder
|
83
76
|
end
|
@@ -86,17 +79,6 @@ module Decidim
|
|
86
79
|
app.config.exceptions_app = Decidim::Core::Engine.routes
|
87
80
|
end
|
88
81
|
|
89
|
-
initializer "decidim.inject_abilities_to_user" do |_app|
|
90
|
-
Decidim.configure do |config|
|
91
|
-
config.abilities << "Decidim::Abilities::EveryoneAbility"
|
92
|
-
config.abilities << "Decidim::Abilities::AdminAbility"
|
93
|
-
config.abilities << "Decidim::Abilities::UserManagerAbility"
|
94
|
-
config.abilities << "Decidim::Abilities::ParticipatoryProcessAdminAbility"
|
95
|
-
config.abilities << "Decidim::Abilities::ParticipatoryProcessCollaboratorAbility"
|
96
|
-
config.abilities << "Decidim::Abilities::ParticipatoryProcessModeratorAbility"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
82
|
initializer "decidim.locales" do |app|
|
101
83
|
app.config.i18n.fallbacks = true
|
102
84
|
end
|
@@ -280,6 +262,13 @@ module Decidim
|
|
280
262
|
inflect.acronym "OAuth"
|
281
263
|
end
|
282
264
|
end
|
265
|
+
|
266
|
+
initializer "decidim.core.register_resources" do
|
267
|
+
Decidim.register_resource(:user) do |resource|
|
268
|
+
resource.model_class_name = "Decidim::User"
|
269
|
+
resource.card = "decidim/user_profile"
|
270
|
+
end
|
271
|
+
end
|
283
272
|
end
|
284
273
|
end
|
285
274
|
end
|