decidim-participatory_processes 0.20.0 → 0.23.1.rc1
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/participatory_processes/admin/participatory_processes.js.es6 +6 -0
- data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/_all_processes.erb +4 -1
- data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/show.erb +5 -9
- data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/single_process.erb +10 -5
- data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb +1 -1
- data/app/cells/decidim/participatory_processes/process_filters/show.erb +2 -2
- data/app/cells/decidim/participatory_processes/process_group_m/footer.erb +4 -5
- data/app/cells/decidim/participatory_processes/process_m/data.erb +1 -1
- data/app/cells/decidim/participatory_processes/process_m/footer.erb +5 -6
- data/app/cells/decidim/participatory_processes/process_m/tags.erb +2 -2
- data/app/cells/decidim/participatory_processes/process_m_cell.rb +21 -0
- data/app/cells/decidim/participatory_processes/statistic/show.erb +9 -0
- data/app/cells/decidim/participatory_processes/statistic_cell.rb +20 -0
- data/app/cells/decidim/participatory_processes/statistics/show.erb +17 -0
- data/app/cells/decidim/participatory_processes/statistics_cell.rb +18 -0
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +13 -3
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +2 -1
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +3 -3
- data/app/commands/decidim/participatory_processes/admin/notify_role_assigned_to_participatory_process.rb +22 -0
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +26 -10
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_admin.rb +3 -1
- data/app/controllers/concerns/decidim/participatory_processes/admin/filterable.rb +27 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_exports_controller.rb +4 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_user_roles_controller.rb +2 -1
- data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +6 -16
- data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +27 -4
- data/app/controllers/decidim/participatory_processes/{participatory_process_widgets_controller.rb → widgets_controller.rb} +2 -2
- data/app/events/decidim/participatory_process_role_assigned_event.rb +28 -0
- data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +18 -6
- data/app/forms/decidim/participatory_processes/admin/participatory_process_group_form.rb +4 -1
- data/app/forms/decidim/participatory_processes/admin/participatory_process_import_form.rb +3 -0
- data/app/forms/decidim/participatory_processes/admin/participatory_process_user_role_form.rb +8 -2
- data/app/functions/decidim/participatory_processes/participatory_process_finder.rb +10 -0
- data/app/functions/decidim/participatory_processes/participatory_process_list.rb +11 -0
- data/app/helpers/decidim/participatory_processes/admin/participatory_process_helper.rb +23 -0
- data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +11 -0
- data/app/models/decidim/participatory_process.rb +25 -2
- data/app/models/decidim/participatory_process_group.rb +5 -0
- data/app/models/decidim/participatory_process_step.rb +3 -0
- data/app/models/decidim/participatory_process_user_role.rb +32 -0
- data/app/permissions/decidim/participatory_processes/permissions.rb +9 -0
- data/app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb +2 -2
- data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +32 -22
- data/app/queries/decidim/participatory_processes/stats_followers_count.rb +46 -0
- data/app/queries/decidim/participatory_processes/stats_participants_count.rb +100 -0
- data/app/serializers/decidim/participatory_processes/participatory_process_importer.rb +8 -4
- data/app/serializers/decidim/participatory_processes/participatory_process_serializer.rb +1 -0
- data/app/types/decidim/participatory_processes/participatory_process_group_type.rb +20 -0
- data/app/types/decidim/participatory_processes/participatory_process_input_filter.rb +13 -0
- data/app/types/decidim/participatory_processes/participatory_process_input_sort.rb +15 -0
- data/app/types/decidim/participatory_processes/participatory_process_step_type.rb +7 -4
- data/app/types/decidim/participatory_processes/participatory_process_type.rb +8 -4
- data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +1 -1
- data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +31 -0
- data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +18 -15
- data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +3 -2
- data/app/views/decidim/participatory_processes/participatory_process_steps/index.html.erb +8 -3
- data/app/views/decidim/participatory_processes/participatory_processes/_metrics.html.erb +2 -2
- data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process.html.erb +13 -6
- data/app/views/decidim/participatory_processes/participatory_processes/_statistics.html.erb +0 -10
- data/app/views/decidim/participatory_processes/participatory_processes/{statistics.html.erb → all_metrics.html.erb} +0 -0
- data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +39 -13
- data/app/views/layouts/decidim/_process_header.html.erb +1 -1
- data/app/views/layouts/decidim/_process_header_steps.html.erb +1 -1
- data/app/views/layouts/decidim/_process_navigation.html.erb +1 -1
- data/app/views/layouts/decidim/admin/participatory_process.html.erb +2 -2
- data/app/views/layouts/decidim/participatory_process.html.erb +1 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +18 -5
- data/config/locales/bg-BG.yml +19 -0
- data/config/locales/bg.yml +19 -0
- data/config/locales/ca.yml +38 -7
- data/config/locales/cs.yml +44 -13
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +55 -4
- data/config/locales/el-GR.yml +1 -0
- data/config/locales/el.yml +453 -0
- data/config/locales/en.yml +37 -6
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +54 -4
- data/config/locales/es-PY.yml +54 -4
- data/config/locales/es.yml +55 -5
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +6 -4
- data/config/locales/fi-plain.yml +32 -4
- data/config/locales/fi.yml +105 -77
- data/config/locales/fr-CA.yml +456 -0
- data/config/locales/fr.yml +35 -4
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +6 -4
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +18 -8
- data/config/locales/id-ID.yml +6 -4
- data/config/locales/is-IS.yml +215 -0
- data/config/locales/is.yml +215 -0
- data/config/locales/it.yml +36 -8
- data/config/locales/ja-JP.yml +445 -0
- data/config/locales/ja.yml +445 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +445 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +44 -16
- data/config/locales/no.yml +347 -25
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +203 -152
- data/config/locales/pt-BR.yml +7 -5
- data/config/locales/pt.yml +175 -124
- data/config/locales/ro-RO.yml +461 -0
- data/config/locales/ru.yml +5 -3
- data/config/locales/sk-SK.yml +451 -0
- data/config/locales/sk.yml +451 -0
- data/config/locales/sl.yml +9 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +33 -0
- data/config/locales/sv.yml +155 -111
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +6 -4
- data/config/locales/uk.yml +5 -3
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +445 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20200114142253_add_scope_type_to_participatory_processes.rb +7 -0
- data/db/migrate/20200204154917_add_show_metrics_to_participatory_processes.rb +7 -0
- data/db/migrate/20200320105908_index_foreign_keys_in_decidim_attachments.rb +7 -0
- data/db/migrate/20200320105924_index_foreign_keys_in_decidim_participatory_process_user_roles.rb +7 -0
- data/db/migrate/20200320105925_index_foreign_keys_in_decidim_participatory_processes.rb +8 -0
- data/db/migrate/20201006072346_fix_attachments_titles.rb +38 -0
- data/db/seeds/city.jpeg +0 -0
- data/db/seeds/city2.jpeg +0 -0
- data/lib/decidim/participatory_processes/admin_engine.rb +1 -0
- data/lib/decidim/participatory_processes/engine.rb +22 -5
- data/lib/decidim/participatory_processes/participatory_space.rb +22 -12
- data/lib/decidim/participatory_processes/query_extensions.rb +40 -0
- data/lib/decidim/participatory_processes/test/factories.rb +23 -3
- data/lib/decidim/participatory_processes/version.rb +1 -1
- metadata +73 -14
- data/app/views/decidim/participatory_processes/participatory_process_widgets/show.html.erb +0 -17
data/app/commands/decidim/participatory_processes/admin/update_participatory_process_admin.rb
CHANGED
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when updated a participatory
|
7
7
|
# process admin in the system.
|
8
|
-
class UpdateParticipatoryProcessAdmin <
|
8
|
+
class UpdateParticipatoryProcessAdmin < NotifyRoleAssignedToParticipatoryProcess
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -47,6 +47,8 @@ module Decidim
|
|
47
47
|
{ role: form.role },
|
48
48
|
extra_info
|
49
49
|
)
|
50
|
+
|
51
|
+
send_notification user_role.user
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module ParticipatoryProcesses
|
7
|
+
module Admin
|
8
|
+
module Filterable
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include Decidim::Admin::Filterable
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def base_query
|
17
|
+
collection
|
18
|
+
end
|
19
|
+
|
20
|
+
def extra_filters
|
21
|
+
[:decidim_participatory_process_group_id_eq]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -25,12 +25,13 @@ module Decidim
|
|
25
25
|
CreateParticipatoryProcessAdmin.call(@form, current_user, current_participatory_process) do
|
26
26
|
on(:ok) do
|
27
27
|
flash[:notice] = I18n.t("participatory_process_user_roles.create.success", scope: "decidim.admin")
|
28
|
+
redirect_to participatory_process_user_roles_path(current_participatory_process)
|
28
29
|
end
|
29
30
|
|
30
31
|
on(:invalid) do
|
31
32
|
flash[:alert] = I18n.t("participatory_process_user_roles.create.error", scope: "decidim.admin")
|
33
|
+
render :new
|
32
34
|
end
|
33
|
-
redirect_to participatory_process_user_roles_path(current_participatory_process)
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb
CHANGED
@@ -7,18 +7,19 @@ module Decidim
|
|
7
7
|
#
|
8
8
|
class ParticipatoryProcessesController < Decidim::ParticipatoryProcesses::Admin::ApplicationController
|
9
9
|
include Decidim::Admin::ParticipatorySpaceAdminContext
|
10
|
+
include Decidim::ParticipatoryProcesses::Admin::Filterable
|
10
11
|
participatory_space_admin_layout only: [:edit]
|
11
|
-
include Decidim::Paginable
|
12
12
|
|
13
13
|
helper ProcessGroupsForSelectHelper
|
14
|
+
helper Decidim::ParticipatoryProcesses::Admin::ParticipatoryProcessHelper
|
14
15
|
|
15
|
-
helper_method :current_participatory_process, :current_participatory_space, :
|
16
|
+
helper_method :current_participatory_process, :current_participatory_space, :process_group
|
16
17
|
|
17
18
|
layout "decidim/admin/participatory_processes"
|
18
19
|
|
19
20
|
def index
|
20
21
|
enforce_permission_to :read, :process_list
|
21
|
-
@participatory_processes =
|
22
|
+
@participatory_processes = filtered_collection
|
22
23
|
end
|
23
24
|
|
24
25
|
def new
|
@@ -76,22 +77,11 @@ module Decidim
|
|
76
77
|
private
|
77
78
|
|
78
79
|
def process_group
|
79
|
-
@process_group ||= ParticipatoryProcessGroup.find_by(id:
|
80
|
-
end
|
81
|
-
|
82
|
-
def participatory_processes
|
83
|
-
@participatory_processes ||= Rectify::Query.merge(
|
84
|
-
ParticipatoryProcessesWithUserRole.for(current_user),
|
85
|
-
ParticipatoryProcessesByGroup.for(process_group)
|
86
|
-
)
|
87
|
-
end
|
88
|
-
|
89
|
-
def query
|
90
|
-
@query ||= participatory_processes.ransack(params[:q])
|
80
|
+
@process_group ||= ParticipatoryProcessGroup.find_by(id: ransack_params[:decidim_participatory_process_group_id_eq])
|
91
81
|
end
|
92
82
|
|
93
83
|
def collection
|
94
|
-
@collection ||=
|
84
|
+
@collection ||= ParticipatoryProcessesWithUserRole.for(current_user)
|
95
85
|
end
|
96
86
|
|
97
87
|
def current_participatory_process
|
@@ -6,10 +6,17 @@ module Decidim
|
|
6
6
|
# public layout.
|
7
7
|
class ParticipatoryProcessesController < Decidim::ParticipatoryProcesses::ApplicationController
|
8
8
|
include ParticipatorySpaceContext
|
9
|
-
participatory_space_layout only: [:show, :
|
9
|
+
participatory_space_layout only: [:show, :all_metrics]
|
10
10
|
include FilterResource
|
11
11
|
|
12
|
-
helper_method :collection,
|
12
|
+
helper_method :collection,
|
13
|
+
:promoted_participatory_processes,
|
14
|
+
:participatory_processes,
|
15
|
+
:stats,
|
16
|
+
:metrics,
|
17
|
+
:default_date_filter,
|
18
|
+
:related_processes,
|
19
|
+
:linked_assemblies
|
13
20
|
|
14
21
|
def index
|
15
22
|
raise ActionController::RoutingError, "Not Found" if published_processes.none?
|
@@ -22,8 +29,12 @@ module Decidim
|
|
22
29
|
enforce_permission_to :read, :process, process: current_participatory_space
|
23
30
|
end
|
24
31
|
|
25
|
-
def
|
26
|
-
|
32
|
+
def all_metrics
|
33
|
+
if current_participatory_space.show_statistics
|
34
|
+
enforce_permission_to :read, :process, process: current_participatory_space
|
35
|
+
else
|
36
|
+
render status: :not_found
|
37
|
+
end
|
27
38
|
end
|
28
39
|
|
29
40
|
private
|
@@ -92,6 +103,18 @@ module Decidim
|
|
92
103
|
|
93
104
|
"all"
|
94
105
|
end
|
106
|
+
|
107
|
+
def related_processes
|
108
|
+
@related_processes ||=
|
109
|
+
current_participatory_space
|
110
|
+
.linked_participatory_space_resources(:participatory_processes, "related_processes")
|
111
|
+
.published
|
112
|
+
.all
|
113
|
+
end
|
114
|
+
|
115
|
+
def linked_assemblies
|
116
|
+
@linked_assemblies ||= current_participatory_space.linked_participatory_space_resources(:assembly, "included_participatory_processes").public_spaces
|
117
|
+
end
|
95
118
|
end
|
96
119
|
end
|
97
120
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module ParticipatoryProcesses
|
5
|
-
class
|
5
|
+
class WidgetsController < Decidim::WidgetsController
|
6
6
|
helper Decidim::SanitizeHelper
|
7
7
|
|
8
8
|
private
|
@@ -20,7 +20,7 @@ module Decidim
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def iframe_url
|
23
|
-
@iframe_url ||=
|
23
|
+
@iframe_url ||= participatory_process_widget_url(model)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ParticipatoryProcessRoleAssignedEvent < Decidim::Events::SimpleEvent
|
5
|
+
include Decidim::Events::NotificationEvent
|
6
|
+
include Decidim::Events::AuthorEvent
|
7
|
+
|
8
|
+
def notification_title
|
9
|
+
I18n.t("notification_title", i18n_options).html_safe
|
10
|
+
end
|
11
|
+
|
12
|
+
def i18n_role
|
13
|
+
I18n.t(extra["role"], "decidim.admin.models.participatory_process_user_role.roles", default: extra["role"])
|
14
|
+
end
|
15
|
+
|
16
|
+
def i18n_options
|
17
|
+
{
|
18
|
+
resource_path: resource_path,
|
19
|
+
resource_title: resource_title,
|
20
|
+
resource_url: resource_url,
|
21
|
+
scope: event_name,
|
22
|
+
participatory_space_title: participatory_space_title,
|
23
|
+
participatory_space_url: participatory_space_url,
|
24
|
+
role: i18n_role
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -8,6 +8,7 @@ module Decidim
|
|
8
8
|
#
|
9
9
|
class ParticipatoryProcessForm < Form
|
10
10
|
include TranslatableAttributes
|
11
|
+
include Decidim::HasUploadValidations
|
11
12
|
|
12
13
|
mimic :participatory_process
|
13
14
|
|
@@ -29,10 +30,13 @@ module Decidim
|
|
29
30
|
attribute :area_id, Integer
|
30
31
|
attribute :participatory_process_group_id, Integer
|
31
32
|
attribute :scope_id, Integer
|
33
|
+
attribute :related_process_ids, Array[Integer]
|
34
|
+
attribute :scope_type_max_depth_id, Integer
|
32
35
|
|
33
36
|
attribute :private_space, Boolean
|
34
37
|
attribute :promoted, Boolean
|
35
38
|
attribute :scopes_enabled, Boolean
|
39
|
+
attribute :show_metrics, Boolean
|
36
40
|
attribute :show_statistics, Boolean
|
37
41
|
|
38
42
|
attribute :end_date, Decidim::Attributes::LocalizedDate
|
@@ -51,22 +55,26 @@ module Decidim
|
|
51
55
|
|
52
56
|
validates :title, :subtitle, :description, :short_description, translatable_presence: true
|
53
57
|
|
54
|
-
validates :banner_image,
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
|
59
|
-
file_content_type: { allow: ["image/jpeg", "image/png"] }
|
58
|
+
validates :banner_image, passthru: { to: Decidim::ParticipatoryProcess }
|
59
|
+
validates :hero_image, passthru: { to: Decidim::ParticipatoryProcess }
|
60
|
+
|
61
|
+
alias organization current_organization
|
60
62
|
|
61
63
|
def map_model(model)
|
62
64
|
self.scope_id = model.decidim_scope_id
|
63
65
|
self.participatory_process_group_id = model.decidim_participatory_process_group_id
|
66
|
+
self.related_process_ids = model.linked_participatory_space_resources(:participatory_process, "related_processes").pluck(:id)
|
67
|
+
@processes = Decidim::ParticipatoryProcess.where(organization: model.organization).where.not(id: model.id)
|
64
68
|
end
|
65
69
|
|
66
70
|
def scope
|
67
71
|
@scope ||= current_organization.scopes.find_by(id: scope_id)
|
68
72
|
end
|
69
73
|
|
74
|
+
def scope_type_max_depth
|
75
|
+
@scope_type_max_depth ||= current_organization.scope_types.find_by(id: scope_type_max_depth_id)
|
76
|
+
end
|
77
|
+
|
70
78
|
def area
|
71
79
|
@area ||= current_organization.areas.find_by(id: area_id)
|
72
80
|
end
|
@@ -75,6 +83,10 @@ module Decidim
|
|
75
83
|
Decidim::ParticipatoryProcessGroup.find_by(id: participatory_process_group_id)
|
76
84
|
end
|
77
85
|
|
86
|
+
def processes
|
87
|
+
@processes ||= Decidim::ParticipatoryProcess.where(organization: current_organization)
|
88
|
+
end
|
89
|
+
|
78
90
|
private
|
79
91
|
|
80
92
|
def organization_participatory_processes
|
@@ -8,6 +8,7 @@ module Decidim
|
|
8
8
|
#
|
9
9
|
class ParticipatoryProcessGroupForm < Form
|
10
10
|
include TranslatableAttributes
|
11
|
+
include Decidim::HasUploadValidations
|
11
12
|
|
12
13
|
translatable_attribute :name, String
|
13
14
|
translatable_attribute :description, String
|
@@ -20,7 +21,9 @@ module Decidim
|
|
20
21
|
|
21
22
|
validates :name, :description, translatable_presence: true
|
22
23
|
|
23
|
-
validates :hero_image,
|
24
|
+
validates :hero_image, passthru: { to: Decidim::ParticipatoryProcessGroup }
|
25
|
+
|
26
|
+
alias organization current_organization
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -13,6 +13,9 @@ module Decidim
|
|
13
13
|
# Accepted mime types
|
14
14
|
# keys: are used for dynamic help text on admin form.
|
15
15
|
# values: are used to validate the file format of imported document.
|
16
|
+
#
|
17
|
+
# WARNING: consider adding/removing the relative translation key at
|
18
|
+
# decidim.participatory_processes.admin.new_import.accepted_types when modifying this hash
|
16
19
|
ACCEPTED_TYPES = {
|
17
20
|
json: JSON_MIME_TYPE
|
18
21
|
}.freeze
|
data/app/forms/decidim/participatory_processes/admin/participatory_process_user_role_form.rb
CHANGED
@@ -13,10 +13,12 @@ module Decidim
|
|
13
13
|
attribute :email, String
|
14
14
|
attribute :role, String
|
15
15
|
|
16
|
-
validates :email, :role, presence: true
|
17
|
-
validates :name, presence: true
|
16
|
+
validates :name, :email, :role, presence: true
|
18
17
|
validates :role, inclusion: { in: Decidim::ParticipatoryProcessUserRole::ROLES }
|
19
18
|
|
19
|
+
validates :name, format: { with: UserBaseEntity::REGEXP_NAME }
|
20
|
+
validate :admin_uniqueness
|
21
|
+
|
20
22
|
def roles
|
21
23
|
Decidim::ParticipatoryProcessUserRole::ROLES.map do |role|
|
22
24
|
[
|
@@ -25,6 +27,10 @@ module Decidim
|
|
25
27
|
]
|
26
28
|
end
|
27
29
|
end
|
30
|
+
|
31
|
+
def admin_uniqueness
|
32
|
+
errors.add(:email, :taken) if context && context.current_organization && context.current_organization.admins.where(email: email).exists?
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# Adds slug finder for participatory_processes
|
6
|
+
class ParticipatoryProcessFinder < Decidim::Core::ParticipatorySpaceFinder
|
7
|
+
argument :slug, types.String, "The slug of the participatory process"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# Adds some filter values for participatory_processes
|
6
|
+
class ParticipatoryProcessList < Decidim::Core::ParticipatorySpaceListBase
|
7
|
+
argument :filter, ParticipatoryProcessInputFilter, "This argument let's you filter the results"
|
8
|
+
argument :order, ParticipatoryProcessInputSort, "This argument let's you order the results"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# Helpers related to the Admin of Participatory Process layout.
|
7
|
+
module ParticipatoryProcessHelper
|
8
|
+
def scope_type_depth_select_options
|
9
|
+
{
|
10
|
+
include_blank: true,
|
11
|
+
selected: current_participatory_process.try(:decidim_scope_type_id)
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def scope_type_depth_select_html_options
|
16
|
+
html_options = {}
|
17
|
+
html_options[:disabled] = "disabled" unless current_participatory_process.try(:scopes_enabled)
|
18
|
+
html_options
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -21,6 +21,17 @@ module Decidim
|
|
21
21
|
dates = [participatory_process_step.start_date, participatory_process_step.end_date]
|
22
22
|
dates.map { |date| date ? localize(date.to_date, format: :default) : "?" }.join(" - ")
|
23
23
|
end
|
24
|
+
|
25
|
+
# Public: Returns the path for the participatory process cta button
|
26
|
+
#
|
27
|
+
# Returns a String with path.
|
28
|
+
def participatory_process_cta_path(process)
|
29
|
+
return participatory_process_path(process) if process.active_step&.cta_path.blank?
|
30
|
+
|
31
|
+
path, params = participatory_process_path(process).split("?")
|
32
|
+
|
33
|
+
"#{path}/#{process.active_step.cta_path}" + (params.present? ? "?#{params}" : "")
|
34
|
+
end
|
24
35
|
end
|
25
36
|
end
|
26
37
|
end
|
@@ -11,7 +11,7 @@ module Decidim
|
|
11
11
|
include Decidim::HasAttachmentCollections
|
12
12
|
include Decidim::Participable
|
13
13
|
include Decidim::Publicable
|
14
|
-
include Decidim::
|
14
|
+
include Decidim::ScopableParticipatorySpace
|
15
15
|
include Decidim::Followable
|
16
16
|
include Decidim::HasReference
|
17
17
|
include Decidim::Traceable
|
@@ -19,6 +19,11 @@ module Decidim
|
|
19
19
|
include Decidim::Loggable
|
20
20
|
include Decidim::ParticipatorySpaceResourceable
|
21
21
|
include Decidim::Searchable
|
22
|
+
include Decidim::HasUploadValidations
|
23
|
+
include Decidim::TranslatableResource
|
24
|
+
|
25
|
+
translatable_fields :title, :subtitle, :short_description, :description, :developer_group, :meta_scope, :local_area,
|
26
|
+
:target, :participatory_scope, :participatory_structure, :announcement
|
22
27
|
|
23
28
|
belongs_to :organization,
|
24
29
|
foreign_key: "decidim_organization_id",
|
@@ -49,6 +54,10 @@ module Decidim
|
|
49
54
|
foreign_type: "decidim_participatory_space_type",
|
50
55
|
dependent: :destroy,
|
51
56
|
as: :participatory_space
|
57
|
+
belongs_to :scope_type_max_depth,
|
58
|
+
foreign_key: "decidim_scope_type_id",
|
59
|
+
class_name: "Decidim::ScopeType",
|
60
|
+
optional: true
|
52
61
|
|
53
62
|
has_many :components, as: :participatory_space, dependent: :destroy
|
54
63
|
|
@@ -57,7 +66,10 @@ module Decidim
|
|
57
66
|
validates :slug, uniqueness: { scope: :organization }
|
58
67
|
validates :slug, presence: true, format: { with: Decidim::ParticipatoryProcess.slug_format }
|
59
68
|
|
69
|
+
validates_upload :hero_image
|
60
70
|
mount_uploader :hero_image, Decidim::HeroImageUploader
|
71
|
+
|
72
|
+
validates_upload :banner_image
|
61
73
|
mount_uploader :banner_image, Decidim::BannerImageUploader
|
62
74
|
|
63
75
|
scope :past, -> { where(arel_table[:end_date].lt(Date.current)) }
|
@@ -149,9 +161,20 @@ module Decidim
|
|
149
161
|
"#{admin_module_name}::Moderators".constantize.for(self)
|
150
162
|
end
|
151
163
|
|
164
|
+
def user_roles(role_name = nil)
|
165
|
+
roles = Decidim::ParticipatoryProcessUserRole.where(participatory_process: self)
|
166
|
+
return roles if role_name.blank?
|
167
|
+
|
168
|
+
roles.where(role: role_name)
|
169
|
+
end
|
170
|
+
|
171
|
+
def attachment_context
|
172
|
+
:admin
|
173
|
+
end
|
174
|
+
|
152
175
|
# Allow ransacker to search for a key in a hstore column (`title`.`en`)
|
153
176
|
ransacker :title do |parent|
|
154
|
-
Arel::Nodes::InfixOperation.new("
|
177
|
+
Arel::Nodes::InfixOperation.new("->>", parent.table[:title], Arel::Nodes.build_quoted(I18n.locale.to_s))
|
155
178
|
end
|
156
179
|
end
|
157
180
|
end
|