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
@@ -4,6 +4,10 @@ module Decidim
|
|
4
4
|
class ParticipatoryProcessGroup < ApplicationRecord
|
5
5
|
include Decidim::Resourceable
|
6
6
|
include Decidim::Traceable
|
7
|
+
include Decidim::HasUploadValidations
|
8
|
+
include Decidim::TranslatableResource
|
9
|
+
|
10
|
+
translatable_fields :name, :description
|
7
11
|
|
8
12
|
has_many :participatory_processes,
|
9
13
|
foreign_key: "decidim_participatory_process_group_id",
|
@@ -15,6 +19,7 @@ module Decidim
|
|
15
19
|
foreign_key: "decidim_organization_id",
|
16
20
|
class_name: "Decidim::Organization"
|
17
21
|
|
22
|
+
validates_upload :hero_image
|
18
23
|
mount_uploader :hero_image, Decidim::HeroImageUploader
|
19
24
|
|
20
25
|
def self.log_presenter_class_for(_log)
|
@@ -5,9 +5,12 @@ module Decidim
|
|
5
5
|
# components that will show up in the depending on what step is currently
|
6
6
|
# active.
|
7
7
|
class ParticipatoryProcessStep < ApplicationRecord
|
8
|
+
include Decidim::TranslatableResource
|
8
9
|
include Traceable
|
9
10
|
include Loggable
|
10
11
|
|
12
|
+
translatable_fields :title, :description, :cta_text
|
13
|
+
|
11
14
|
belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: "Decidim::ParticipatoryProcess"
|
12
15
|
has_one :organization, through: :participatory_process
|
13
16
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Defines a relation between a user and a participatory process, and what
|
5
|
+
# kind of relation does the user has.
|
6
|
+
class ParticipatoryProcessUserRole < ApplicationRecord
|
7
|
+
include Traceable
|
8
|
+
include Loggable
|
9
|
+
|
10
|
+
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User", optional: true
|
11
|
+
belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: "Decidim::ParticipatoryProcess", optional: true
|
12
|
+
|
13
|
+
alias participatory_space participatory_process
|
14
|
+
|
15
|
+
ROLES = %w(admin collaborator moderator valuator).freeze
|
16
|
+
validates :role, inclusion: { in: ROLES }, uniqueness: { scope: [:user, :participatory_process] }
|
17
|
+
validate :user_and_participatory_process_same_organization
|
18
|
+
|
19
|
+
def self.log_presenter_class_for(_log)
|
20
|
+
Decidim::ParticipatoryProcesses::AdminLog::ParticipatoryProcessUserRolePresenter
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Private: check if the process and the user have the same organization
|
26
|
+
def user_and_participatory_process_same_organization
|
27
|
+
return if !participatory_process || !user
|
28
|
+
|
29
|
+
errors.add(:participatory_process, :invalid) unless user.organization == participatory_process.organization
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -44,6 +44,7 @@ module Decidim
|
|
44
44
|
|
45
45
|
moderator_action?
|
46
46
|
collaborator_action?
|
47
|
+
valuator_action?
|
47
48
|
process_admin_action?
|
48
49
|
|
49
50
|
permission_action
|
@@ -205,6 +206,14 @@ module Decidim
|
|
205
206
|
allow! if permission_action.action == :preview
|
206
207
|
end
|
207
208
|
|
209
|
+
# Valuators can only read the components of a process.
|
210
|
+
def valuator_action?
|
211
|
+
return unless can_manage_process?(role: :valuator)
|
212
|
+
|
213
|
+
allow! if permission_action.action == :read && permission_action.subject == :component
|
214
|
+
allow! if permission_action.action == :export && permission_action.subject == :component_data
|
215
|
+
end
|
216
|
+
|
208
217
|
# Process admins can eprform everything *inside* that process. They cannot
|
209
218
|
# create a process or perform actions on process groups or other
|
210
219
|
# processes.
|
data/app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb
CHANGED
@@ -8,8 +8,8 @@ module Decidim
|
|
8
8
|
|
9
9
|
def params
|
10
10
|
capture do
|
11
|
-
concat(
|
12
|
-
concat(
|
11
|
+
concat(hidden_field_tag(:metrics_space_type, value: participatory_process.class, id: :"metrics-space_type"))
|
12
|
+
concat(hidden_field_tag(:metrics_space_id, value: participatory_process.id, id: :"metrics-space_id"))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb
CHANGED
@@ -7,41 +7,51 @@ module Decidim
|
|
7
7
|
attribute :participatory_process, Decidim::ParticipatoryProcess
|
8
8
|
include Decidim::IconHelper
|
9
9
|
|
10
|
-
# Public:
|
11
|
-
def
|
12
|
-
highlighted_stats =
|
10
|
+
# Public: returns a collection of stats (Hash) for the Process Home.
|
11
|
+
def collection
|
12
|
+
highlighted_stats = process_participants_stats
|
13
|
+
highlighted_stats = highlighted_stats.concat(process_followers_stats(priority: StatsRegistry::HIGH_PRIORITY))
|
14
|
+
highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY))
|
13
15
|
highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
|
14
16
|
highlighted_stats = highlighted_stats.reject(&:empty?)
|
15
|
-
highlighted_stats = highlighted_stats.reject { |
|
16
|
-
grouped_highlighted_stats = highlighted_stats.group_by
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
highlighted_stats = highlighted_stats.reject { |_stat_manifest, _stat_title, stat_number| stat_number.zero? }
|
18
|
+
grouped_highlighted_stats = highlighted_stats.group_by(&:first)
|
19
|
+
|
20
|
+
statistics = []
|
21
|
+
grouped_highlighted_stats.each do |_manifest_name, stats|
|
22
|
+
stats.each_with_index.each do |stat, _index|
|
23
|
+
stat.each_with_index.map do |_item, subindex|
|
24
|
+
next unless (subindex % 3).zero?
|
25
|
+
next if stat[subindex + 2].zero?
|
26
|
+
|
27
|
+
statistics << { stat_title: stat[subindex + 1], stat_number: stat[subindex + 2] }
|
26
28
|
end
|
27
29
|
end
|
28
|
-
|
30
|
+
end
|
31
|
+
statistics
|
29
32
|
end
|
30
33
|
|
31
34
|
private
|
32
35
|
|
36
|
+
def process_participants_stats
|
37
|
+
Decidim.stats.only([:participants_count]).with_context(participatory_process)
|
38
|
+
.map { |stat_title, stat_number| [participatory_process.manifest.name, stat_title, stat_number] }
|
39
|
+
end
|
40
|
+
|
33
41
|
def component_stats(conditions)
|
34
42
|
Decidim.component_manifests.map do |component_manifest|
|
35
|
-
component_manifest.stats.
|
43
|
+
component_manifest.stats.except([:proposals_accepted])
|
44
|
+
.filter(conditions)
|
45
|
+
.with_context(published_components)
|
46
|
+
.map { |stat_title, stat_number| [component_manifest.name, stat_title, stat_number] }.flatten
|
36
47
|
end
|
37
48
|
end
|
38
49
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
])
|
50
|
+
def process_followers_stats(conditions)
|
51
|
+
Decidim.stats.only([:followers_count])
|
52
|
+
.filter(conditions)
|
53
|
+
.with_context(participatory_process)
|
54
|
+
.map { |stat_title, stat_number| [participatory_process.manifest.name, stat_title, stat_number] }
|
45
55
|
end
|
46
56
|
|
47
57
|
def published_components
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This class counts all Followers of a participatory processes
|
6
|
+
class StatsFollowersCount < Rectify::Query
|
7
|
+
def self.for(participatory_space)
|
8
|
+
return 0 unless participatory_space.is_a? Decidim::ParticipatoryProcess
|
9
|
+
|
10
|
+
new(participatory_space).query
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(participatory_space)
|
14
|
+
@participatory_space = participatory_space
|
15
|
+
end
|
16
|
+
|
17
|
+
def query
|
18
|
+
space_query + components_query
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :participatory_space
|
24
|
+
|
25
|
+
def components_query
|
26
|
+
Decidim.component_manifests.sum do |component|
|
27
|
+
component.stats
|
28
|
+
.filter(tag: :followers)
|
29
|
+
.with_context(participatory_space.components.published)
|
30
|
+
.map { |_name, value| value }
|
31
|
+
.sum
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def space_query
|
36
|
+
Decidim.participatory_space_manifests.sum do |space|
|
37
|
+
space.stats
|
38
|
+
.filter(tag: :followers)
|
39
|
+
.with_context(participatory_space)
|
40
|
+
.map { |_name, value| value }
|
41
|
+
.sum
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This class counts unique Participants on a participatory processes
|
6
|
+
class StatsParticipantsCount < Rectify::Query
|
7
|
+
def self.for(participatory_space)
|
8
|
+
return 0 unless participatory_space.is_a? Decidim::ParticipatoryProcess
|
9
|
+
|
10
|
+
new(participatory_space).query
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(participatory_space)
|
14
|
+
@participatory_space = participatory_space
|
15
|
+
end
|
16
|
+
|
17
|
+
def query
|
18
|
+
[
|
19
|
+
comments_query,
|
20
|
+
debates_query,
|
21
|
+
endorsements_query,
|
22
|
+
project_supports_query,
|
23
|
+
proposals_query,
|
24
|
+
proposal_supports_query,
|
25
|
+
survey_answer_query
|
26
|
+
].flatten.uniq.count
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :participatory_space
|
32
|
+
|
33
|
+
def comments_query
|
34
|
+
Decidim::Comments::Comment
|
35
|
+
.where(decidim_root_commentable_id: participatory_space.id)
|
36
|
+
.pluck(:decidim_author_id)
|
37
|
+
.uniq
|
38
|
+
end
|
39
|
+
|
40
|
+
def debates_query
|
41
|
+
Decidim::Debates::Debate
|
42
|
+
.where(
|
43
|
+
component: space_components,
|
44
|
+
decidim_author_type: Decidim::UserBaseEntity.name
|
45
|
+
)
|
46
|
+
.not_hidden
|
47
|
+
.pluck(:decidim_author_id)
|
48
|
+
.uniq
|
49
|
+
end
|
50
|
+
|
51
|
+
def endorsements_query
|
52
|
+
Decidim::Endorsement
|
53
|
+
.where(resource: space_components)
|
54
|
+
.pluck(:decidim_author_id)
|
55
|
+
.uniq
|
56
|
+
end
|
57
|
+
|
58
|
+
def proposals_query
|
59
|
+
Decidim::Coauthorship
|
60
|
+
.where(
|
61
|
+
coauthorable: proposals_components,
|
62
|
+
decidim_author_type: Decidim::UserBaseEntity.name
|
63
|
+
)
|
64
|
+
.pluck(:decidim_author_id)
|
65
|
+
.uniq
|
66
|
+
end
|
67
|
+
|
68
|
+
def proposal_supports_query
|
69
|
+
Decidim::Proposals::ProposalVote
|
70
|
+
.where(
|
71
|
+
proposal: proposals_components
|
72
|
+
)
|
73
|
+
.final
|
74
|
+
.pluck(:decidim_author_id)
|
75
|
+
.uniq
|
76
|
+
end
|
77
|
+
|
78
|
+
def project_supports_query
|
79
|
+
Decidim::Budgets::Order.joins(budget: [:component])
|
80
|
+
.where(budget: {
|
81
|
+
decidim_components: { id: space_components.pluck(:id) }
|
82
|
+
})
|
83
|
+
.pluck(:decidim_user_id)
|
84
|
+
.uniq
|
85
|
+
end
|
86
|
+
|
87
|
+
def survey_answer_query
|
88
|
+
Decidim::Forms::Answer.newsletter_participant_ids(space_components)
|
89
|
+
end
|
90
|
+
|
91
|
+
def space_components
|
92
|
+
@space_components ||= participatory_space.components
|
93
|
+
end
|
94
|
+
|
95
|
+
def proposals_components
|
96
|
+
@proposals_components ||= Decidim::Proposals::FilteredProposals.for(space_components).published.not_hidden
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -39,7 +39,9 @@ module Decidim
|
|
39
39
|
meta_scope: attributes["meta_scope"],
|
40
40
|
start_date: attributes["start_date"],
|
41
41
|
end_date: attributes["end_date"],
|
42
|
+
announcement: attributes["announcement"],
|
42
43
|
private_space: attributes["private_space"],
|
44
|
+
scopes_enabled: attributes["scopes_enabled"],
|
43
45
|
participatory_process_group: import_process_group(attributes["participatory_process_group"])
|
44
46
|
)
|
45
47
|
@imported_process.remote_hero_image_url = attributes["remote_hero_image_url"] if remote_file_exists?(attributes["remote_hero_image_url"])
|
@@ -120,11 +122,11 @@ module Decidim
|
|
120
122
|
attachment = Attachment.new(
|
121
123
|
title: file["title"],
|
122
124
|
description: file["description"],
|
123
|
-
file: file_tmp,
|
124
|
-
file_size: file_tmp.size,
|
125
125
|
content_type: file_tmp.content_type,
|
126
126
|
attached_to: @imported_process,
|
127
|
-
weight: file["weight"]
|
127
|
+
weight: file["weight"],
|
128
|
+
file: file_tmp, # Define attached_to before this
|
129
|
+
file_size: file_tmp.size
|
128
130
|
)
|
129
131
|
attachment.create_attachment_collection(file["attachment_collection"])
|
130
132
|
attachment.save!
|
@@ -167,7 +169,9 @@ module Decidim
|
|
167
169
|
|
168
170
|
accepted = ["image", "application/pdf"]
|
169
171
|
url = URI.parse(url)
|
170
|
-
Net::HTTP.
|
172
|
+
http_connection = Net::HTTP.new(url.host, url.port)
|
173
|
+
http_connection.use_ssl = true if url.scheme == "https"
|
174
|
+
http_connection.start do |http|
|
171
175
|
return http.head(url.request_uri)["Content-Type"].start_with?(*accepted)
|
172
176
|
end
|
173
177
|
rescue StandardError
|
@@ -52,6 +52,7 @@ module Decidim
|
|
52
52
|
private_space: participatory_process.private_space,
|
53
53
|
promoted: participatory_process.promoted,
|
54
54
|
scopes_enabled: participatory_process.scopes_enabled,
|
55
|
+
show_metrics: participatory_process.show_metrics,
|
55
56
|
show_statistics: participatory_process.show_statistics,
|
56
57
|
participatory_process_steps: serialize_participatory_process_steps,
|
57
58
|
participatory_process_categories: serialize_categories,
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
# This type represents a ParticipatoryProcess.
|
6
|
+
ParticipatoryProcessGroupType = GraphQL::ObjectType.define do
|
7
|
+
name "ParticipatoryProcessGroup"
|
8
|
+
description "A participatory process group"
|
9
|
+
|
10
|
+
field :id, !types.ID, "ID of this participatory process group"
|
11
|
+
field :name, Decidim::Core::TranslatedFieldType, "The name of this participatory process group"
|
12
|
+
field :description, Decidim::Core::TranslatedFieldType, "The description of this participatory process group", property: :description
|
13
|
+
field :participatoryProcesses, !types[ParticipatoryProcessType] do
|
14
|
+
description "Lists all the participatory processes belonging to this group"
|
15
|
+
property :participatory_processes
|
16
|
+
end
|
17
|
+
field :heroImage, types.String, "The hero image for this participatory process group", property: :hero_image
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
class ParticipatoryProcessInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
include Decidim::Core::HasPublishableInputFilter
|
7
|
+
include Decidim::Core::HasHastaggableInputFilter
|
8
|
+
|
9
|
+
graphql_name "ParticipatoryProcessFilter"
|
10
|
+
description "A type used for filtering participatory processes"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
class ParticipatoryProcessInputSort < Decidim::Core::BaseInputSort
|
6
|
+
include Decidim::Core::HasPublishableInputSort
|
7
|
+
|
8
|
+
graphql_name "ParticipatoryProcessSort"
|
9
|
+
description "A type used for sorting participatory processess"
|
10
|
+
|
11
|
+
argument :id, String, "Sort by ID, valid values are ASC or DESC", required: false
|
12
|
+
argument :start_date, String, "Sort by participatory process starting date, valid values are ASC or DESC", required: false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -16,10 +16,13 @@ module Decidim
|
|
16
16
|
end
|
17
17
|
|
18
18
|
field :title, !Decidim::Core::TranslatedFieldType, "The title of this step"
|
19
|
-
|
20
|
-
field :startDate, Decidim::Core::DateType, "This step's start date
|
21
|
-
|
22
|
-
field :
|
19
|
+
field :description, Decidim::Core::TranslatedFieldType, "The description of this step"
|
20
|
+
field :startDate, Decidim::Core::DateType, "This step's start date", property: :start_date
|
21
|
+
field :endDate, Decidim::Core::DateType, "This step's end date", property: :end_date
|
22
|
+
field :callToActionPath, types.String, "A call to action URL for this step", property: :cta_path
|
23
|
+
field :callToActionText, Decidim::Core::TranslatedFieldType, "The call to action text for this step", property: :cta_text
|
24
|
+
field :active, types.Boolean, "If this step is the active one"
|
25
|
+
field :position, types.Int, "Ordering position among all the steps"
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -6,6 +6,7 @@ module Decidim
|
|
6
6
|
ParticipatoryProcessType = GraphQL::ObjectType.define do
|
7
7
|
interfaces [
|
8
8
|
-> { Decidim::Core::ParticipatorySpaceInterface },
|
9
|
+
-> { Decidim::Core::ParticipatorySpaceResourceableInterface },
|
9
10
|
-> { Decidim::Core::ScopableInterface },
|
10
11
|
-> { Decidim::Core::AttachableInterface }
|
11
12
|
]
|
@@ -13,6 +14,7 @@ module Decidim
|
|
13
14
|
name "ParticipatoryProcess"
|
14
15
|
description "A participatory process"
|
15
16
|
|
17
|
+
field :id, !types.ID, "The internal ID for this participatory process"
|
16
18
|
field :slug, !types.String
|
17
19
|
field :hashtag, types.String, "The hashtag for this participatory process"
|
18
20
|
field :createdAt, !Decidim::Core::DateTimeType, "The time this page was created", property: :created_at
|
@@ -33,6 +35,7 @@ module Decidim
|
|
33
35
|
field :target, Decidim::Core::TranslatedFieldType, "Who participates in this participatory process."
|
34
36
|
field :participatoryScope, Decidim::Core::TranslatedFieldType, "What is decided on this participatory process.", property: :participatory_scope
|
35
37
|
field :participatoryStructure, Decidim::Core::TranslatedFieldType, "How it is decided on this participatory process.", property: :participatory_structure
|
38
|
+
field :showMetrics, types.Boolean, "If this participatory process should show metrics", property: :show_metrics
|
36
39
|
field :showStatistics, types.Boolean, "If this participatory process should show statistics", property: :show_statistics
|
37
40
|
field :scopesEnabled, types.Boolean, "If this participatory process has scopes enabled", property: :scopes_enabled
|
38
41
|
|
@@ -40,11 +43,12 @@ module Decidim
|
|
40
43
|
|
41
44
|
field :reference, types.String, "Reference prefix for this participatory process"
|
42
45
|
field :steps, !types[ParticipatoryProcessStepType], "All the steps of this process."
|
46
|
+
field :categories, !types[Decidim::Core::CategoryType], "Categories for this participatory process"
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
field :participatoryProcessGroup, ParticipatoryProcessGroupType do
|
49
|
+
description "The participatory process group in which this process belong to"
|
50
|
+
property :participatory_process_group
|
51
|
+
end
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|