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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a774be89f3656a65dcf358c853dce78b47bf583c
|
4
|
+
data.tar.gz: 2e9e91cc41497ccdad3c58f4786921d053888a0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4def8591405abaa854afb048f841c35ced6f6fea5e35e8c77f5c9de0ecae2c1bd4fbc5c599e5cc07f5d0747b8686247955c98b21be47f422239642d0f08ad2f6
|
7
|
+
data.tar.gz: 1ba2f7fef1c8d850f0732765e7199dff180d6ea78bd62c6edb4a392c3f01f5d82ecd9e4633205ec9bee2afd5661e5484b47b43b00e5917f034d1bdd48c704b60
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$(() => {
|
2
|
+
const $wrapper = $('#notifications');
|
3
|
+
const $section = $wrapper.find('section#notifications-list');
|
4
|
+
const $noNotificationsText = $wrapper.find('.empty-notifications');
|
5
|
+
const $pagination = $wrapper.find('ul.pagination');
|
6
|
+
const FADEOUT_TIME = 500;
|
7
|
+
|
8
|
+
const anyNotifications = () => $wrapper.find('.card--list__item').length > 0;
|
9
|
+
const emptyNotifications = () => {
|
10
|
+
if (!anyNotifications()) {
|
11
|
+
$section.remove();
|
12
|
+
$noNotificationsText.removeClass('hide');
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
$section.on('click', '.mark-as-read-button', (event) => {
|
17
|
+
const $item = $(event.target).parents('.card--list__item');
|
18
|
+
$item.fadeOut(FADEOUT_TIME, () => {
|
19
|
+
$item.remove();
|
20
|
+
emptyNotifications();
|
21
|
+
});
|
22
|
+
});
|
23
|
+
|
24
|
+
$wrapper.on('click', '.mark-all-as-read-button', () => {
|
25
|
+
$section.fadeOut(FADEOUT_TIME, () => {
|
26
|
+
$pagination.remove();
|
27
|
+
$wrapper.find('.card--list__item').remove();
|
28
|
+
emptyNotifications();
|
29
|
+
});
|
30
|
+
});
|
31
|
+
|
32
|
+
emptyNotifications();
|
33
|
+
});
|
@@ -83,6 +83,16 @@
|
|
83
83
|
width: 25px;
|
84
84
|
height: 25px;
|
85
85
|
fill: $muted;
|
86
|
+
|
87
|
+
.stroked-shape{
|
88
|
+
fill: none;
|
89
|
+
fill-opacity: 1;
|
90
|
+
stroke-width: 2.01957917;
|
91
|
+
stroke-miterlimit: 4;
|
92
|
+
stroke-dasharray: none;
|
93
|
+
stroke-dashoffset: 0;
|
94
|
+
stroke: $muted;
|
95
|
+
}
|
86
96
|
}
|
87
97
|
}
|
88
98
|
|
@@ -92,6 +102,10 @@
|
|
92
102
|
color: $primary;
|
93
103
|
svg{
|
94
104
|
fill: $primary;
|
105
|
+
|
106
|
+
.stroked-shape{
|
107
|
+
stroke: $primary;
|
108
|
+
}
|
95
109
|
}
|
96
110
|
}
|
97
111
|
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A command with all the business logic for when a user starts following a resource.
|
5
|
+
class CreateFollow < Rectify::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# form - A form object with the params.
|
9
|
+
# current_user - The current user.
|
10
|
+
def initialize(form, current_user)
|
11
|
+
@form = form
|
12
|
+
@current_user = current_user
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid, together with the follow.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
create_follow!
|
25
|
+
|
26
|
+
broadcast(:ok, follow)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :follow, :form, :current_user
|
32
|
+
|
33
|
+
def create_follow!
|
34
|
+
@follow = Follow.create!(
|
35
|
+
followable: form.followable,
|
36
|
+
user: current_user
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -53,8 +53,6 @@ module Decidim
|
|
53
53
|
@user.password = generated_password
|
54
54
|
@user.password_confirmation = generated_password
|
55
55
|
@user.skip_confirmation! if verified_email
|
56
|
-
@user.comments_notifications = true
|
57
|
-
@user.replies_notifications = true
|
58
56
|
end
|
59
57
|
|
60
58
|
@user.tos_agreement = "1"
|
@@ -39,9 +39,7 @@ module Decidim
|
|
39
39
|
password_confirmation: form.password_confirmation,
|
40
40
|
organization: form.current_organization,
|
41
41
|
tos_agreement: form.tos_agreement,
|
42
|
-
newsletter_notifications: form.newsletter_notifications
|
43
|
-
comments_notifications: true,
|
44
|
-
replies_notifications: true)
|
42
|
+
newsletter_notifications: form.newsletter_notifications)
|
45
43
|
end
|
46
44
|
|
47
45
|
def create_user_group
|
@@ -44,7 +44,7 @@ module Decidim
|
|
44
44
|
attr_reader :form, :report
|
45
45
|
|
46
46
|
def find_or_create_moderation!
|
47
|
-
@moderation = Moderation.find_or_create_by!(reportable: @reportable,
|
47
|
+
@moderation = Moderation.find_or_create_by!(reportable: @reportable, participatory_space: participatory_space)
|
48
48
|
end
|
49
49
|
|
50
50
|
def create_report!
|
@@ -60,12 +60,12 @@ module Decidim
|
|
60
60
|
@moderation.update_attributes!(report_count: @moderation.report_count + 1)
|
61
61
|
end
|
62
62
|
|
63
|
-
def
|
64
|
-
@
|
63
|
+
def participatory_space_admins
|
64
|
+
@participatory_space_admins ||= participatory_space.admins
|
65
65
|
end
|
66
66
|
|
67
67
|
def send_report_notification_to_admins
|
68
|
-
|
68
|
+
participatory_space_admins.each do |admin|
|
69
69
|
ReportedMailer.report(admin, @report).deliver_later
|
70
70
|
end
|
71
71
|
end
|
@@ -79,13 +79,13 @@ module Decidim
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def send_hide_notification_to_admins
|
82
|
-
|
82
|
+
participatory_space_admins.each do |admin|
|
83
83
|
ReportedMailer.hide(admin, @report).deliver_later
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
88
|
-
@
|
87
|
+
def participatory_space
|
88
|
+
@participatory_space ||= @reportable.feature.participatory_space
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A command with all the business logic for when a user stops following a resource.
|
5
|
+
class DeleteFollow < Rectify::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# form - A form object with the params.
|
9
|
+
# current_user - The current user.
|
10
|
+
def initialize(form, current_user)
|
11
|
+
@form = form
|
12
|
+
@current_user = current_user
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid, together with the follow.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
delete_follow!
|
25
|
+
|
26
|
+
broadcast(:ok)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :form, :current_user
|
32
|
+
|
33
|
+
def delete_follow!
|
34
|
+
form.follow.destroy!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -43,9 +43,7 @@ module Decidim
|
|
43
43
|
email: form.email.downcase,
|
44
44
|
organization: form.organization,
|
45
45
|
admin: form.role == "admin",
|
46
|
-
roles: form.role == "admin" ? [] : [form.role]
|
47
|
-
comments_notifications: true,
|
48
|
-
replies_notifications: true
|
46
|
+
roles: form.role == "admin" ? [] : [form.role]
|
49
47
|
)
|
50
48
|
@user.invite!(
|
51
49
|
form.invited_by,
|
@@ -24,8 +24,7 @@ module Decidim
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def update_notifications_settings
|
27
|
-
@user.
|
28
|
-
@user.replies_notifications = @form.replies_notifications
|
27
|
+
@user.email_on_notification = @form.email_on_notification
|
29
28
|
@user.newsletter_notifications = @form.newsletter_notifications
|
30
29
|
end
|
31
30
|
end
|
@@ -20,9 +20,8 @@ module Decidim
|
|
20
20
|
def matches?(request)
|
21
21
|
env = request.env
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
@participatory_process = env["decidim.current_participatory_process"]
|
23
|
+
@participatory_space = env["decidim.current_participatory_space"]
|
24
|
+
return false unless @participatory_space
|
26
25
|
|
27
26
|
current_feature(env, request.params) ? true : false
|
28
27
|
end
|
@@ -34,7 +33,7 @@ module Decidim
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def detect_current_feature(params)
|
37
|
-
@
|
36
|
+
@participatory_space.features.find do |feature|
|
38
37
|
params["feature_id"] == feature.id.to_s && feature.manifest_name == @manifest.name.to_s
|
39
38
|
end
|
40
39
|
end
|
@@ -6,8 +6,6 @@ module Decidim
|
|
6
6
|
# setting the appropiate layout, including necessary helpers, and overall
|
7
7
|
# fooling the engine into thinking it's isolated.
|
8
8
|
class BaseController < Decidim::ApplicationController
|
9
|
-
layout "layouts/decidim/participatory_process"
|
10
|
-
include NeedsParticipatoryProcess
|
11
9
|
include Settings
|
12
10
|
include ActionAuthorization
|
13
11
|
|
@@ -15,7 +13,6 @@ module Decidim
|
|
15
13
|
helper Decidim::OrdersHelper
|
16
14
|
helper Decidim::FeatureReferenceHelper
|
17
15
|
helper Decidim::TranslationsHelper
|
18
|
-
helper Decidim::ParticipatoryProcessHelper
|
19
16
|
helper Decidim::IconHelper
|
20
17
|
helper Decidim::ResourceHelper
|
21
18
|
helper Decidim::ScopesHelper
|
@@ -23,12 +20,14 @@ module Decidim
|
|
23
20
|
helper Decidim::AttachmentsHelper
|
24
21
|
|
25
22
|
helper_method :current_feature,
|
23
|
+
:current_participatory_space,
|
26
24
|
:current_manifest
|
27
25
|
|
28
26
|
skip_authorize_resource
|
29
27
|
|
30
28
|
before_action do
|
31
|
-
|
29
|
+
extend current_participatory_space.extension_module
|
30
|
+
|
32
31
|
authorize! :read, current_feature
|
33
32
|
end
|
34
33
|
|
@@ -40,8 +39,8 @@ module Decidim
|
|
40
39
|
@current_manifest ||= current_feature.manifest
|
41
40
|
end
|
42
41
|
|
43
|
-
def
|
44
|
-
|
42
|
+
def current_participatory_space
|
43
|
+
current_feature.participatory_space
|
45
44
|
end
|
46
45
|
|
47
46
|
def ability_context
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class FollowsController < Decidim::ApplicationController
|
5
|
+
include FormFactory
|
6
|
+
before_action :authenticate_user!
|
7
|
+
helper_method :resource
|
8
|
+
|
9
|
+
def destroy
|
10
|
+
@form = form(Decidim::FollowForm).from_params(params)
|
11
|
+
authorize! :delete, @form.follow
|
12
|
+
|
13
|
+
DeleteFollow.call(@form, current_user) do
|
14
|
+
on(:ok) do
|
15
|
+
render :update_button
|
16
|
+
end
|
17
|
+
|
18
|
+
on(:invalid) do
|
19
|
+
render json: { error: I18n.t("follows.destroy.error", scope: "decidim") }, status: 422
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create
|
25
|
+
@form = form(Decidim::FollowForm).from_params(params)
|
26
|
+
authorize! :create, Follow
|
27
|
+
|
28
|
+
CreateFollow.call(@form, current_user) do
|
29
|
+
on(:ok) do
|
30
|
+
render :update_button
|
31
|
+
end
|
32
|
+
|
33
|
+
on(:invalid) do
|
34
|
+
render json: { error: I18n.t("follows.create.error", scope: "decidim") }, status: 422
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def resource
|
40
|
+
@resource ||= GlobalID::Locator.locate_signed(
|
41
|
+
params[:follow][:followable_gid]
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# The controller to handle the user's notifications dashboard.
|
5
|
+
class NotificationsController < Decidim::ApplicationController
|
6
|
+
helper Decidim::IconHelper
|
7
|
+
helper Decidim::PaginateHelper
|
8
|
+
include Paginable
|
9
|
+
|
10
|
+
helper_method :notifications
|
11
|
+
|
12
|
+
def index
|
13
|
+
authorize! :read, Notification
|
14
|
+
@notifications = paginate(notifications)
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy
|
18
|
+
notification = notifications.find(params[:id])
|
19
|
+
authorize! :destroy, notification
|
20
|
+
notification.destroy
|
21
|
+
end
|
22
|
+
|
23
|
+
def read_all
|
24
|
+
authorize! :destroy, notifications.first
|
25
|
+
notifications.destroy_all
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def notifications
|
31
|
+
@notifications ||= current_user.notifications.order(created_at: :desc)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Private: overwrites the amount of elements per page.
|
35
|
+
def per_page
|
36
|
+
50
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -25,12 +25,12 @@ module Decidim
|
|
25
25
|
|
26
26
|
def promoted_participatory_processes
|
27
27
|
@promoted_participatory_processes ||=
|
28
|
-
OrganizationPrioritizedParticipatoryProcesses.new(current_organization) | PromotedParticipatoryProcesses.new
|
28
|
+
ParticipatoryProcesses::OrganizationPrioritizedParticipatoryProcesses.new(current_organization) | ParticipatoryProcesses::PromotedParticipatoryProcesses.new
|
29
29
|
end
|
30
30
|
|
31
31
|
def highlighted_participatory_processes
|
32
32
|
@highlighted_participatory_processes ||=
|
33
|
-
OrganizationPublishedParticipatoryProcesses.new(current_organization) | HighlightedParticipatoryProcesses.new
|
33
|
+
ParticipatoryProcesses::OrganizationPublishedParticipatoryProcesses.new(current_organization) | ParticipatoryProcesses::HighlightedParticipatoryProcesses.new
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|