decidim-core 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/decidim_core_manifest.js +1 -0
- data/app/assets/javascripts/decidim/notifications.js.es6 +33 -0
- data/app/assets/stylesheets/decidim/extras/_meeting-registrations.scss +11 -0
- data/app/assets/stylesheets/decidim/modules/_extra.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_process-nav.scss +14 -0
- data/app/commands/decidim/create_follow.rb +40 -0
- data/app/commands/decidim/create_omniauth_registration.rb +0 -2
- data/app/commands/decidim/create_registration.rb +1 -3
- data/app/commands/decidim/create_report.rb +7 -7
- data/app/commands/decidim/delete_follow.rb +37 -0
- data/app/commands/decidim/invite_user.rb +1 -3
- data/app/commands/decidim/update_notifications_settings.rb +1 -2
- data/app/constraints/decidim/current_feature.rb +3 -4
- data/app/controllers/concerns/decidim/settings.rb +1 -1
- data/app/controllers/decidim/features/base_controller.rb +5 -6
- data/app/controllers/decidim/follows_controller.rb +45 -0
- data/app/controllers/decidim/notifications_controller.rb +39 -0
- data/app/controllers/decidim/pages_controller.rb +2 -2
- data/app/controllers/decidim/scopes_controller.rb +2 -0
- data/app/controllers/decidim/widgets_controller.rb +3 -3
- data/app/forms/decidim/follow_form.rb +20 -0
- data/app/forms/decidim/invite_user_form.rb +1 -1
- data/app/forms/decidim/notifications_settings_form.rb +2 -4
- data/app/helpers/decidim/action_authorization_helper.rb +2 -1
- data/app/helpers/decidim/decidim_form_helper.rb +4 -0
- data/app/helpers/decidim/feature_path_helper.rb +2 -13
- data/app/helpers/decidim/icon_helper.rb +26 -8
- data/app/helpers/decidim/paginate_helper.rb +1 -1
- data/app/helpers/decidim/scopes_helper.rb +1 -1
- data/app/jobs/decidim/email_notification_generator_job.rb +12 -0
- data/app/jobs/decidim/export_job.rb +1 -3
- data/app/jobs/decidim/notification_generator_for_recipient_job.rb +14 -0
- data/app/jobs/decidim/notification_generator_job.rb +12 -0
- data/app/mailers/decidim/export_mailer.rb +6 -7
- data/app/mailers/decidim/notification_mailer.rb +20 -0
- data/app/mailers/decidim/reported_mailer.rb +3 -3
- data/app/models/decidim/abilities/admin_ability.rb +0 -1
- data/app/models/decidim/abilities/base_ability.rb +8 -0
- data/app/models/decidim/abilities/everyone_ability.rb +0 -2
- data/app/models/decidim/abilities/participatory_process_admin_ability.rb +1 -1
- data/app/models/decidim/abilities/participatory_process_collaborator_ability.rb +1 -1
- data/app/models/decidim/category.rb +4 -4
- data/app/models/decidim/feature.rb +29 -4
- data/app/models/decidim/follow.rb +10 -0
- data/app/models/decidim/moderation.rb +1 -1
- data/app/models/decidim/notification.rb +12 -0
- data/app/models/decidim/scope.rb +8 -8
- data/app/models/decidim/user.rb +11 -1
- data/app/presenters/decidim/home_stats_presenter.rb +1 -1
- data/app/presenters/decidim/resource_locator_presenter.rb +3 -18
- data/app/queries/decidim/participatory_processes_with_user_role.rb +1 -1
- data/app/services/decidim/email_notification_generator.rb +63 -0
- data/app/services/decidim/events_manager.rb +41 -0
- data/app/services/decidim/notification_generator.rb +51 -0
- data/app/services/decidim/notification_generator_for_recipient.rb +50 -0
- data/app/uploaders/decidim/attachment_uploader.rb +1 -1
- data/app/views/decidim/authorizations/first_login.html.erb +2 -2
- data/app/views/decidim/follows/update_button.js.erb +3 -0
- data/app/views/decidim/notification_mailer/event_received.html.erb +9 -0
- data/app/views/decidim/notifications/_notification.html.erb +18 -0
- data/app/views/decidim/notifications/index.html.erb +32 -0
- data/app/views/decidim/notifications_settings/show.html.erb +3 -10
- data/app/views/decidim/shared/_follow_button.html.erb +19 -0
- data/app/views/layouts/decidim/_head.html.erb +1 -0
- data/app/views/layouts/decidim/_head_extra.html.erb +7 -0
- data/app/views/layouts/decidim/_user_menu.html.erb +1 -0
- data/app/views/layouts/decidim/_wrapper.html.erb +3 -0
- data/app/views/layouts/decidim/widget.html.erb +3 -3
- data/app/views/pages/home/_hero.html.erb +1 -1
- data/app/views/pages/home/_highlighted_processes.html.erb +3 -3
- data/config/locales/ca.yml +29 -74
- data/config/locales/en.yml +23 -71
- data/config/locales/es.yml +31 -78
- data/config/locales/eu.yml +61 -65
- data/config/locales/fi.yml +91 -51
- data/config/locales/fr.yml +40 -83
- data/config/locales/it.yml +129 -54
- data/config/locales/nl.yml +90 -51
- data/config/locales/pl.yml +319 -10
- data/config/locales/uk.yml +400 -0
- data/config/routes.rb +8 -14
- data/db/migrate/20170720120231_make_moderations_polymorphic.rb +29 -0
- data/db/migrate/20170726145242_make_categories_polymorphic.rb +27 -0
- data/db/migrate/20170807123535_create_decidim_follows.rb +20 -0
- data/db/migrate/20170808071019_create_decidim_notifications.rb +13 -0
- data/db/migrate/20170906091718_add_extra_to_notifications.rb +7 -0
- data/db/migrate/20170912082054_add_emails_on_notifications_flag_to_user.rb +7 -0
- data/db/migrate/20170913092351_add_header_snippets_to_organizations.rb +7 -0
- data/db/migrate/20170914075721_remove_followable_index_from_follows.rb +7 -0
- data/db/migrate/20170914092116_remove_comment_and_replies_notifications_from_users.rb +8 -0
- data/db/seeds.rb +2 -108
- data/lib/decidim/core.rb +46 -8
- data/lib/decidim/core/engine.rb +20 -6
- data/lib/decidim/core/test.rb +3 -0
- data/lib/decidim/core/test/factories.rb +37 -75
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +0 -26
- data/lib/decidim/core/test/shared_examples/follows_examples.rb +37 -0
- data/lib/decidim/core/test/shared_examples/manage_moderations_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/process_announcements_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/reportable.rb +4 -4
- data/lib/decidim/core/test/shared_examples/reports_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +41 -0
- data/lib/decidim/core/test/shared_examples/user_localised_email_examples.rb +25 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/engine_router.rb +54 -0
- data/lib/decidim/events.rb +9 -0
- data/lib/decidim/events/base_event.rb +70 -0
- data/lib/decidim/events/email_event.rb +39 -0
- data/lib/decidim/events/notification_event.rb +32 -0
- data/lib/decidim/exporters.rb +7 -0
- data/lib/decidim/exporters/export_data.rb +14 -0
- data/lib/decidim/feature_manifest.rb +2 -2
- data/lib/decidim/features/namer.rb +1 -1
- data/lib/decidim/followable.rb +13 -0
- data/lib/decidim/form_builder.rb +1 -1
- data/lib/decidim/has_feature.rb +1 -1
- data/lib/decidim/has_settings.rb +19 -15
- data/lib/decidim/manifest_registry.rb +1 -3
- data/lib/decidim/participable.rb +80 -0
- data/lib/decidim/participatory_space_manifest.rb +40 -0
- data/lib/decidim/query_extensions.rb +1 -1
- data/lib/decidim/resource_manifest.rb +1 -1
- data/lib/decidim/settings_manifest.rb +0 -4
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.uk.js +14 -0
- data/vendor/assets/javascripts/morphdom.js +14 -5
- metadata +70 -79
- data/app/assets/images/decidim/process.svg +0 -10
- data/app/constraints/decidim/current_participatory_process.rb +0 -35
- data/app/controllers/concerns/decidim/needs_participatory_process.rb +0 -46
- data/app/controllers/decidim/participatory_process_groups_controller.rb +0 -26
- data/app/controllers/decidim/participatory_process_steps_controller.rb +0 -18
- data/app/controllers/decidim/participatory_process_widgets_controller.rb +0 -19
- data/app/controllers/decidim/participatory_processes_controller.rb +0 -49
- data/app/helpers/decidim/participatory_process_helper.rb +0 -17
- data/app/helpers/decidim/participatory_process_steps_helper.rb +0 -18
- data/app/models/decidim/participatory_process.rb +0 -61
- data/app/models/decidim/participatory_process_group.rb +0 -15
- data/app/models/decidim/participatory_process_step.rb +0 -39
- data/app/presenters/decidim/participatory_process_stats_presenter.rb +0 -50
- data/app/queries/decidim/highlighted_participatory_processes.rb +0 -10
- data/app/queries/decidim/organization_participatory_process_groups.rb +0 -14
- data/app/queries/decidim/organization_participatory_processes.rb +0 -14
- data/app/queries/decidim/organization_prioritized_participatory_processes.rb +0 -18
- data/app/queries/decidim/organization_published_participatory_processes.rb +0 -17
- data/app/queries/decidim/prioritized_participatory_processes.rb +0 -11
- data/app/queries/decidim/promoted_participatory_processes.rb +0 -10
- data/app/queries/decidim/published_participatory_processes.rb +0 -10
- data/app/views/decidim/participatory_process_groups/_participatory_process_group.html.erb +0 -22
- data/app/views/decidim/participatory_process_groups/show.html.erb +0 -11
- data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +0 -16
- data/app/views/decidim/participatory_process_steps/_timeline.html.erb +0 -7
- data/app/views/decidim/participatory_process_steps/index.html.erb +0 -14
- data/app/views/decidim/participatory_process_widgets/show.html.erb +0 -17
- data/app/views/decidim/participatory_processes/_no_processes_yet.html.erb +0 -3
- data/app/views/decidim/participatory_processes/_order_by_processes.html.erb +0 -3
- data/app/views/decidim/participatory_processes/_participatory_process.html.erb +0 -28
- data/app/views/decidim/participatory_processes/_promoted_process.html.erb +0 -32
- data/app/views/decidim/participatory_processes/_statistics.html.erb +0 -10
- data/app/views/decidim/participatory_processes/index.html.erb +0 -17
- data/app/views/decidim/participatory_processes/show.html.erb +0 -85
- data/app/views/layouts/decidim/_process_header.html.erb +0 -65
- data/app/views/layouts/decidim/_process_header_steps.html.erb +0 -27
- data/app/views/layouts/decidim/participatory_process.html.erb +0 -30
- data/config/i18n-tasks.yml +0 -138
- data/db/migrate/20161005130108_add_participatory_processes.rb +0 -19
- data/db/migrate/20161010102356_translate_processes.rb +0 -17
- data/db/migrate/20161011125616_add_hero_image_to_processes.rb +0 -7
- data/db/migrate/20161011141033_add_banner_image_to_processes.rb +0 -7
- data/db/migrate/20161013134732_add_promoted_flag_to_processes.rb +0 -7
- data/db/migrate/20161017085822_add_participatory_process_steps.rb +0 -18
- data/db/migrate/20161019072016_add_active_flag_to_step.rb +0 -13
- data/db/migrate/20161020080756_add_position_to_steps.rb +0 -9
- data/db/migrate/20161025125300_add_published_at_to_processes.rb +0 -7
- data/db/migrate/20161107152228_remove_not_null_on_step_position.rb +0 -7
- data/db/migrate/20161110092735_add_index_for_process_slug_organization.rb +0 -10
- data/db/migrate/20161116115156_create_attachments.rb +0 -18
- data/db/migrate/20170116135237_loosen_step_requirements.rb +0 -8
- data/db/migrate/20170123134023_make_attachments_polymorphic.rb +0 -20
- data/db/migrate/20170125135937_rename_attachable_to_attached_to.rb +0 -13
- data/db/migrate/20170126151123_add_extra_info_to_processes.rb +0 -10
- data/db/migrate/20170206083118_rename_extra_info_on_processes.rb +0 -14
- data/db/migrate/20170220110740_remove_steps_short_description.rb +0 -23
- data/db/migrate/20170221094835_add_scopes_to_processes.rb +0 -8
- data/db/migrate/20170228142440_add_participatory_process_groups.rb +0 -17
- data/db/migrate/20170404132616_change_steps_end_and_start_date_to_date.rb +0 -8
- data/db/migrate/20170725085104_add_show_statistics_to_participatory_processes.rb +0 -7
- data/db/migrate/20170804125402_attachment_description_nullable.rb +0 -7
- data/db/migrate/20170808080905_add_announcement_to_participatory_processes.rb +0 -7
- data/db/migrate/20170809084005_add_scopes_enabled_to_participatory_processes.rb +0 -7
- data/db/seeds/Exampledocument.pdf +0 -0
- data/db/seeds/city.jpeg +0 -0
- data/db/seeds/city2.jpeg +0 -0
- data/lib/decidim/notifiable.rb +0 -22
data/config/routes.rb
CHANGED
@@ -22,20 +22,8 @@ Decidim::Core::Engine.routes.draw do
|
|
22
22
|
|
23
23
|
resource :locale, only: [:create]
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
resources :participatory_process_steps, only: [:index], path: "steps"
|
28
|
-
resource :participatory_process_widget, only: :show, path: "embed"
|
29
|
-
end
|
30
|
-
|
31
|
-
scope "/processes/:participatory_process_id/f/:feature_id" do
|
32
|
-
Decidim.feature_manifests.each do |manifest|
|
33
|
-
next unless manifest.engine
|
34
|
-
|
35
|
-
constraints Decidim::CurrentFeature.new(manifest) do
|
36
|
-
mount manifest.engine, at: "/", as: "decidim_#{manifest.name}"
|
37
|
-
end
|
38
|
-
end
|
25
|
+
Decidim.participatory_space_manifests.each do |manifest|
|
26
|
+
mount manifest.engine, at: "/", as: "decidim_#{manifest.name}"
|
39
27
|
end
|
40
28
|
|
41
29
|
authenticate(:user) do
|
@@ -49,6 +37,11 @@ Decidim::Core::Engine.routes.draw do
|
|
49
37
|
get :delete
|
50
38
|
end
|
51
39
|
end
|
40
|
+
resources :notifications, only: [:index, :destroy] do
|
41
|
+
collection do
|
42
|
+
delete :read_all
|
43
|
+
end
|
44
|
+
end
|
52
45
|
resource :notifications_settings, only: [:show, :update], controller: "notifications_settings"
|
53
46
|
resources :own_user_groups, only: [:index]
|
54
47
|
end
|
@@ -63,6 +56,7 @@ Decidim::Core::Engine.routes.draw do
|
|
63
56
|
match "/404", to: "errors#not_found", via: :all
|
64
57
|
match "/500", to: "errors#internal_server_error", via: :all
|
65
58
|
|
59
|
+
resource :follow, only: [:create, :destroy]
|
66
60
|
resource :report, only: [:create]
|
67
61
|
|
68
62
|
root to: "pages#show", id: "home"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class MakeModerationsPolymorphic < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
remove_index :decidim_moderations,
|
6
|
+
name: "decidim_moderations_participatory_process"
|
7
|
+
|
8
|
+
add_column :decidim_moderations, :decidim_participatory_space_type, :string
|
9
|
+
|
10
|
+
reversible do |direction|
|
11
|
+
direction.up do
|
12
|
+
execute <<~SQL.squish
|
13
|
+
UPDATE decidim_moderations
|
14
|
+
SET decidim_participatory_space_type = 'Decidim::ParticipatoryProcess'
|
15
|
+
SQL
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
rename_column :decidim_moderations,
|
20
|
+
:decidim_participatory_process_id,
|
21
|
+
:decidim_participatory_space_id
|
22
|
+
|
23
|
+
add_index :decidim_moderations,
|
24
|
+
[:decidim_participatory_space_id, :decidim_participatory_space_type],
|
25
|
+
name: "decidim_moderations_participatory_space"
|
26
|
+
|
27
|
+
change_column_null :decidim_moderations, :decidim_participatory_space_type, false
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class MakeCategoriesPolymorphic < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
remove_index :decidim_categories,
|
6
|
+
name: "index_decidim_categories_on_decidim_participatory_process_id"
|
7
|
+
|
8
|
+
add_column :decidim_categories, :decidim_participatory_space_type, :string
|
9
|
+
|
10
|
+
reversible do |direction|
|
11
|
+
direction.up do
|
12
|
+
execute <<~SQL.squish
|
13
|
+
UPDATE decidim_categories
|
14
|
+
SET decidim_participatory_space_type = 'Decidim::ParticipatoryProcess'
|
15
|
+
SQL
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
rename_column :decidim_categories,
|
20
|
+
:decidim_participatory_process_id,
|
21
|
+
:decidim_participatory_space_id
|
22
|
+
|
23
|
+
add_index :decidim_categories,
|
24
|
+
[:decidim_participatory_space_id, :decidim_participatory_space_type],
|
25
|
+
name: "index_decidim_categories_on_decidim_participatory_space"
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDecidimFollows < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :decidim_follows do |t|
|
6
|
+
t.references :decidim_user, null: false
|
7
|
+
t.references :decidim_followable, polymorphic: true, index: false
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index :decidim_follows,
|
12
|
+
[:decidim_user_id, :decidim_followable_id, :decidim_followable_type],
|
13
|
+
unique: true,
|
14
|
+
name: "index_uniq_on_follows_user_and_followable"
|
15
|
+
add_index :decidim_follows,
|
16
|
+
[:decidim_followable_id, :decidim_followable_type],
|
17
|
+
unique: true,
|
18
|
+
name: "index_uniq_on_followable"
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDecidimNotifications < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :decidim_notifications do |t|
|
6
|
+
t.references :decidim_user, null: false
|
7
|
+
t.references :decidim_resource, polymorphic: true, index: false, null: false
|
8
|
+
t.string :event_name, null: false
|
9
|
+
t.string :event_class, null: false
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/db/seeds.rb
CHANGED
@@ -62,9 +62,7 @@ if !Rails.env.production? || ENV["SEED"]
|
|
62
62
|
confirmed_at: Time.current,
|
63
63
|
locale: I18n.default_locale,
|
64
64
|
admin: true,
|
65
|
-
tos_agreement: true
|
66
|
-
comments_notifications: true,
|
67
|
-
replies_notifications: true
|
65
|
+
tos_agreement: true
|
68
66
|
)
|
69
67
|
|
70
68
|
Decidim::User.find_or_initialize_by(email: "user@example.org").update!(
|
@@ -74,9 +72,7 @@ if !Rails.env.production? || ENV["SEED"]
|
|
74
72
|
confirmed_at: Time.current,
|
75
73
|
locale: I18n.default_locale,
|
76
74
|
organization: organization,
|
77
|
-
tos_agreement: true
|
78
|
-
comments_notifications: true,
|
79
|
-
replies_notifications: true
|
75
|
+
tos_agreement: true
|
80
76
|
)
|
81
77
|
|
82
78
|
Decidim::User.find_each do |user|
|
@@ -95,106 +91,4 @@ if !Rails.env.production? || ENV["SEED"]
|
|
95
91
|
)
|
96
92
|
end
|
97
93
|
end
|
98
|
-
|
99
|
-
process_groups = []
|
100
|
-
3.times do
|
101
|
-
process_groups << Decidim::ParticipatoryProcessGroup.create!(
|
102
|
-
name: Decidim::Faker::Localized.sentence(3),
|
103
|
-
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
104
|
-
Decidim::Faker::Localized.paragraph(3)
|
105
|
-
end,
|
106
|
-
hero_image: File.new(File.join(seeds_root, "city.jpeg")),
|
107
|
-
organization: organization
|
108
|
-
)
|
109
|
-
end
|
110
|
-
|
111
|
-
3.times do
|
112
|
-
Decidim::ParticipatoryProcess.create!(
|
113
|
-
title: Decidim::Faker::Localized.sentence(5),
|
114
|
-
slug: Faker::Internet.unique.slug(nil, "-"),
|
115
|
-
subtitle: Decidim::Faker::Localized.sentence(2),
|
116
|
-
hashtag: "##{Faker::Lorem.word}",
|
117
|
-
short_description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
118
|
-
Decidim::Faker::Localized.sentence(3)
|
119
|
-
end,
|
120
|
-
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
121
|
-
Decidim::Faker::Localized.paragraph(3)
|
122
|
-
end,
|
123
|
-
hero_image: File.new(File.join(seeds_root, "city.jpeg")),
|
124
|
-
banner_image: File.new(File.join(seeds_root, "city2.jpeg")),
|
125
|
-
promoted: true, published_at: 2.weeks.ago,
|
126
|
-
organization: organization,
|
127
|
-
meta_scope: Decidim::Faker::Localized.word,
|
128
|
-
developer_group: Decidim::Faker::Localized.sentence(1),
|
129
|
-
local_area: Decidim::Faker::Localized.sentence(2),
|
130
|
-
target: Decidim::Faker::Localized.sentence(3),
|
131
|
-
participatory_scope: Decidim::Faker::Localized.sentence(1),
|
132
|
-
participatory_structure: Decidim::Faker::Localized.sentence(2),
|
133
|
-
end_date: 2.month.from_now.at_midnight,
|
134
|
-
participatory_process_group: process_groups.sample,
|
135
|
-
scope: Faker::Boolean.boolean(0.5) ? nil : Decidim::Scope.reorder("RANDOM()").first
|
136
|
-
)
|
137
|
-
end
|
138
|
-
|
139
|
-
Decidim::ParticipatoryProcess.find_each do |process|
|
140
|
-
Decidim::ParticipatoryProcessStep.find_or_initialize_by(
|
141
|
-
participatory_process: process,
|
142
|
-
active: true
|
143
|
-
).update!(
|
144
|
-
title: Decidim::Faker::Localized.sentence(1, false, 2),
|
145
|
-
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
146
|
-
Decidim::Faker::Localized.paragraph(3)
|
147
|
-
end,
|
148
|
-
start_date: 1.month.ago.at_midnight,
|
149
|
-
end_date: 2.months.from_now.at_midnight
|
150
|
-
)
|
151
|
-
|
152
|
-
# Create users with specific roles
|
153
|
-
Decidim::ParticipatoryProcessUserRole::ROLES.each do |role|
|
154
|
-
email = "participatory_process_#{process.id}_#{role}@example.org"
|
155
|
-
|
156
|
-
user = Decidim::User.find_or_initialize_by(email: email)
|
157
|
-
user.update!(
|
158
|
-
name: Faker::Name.name,
|
159
|
-
password: "decidim123456",
|
160
|
-
password_confirmation: "decidim123456",
|
161
|
-
organization: organization,
|
162
|
-
confirmed_at: Time.current,
|
163
|
-
locale: I18n.default_locale,
|
164
|
-
tos_agreement: true,
|
165
|
-
comments_notifications: true,
|
166
|
-
replies_notifications: true
|
167
|
-
)
|
168
|
-
|
169
|
-
Decidim::ParticipatoryProcessUserRole.find_or_create_by!(
|
170
|
-
user: user,
|
171
|
-
participatory_process: process,
|
172
|
-
role: role
|
173
|
-
)
|
174
|
-
end
|
175
|
-
|
176
|
-
Decidim::Attachment.create!(
|
177
|
-
title: Decidim::Faker::Localized.sentence(2),
|
178
|
-
description: Decidim::Faker::Localized.sentence(5),
|
179
|
-
file: File.new(File.join(seeds_root, "city.jpeg")),
|
180
|
-
attached_to: process
|
181
|
-
)
|
182
|
-
|
183
|
-
Decidim::Attachment.create!(
|
184
|
-
title: Decidim::Faker::Localized.sentence(2),
|
185
|
-
description: Decidim::Faker::Localized.sentence(5),
|
186
|
-
file: File.new(File.join(seeds_root, "Exampledocument.pdf")),
|
187
|
-
attached_to: process
|
188
|
-
)
|
189
|
-
|
190
|
-
2.times do
|
191
|
-
Decidim::Category.create!(
|
192
|
-
name: Decidim::Faker::Localized.sentence(5),
|
193
|
-
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
194
|
-
Decidim::Faker::Localized.paragraph(3)
|
195
|
-
end,
|
196
|
-
participatory_process: process
|
197
|
-
)
|
198
|
-
end
|
199
|
-
end
|
200
94
|
end
|
data/lib/decidim/core.rb
CHANGED
@@ -12,11 +12,12 @@ module Decidim
|
|
12
12
|
autoload :FilterFormBuilder, "decidim/filter_form_builder"
|
13
13
|
autoload :DeviseFailureApp, "decidim/devise_failure_app"
|
14
14
|
autoload :FeatureManifest, "decidim/feature_manifest"
|
15
|
+
autoload :ParticipatorySpaceManifest, "decidim/participatory_space_manifest"
|
15
16
|
autoload :ResourceManifest, "decidim/resource_manifest"
|
16
17
|
autoload :Resourceable, "decidim/resourceable"
|
17
18
|
autoload :Reportable, "decidim/reportable"
|
18
19
|
autoload :Authorable, "decidim/authorable"
|
19
|
-
autoload :
|
20
|
+
autoload :Participable, "decidim/participable"
|
20
21
|
autoload :Publicable, "decidim/publicable"
|
21
22
|
autoload :Scopable, "decidim/scopable"
|
22
23
|
autoload :Features, "decidim/features"
|
@@ -26,6 +27,7 @@ module Decidim
|
|
26
27
|
autoload :HasFeature, "decidim/has_feature"
|
27
28
|
autoload :HasScope, "decidim/has_scope"
|
28
29
|
autoload :HasCategory, "decidim/has_category"
|
30
|
+
autoload :Followable, "decidim/followable"
|
29
31
|
autoload :HasReference, "decidim/has_reference"
|
30
32
|
autoload :Attributes, "decidim/attributes"
|
31
33
|
autoload :StatsRegistry, "decidim/stats_registry"
|
@@ -36,6 +38,8 @@ module Decidim
|
|
36
38
|
autoload :MenuRegistry, "decidim/menu_registry"
|
37
39
|
autoload :ManifestRegistry, "decidim/manifest_registry"
|
38
40
|
autoload :Abilities, "decidim/abilities"
|
41
|
+
autoload :EngineRouter, "decidim/engine_router"
|
42
|
+
autoload :Events, "decidim/events"
|
39
43
|
|
40
44
|
include ActiveSupport::Configurable
|
41
45
|
|
@@ -52,11 +56,7 @@ module Decidim
|
|
52
56
|
railtie.load_seed
|
53
57
|
end
|
54
58
|
|
55
|
-
Decidim
|
56
|
-
Decidim.feature_manifests.each do |feature|
|
57
|
-
feature.seed!(process)
|
58
|
-
end
|
59
|
-
end
|
59
|
+
Decidim.participatory_space_manifests.each(&:seed!)
|
60
60
|
|
61
61
|
I18n.available_locales = original_locale
|
62
62
|
end
|
@@ -90,7 +90,7 @@ module Decidim
|
|
90
90
|
|
91
91
|
# Exposes a configuration option: The application available locales.
|
92
92
|
config_accessor :available_locales do
|
93
|
-
%w(en ca es eu it fi fr nl)
|
93
|
+
%w(en ca es eu it fi fr nl uk)
|
94
94
|
end
|
95
95
|
|
96
96
|
# Exposes a configuration option: The application default locale.
|
@@ -113,7 +113,7 @@ module Decidim
|
|
113
113
|
# 6589: ID of the resource
|
114
114
|
config_accessor :resource_reference_generator do
|
115
115
|
lambda do |resource, feature|
|
116
|
-
ref = feature.
|
116
|
+
ref = feature.participatory_space.organization.reference_prefix
|
117
117
|
class_identifier = resource.class.name.demodulize[0..3].upcase
|
118
118
|
year_month = (resource.created_at || Time.current).strftime("%Y-%m")
|
119
119
|
|
@@ -156,6 +156,21 @@ module Decidim
|
|
156
156
|
feature_registry.register(name, &block)
|
157
157
|
end
|
158
158
|
|
159
|
+
# Public: Registers a participatory space, usually held in an external library
|
160
|
+
# or in a separate folder in the main repository. Exposes a DSL defined by
|
161
|
+
# `Decidim::ParticipatorySpaceManifest`.
|
162
|
+
#
|
163
|
+
# Participatory space manifests are held in a global registry and are used in
|
164
|
+
# all kinds of places to figure out what new components or functionalities the
|
165
|
+
# participatory space provides.
|
166
|
+
#
|
167
|
+
# name - A Symbol with the participatory space's unique name.
|
168
|
+
#
|
169
|
+
# Returns nothing.
|
170
|
+
def self.register_participatory_space(name, &block)
|
171
|
+
participatory_space_registry.register(name, &block)
|
172
|
+
end
|
173
|
+
|
159
174
|
# Public: Finds all registered feature manifest's via the `register_feature`
|
160
175
|
# method.
|
161
176
|
#
|
@@ -164,6 +179,14 @@ module Decidim
|
|
164
179
|
feature_registry.manifests
|
165
180
|
end
|
166
181
|
|
182
|
+
# Public: Finds all registered participatory space manifest's via the
|
183
|
+
# `register_participatory_space` method.
|
184
|
+
#
|
185
|
+
# Returns an Array[ParticipatorySpaceManifest].
|
186
|
+
def self.participatory_space_manifests
|
187
|
+
participatory_space_registry.manifests
|
188
|
+
end
|
189
|
+
|
167
190
|
# Public: Finds a feature manifest by the feature's name.
|
168
191
|
#
|
169
192
|
# name - The name of the FeatureManifest to find.
|
@@ -173,6 +196,16 @@ module Decidim
|
|
173
196
|
feature_registry.find(name.to_sym)
|
174
197
|
end
|
175
198
|
|
199
|
+
# Public: Finds a participatory space manifest by the participatory space's
|
200
|
+
# name.
|
201
|
+
#
|
202
|
+
# name - The name of the ParticipatorySpaceManifest to find.
|
203
|
+
#
|
204
|
+
# Returns a ParticipatorySpaceManifest if found, nil otherwise.
|
205
|
+
def self.find_participatory_space_manifest(name)
|
206
|
+
participatory_space_registry.find(name.to_sym)
|
207
|
+
end
|
208
|
+
|
176
209
|
# Public: Finds a resource manifest by the resource's name.
|
177
210
|
#
|
178
211
|
# resource_name_or_class - The String of the ResourceManifest name or the class of
|
@@ -188,6 +221,11 @@ module Decidim
|
|
188
221
|
@feature_registry ||= ManifestRegistry.new(:features)
|
189
222
|
end
|
190
223
|
|
224
|
+
# Public: Stores the registry of participatory spaces
|
225
|
+
def self.participatory_space_registry
|
226
|
+
@participatory_space_registry ||= ManifestRegistry.new(:participatory_spaces)
|
227
|
+
end
|
228
|
+
|
191
229
|
# Public: Stores an instance of StatsRegistry
|
192
230
|
def self.stats
|
193
231
|
@stats ||= StatsRegistry.new
|
data/lib/decidim/core/engine.rb
CHANGED
@@ -131,7 +131,7 @@ module Decidim
|
|
131
131
|
end
|
132
132
|
|
133
133
|
Decidim.stats.register :processes_count, priority: StatsRegistry::HIGH_PRIORITY do |organization, start_at, end_at|
|
134
|
-
processes = OrganizationPrioritizedParticipatoryProcesses.new(organization)
|
134
|
+
processes = ParticipatoryProcesses::OrganizationPrioritizedParticipatoryProcesses.new(organization)
|
135
135
|
processes = processes.where("created_at >= ?", start_at) if start_at.present?
|
136
136
|
processes = processes.where("created_at <= ?", end_at) if end_at.present?
|
137
137
|
processes.count
|
@@ -145,17 +145,31 @@ module Decidim
|
|
145
145
|
position: 1,
|
146
146
|
active: :exact
|
147
147
|
|
148
|
-
menu.item I18n.t("menu.processes", scope: "decidim"),
|
149
|
-
decidim.participatory_processes_path,
|
150
|
-
position: 2,
|
151
|
-
active: :inclusive
|
152
|
-
|
153
148
|
menu.item I18n.t("menu.more_information", scope: "decidim"),
|
154
149
|
decidim.pages_path,
|
155
150
|
position: 3,
|
156
151
|
active: :inclusive
|
157
152
|
end
|
158
153
|
end
|
154
|
+
|
155
|
+
initializer "decidim.notifications" do
|
156
|
+
Decidim::EventsManager.subscribe(/^decidim\.events\./) do |event_name, data|
|
157
|
+
EmailNotificationGeneratorJob.perform_later(
|
158
|
+
event_name,
|
159
|
+
data[:event_class],
|
160
|
+
data[:resource],
|
161
|
+
data[:recipient_ids],
|
162
|
+
data[:extra]
|
163
|
+
)
|
164
|
+
NotificationGeneratorJob.perform_later(
|
165
|
+
event_name,
|
166
|
+
data[:event_class],
|
167
|
+
data[:resource],
|
168
|
+
data[:recipient_ids],
|
169
|
+
data[:extra]
|
170
|
+
)
|
171
|
+
end
|
172
|
+
end
|
159
173
|
end
|
160
174
|
end
|
161
175
|
end
|