decidim-proposals 0.30.5 → 0.31.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/proposals/collaborative_draft_metadata_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_g/show.erb +1 -1
- data/app/cells/decidim/proposals/proposal_g_cell.rb +4 -4
- data/app/cells/decidim/proposals/proposal_l_cell.rb +4 -4
- data/app/cells/decidim/proposals/proposal_metadata_cell.rb +2 -2
- data/app/cells/decidim/proposals/proposal_vote/show.erb +1 -1
- data/app/commands/decidim/proposals/admin/{assign_proposals_to_valuator.rb → assign_proposals_to_evaluator.rb} +16 -16
- data/app/commands/decidim/proposals/admin/create_proposal.rb +1 -2
- data/app/commands/decidim/proposals/admin/create_proposal_note.rb +4 -4
- data/app/commands/decidim/proposals/admin/merge_proposals.rb +60 -13
- data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +2 -2
- data/app/commands/decidim/proposals/admin/proposal_notes_methods.rb +5 -5
- data/app/commands/decidim/proposals/admin/reply_proposal_note.rb +1 -1
- data/app/commands/decidim/proposals/admin/{unassign_proposals_from_valuator.rb → unassign_proposals_from_evaluator.rb} +7 -7
- data/app/commands/decidim/proposals/admin/update_proposal.rb +1 -2
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +3 -8
- data/app/commands/decidim/proposals/create_proposal.rb +5 -22
- data/app/commands/decidim/proposals/publish_collaborative_draft.rb +2 -2
- data/app/commands/decidim/proposals/publish_proposal.rb +1 -5
- data/app/commands/decidim/proposals/update_collaborative_draft.rb +2 -4
- data/app/commands/decidim/proposals/update_proposal.rb +5 -18
- data/app/controllers/concerns/decidim/proposals/admin/filterable.rb +6 -6
- data/app/controllers/concerns/decidim/proposals/orderable.rb +3 -3
- data/app/controllers/decidim/proposals/admin/evaluation_assignments_controller.rb +55 -0
- data/app/controllers/decidim/proposals/admin/participatory_texts_controller.rb +6 -6
- data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposal_states_controller.rb +2 -2
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
- data/app/controllers/decidim/proposals/admin/proposals_imports_controller.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposals_merges_controller.rb +12 -3
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +2 -3
- data/app/controllers/decidim/proposals/proposals_controller.rb +5 -6
- data/app/events/decidim/proposals/admin/{proposal_assigned_to_valuator_event.rb → proposal_assigned_to_evaluator_event.rb} +1 -1
- data/app/events/decidim/proposals/{endorsing_enabled_event.rb → liking_enabled_event.rb} +1 -1
- data/app/events/decidim/proposals/merged_proposal_event.rb +9 -0
- data/app/events/decidim/proposals/proposal_liked_event.rb +33 -0
- data/app/forms/decidim/proposals/admin/evaluation_assignment_form.rb +38 -0
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +1 -27
- data/app/forms/decidim/proposals/admin/proposals_fork_form.rb +1 -1
- data/app/forms/decidim/proposals/admin/proposals_merge_form.rb +58 -2
- data/app/forms/decidim/proposals/collaborative_draft_form.rb +1 -5
- data/app/forms/decidim/proposals/proposal_form.rb +0 -29
- data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +8 -8
- data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +6 -6
- data/app/helpers/decidim/proposals/admin/proposals_helper.rb +2 -17
- data/app/helpers/decidim/proposals/application_helper.rb +3 -6
- data/app/jobs/decidim/proposals/settings_change_job.rb +6 -6
- data/app/models/decidim/proposals/collaborative_draft.rb +1 -1
- data/app/models/decidim/proposals/{valuation_assignment.rb → evaluation_assignment.rb} +7 -7
- data/app/models/decidim/proposals/proposal.rb +24 -34
- data/app/packs/entrypoints/decidim_proposals_admin.js +1 -0
- data/app/packs/src/decidim/proposals/add_proposal.js +1 -1
- data/app/packs/src/decidim/proposals/admin/proposals.js +22 -11
- data/app/packs/src/decidim/proposals/admin/proposals_form.js +1 -1
- data/app/packs/src/decidim/proposals/admin/proposals_merge.js +92 -0
- data/app/packs/src/decidim/proposals/choose_proposals.js +1 -1
- data/app/packs/src/decidim/proposals/exit_handler.js +1 -1
- data/app/packs/src/decidim/proposals/utils.js +1 -1
- data/app/packs/stylesheets/decidim/proposals/proposals.scss +29 -1
- data/app/permissions/decidim/proposals/admin/permissions.rb +20 -20
- data/app/presenters/decidim/proposals/admin_log/{valuation_assignment_presenter.rb → evaluation_assignment_presenter.rb} +7 -7
- data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +15 -0
- data/app/presenters/decidim/proposals/admin_log/value_types/{valuator_role_user_presenter.rb → evaluator_role_user_presenter.rb} +2 -2
- data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +1 -1
- data/app/presenters/decidim/proposals/collaborative_draft_presenter.rb +1 -6
- data/app/presenters/decidim/proposals/log/{valuation_assignment_presenter.rb → evaluation_assignment_presenter.rb} +1 -1
- data/app/presenters/decidim/proposals/proposal_presenter.rb +10 -13
- data/app/services/decidim/proposals/diff_renderer.rb +0 -1
- data/app/services/decidim/proposals/proposal_builder.rb +5 -10
- data/app/views/decidim/proposals/admin/participatory_texts/_article-preview.html.erb +1 -1
- data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +1 -2
- data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposal_states/index.html.erb +42 -12
- data/app/views/decidim/proposals/admin/proposals/_actions.html.erb +87 -21
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +9 -13
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +2 -24
- data/app/views/decidim/proposals/admin/proposals/_likes.html.erb +25 -0
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +13 -12
- data/app/views/decidim/proposals/admin/proposals/_proposals-thead.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_evaluator.html.erb +19 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_dropdown.html.erb +45 -49
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/{_valuators_picker.html.erb → _evaluators_picker.html.erb} +4 -4
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_merge.html.erb +7 -14
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_evaluator.html.erb +19 -0
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +9 -5
- data/app/views/decidim/proposals/admin/proposals/manage_trash.html.erb +2 -1
- data/app/views/decidim/proposals/admin/proposals/show.html.erb +17 -17
- data/app/views/decidim/proposals/admin/proposals_merges/_form.html.erb +49 -0
- data/app/views/decidim/proposals/admin/proposals_merges/new.html.erb +14 -0
- data/app/views/decidim/proposals/collaborative_drafts/_collaborative_actions.html.erb +2 -2
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +1 -21
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_actions.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +1 -21
- data/app/views/decidim/proposals/proposals/_proposal_actions.html.erb +4 -4
- data/app/views/decidim/proposals/proposals/_proposal_aside.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_proposal_voting_rules.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_votes_count.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/preview.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/show.html.erb +2 -2
- data/config/assets.rb +2 -2
- data/config/locales/ar.yml +0 -65
- data/config/locales/bg.yml +0 -71
- data/config/locales/bs-BA.yml +0 -25
- data/config/locales/ca-IT.yml +66 -74
- data/config/locales/ca.yml +66 -74
- data/config/locales/cs.yml +52 -81
- data/config/locales/de.yml +66 -75
- data/config/locales/el.yml +0 -66
- data/config/locales/en.yml +69 -77
- data/config/locales/es-MX.yml +68 -76
- data/config/locales/es-PY.yml +68 -76
- data/config/locales/es.yml +68 -76
- data/config/locales/eu.yml +73 -81
- data/config/locales/fi-plain.yml +67 -75
- data/config/locales/fi.yml +68 -76
- data/config/locales/fr-CA.yml +49 -74
- data/config/locales/fr.yml +49 -74
- data/config/locales/ga-IE.yml +0 -22
- data/config/locales/gl.yml +0 -47
- data/config/locales/hu.yml +0 -64
- data/config/locales/id-ID.yml +0 -34
- data/config/locales/is-IS.yml +0 -14
- data/config/locales/it.yml +0 -69
- data/config/locales/ja.yml +68 -76
- data/config/locales/lb.yml +0 -3
- data/config/locales/lt.yml +0 -68
- data/config/locales/lv.yml +0 -62
- data/config/locales/nl.yml +0 -63
- data/config/locales/no.yml +0 -42
- data/config/locales/pl.yml +0 -73
- data/config/locales/pt-BR.yml +1 -469
- data/config/locales/pt.yml +0 -60
- data/config/locales/ro-RO.yml +45 -72
- data/config/locales/ru.yml +0 -15
- data/config/locales/sk.yml +0 -60
- data/config/locales/sr-CS.yml +0 -25
- data/config/locales/sv.yml +82 -113
- data/config/locales/tr-TR.yml +0 -58
- data/config/locales/uk.yml +0 -15
- data/config/locales/zh-CN.yml +0 -57
- data/config/locales/zh-TW.yml +0 -65
- data/db/migrate/20240110203500_add_withdrawn_at_field_to_proposals.rb +1 -1
- data/db/migrate/20240110203504_create_default_proposal_states.rb +1 -1
- data/db/migrate/20250121110014_rename_proposal_valuation_assignments_to_evaluation_assignments.rb +15 -0
- data/db/migrate/20250121110904_rename_valuation_assignments_count_to_evaluation_assignments_count.rb +16 -0
- data/db/migrate/20250211141313_rename_valuator_columns.rb +8 -0
- data/db/migrate/20250515132351_rename_proposals_endorsements_count_to_likes.rb +7 -0
- data/decidim-proposals.gemspec +1 -1
- data/lib/decidim/api/mutations/answer_proposal_attributes.rb +17 -0
- data/lib/decidim/api/mutations/proposal_answer_type.rb +57 -0
- data/lib/decidim/api/mutations/proposal_mutation_type.rb +14 -0
- data/lib/decidim/api/mutations/proposals_mutation_type.rb +23 -0
- data/lib/decidim/api/proposal_input_sort.rb +1 -1
- data/lib/decidim/api/proposal_state_type.rb +16 -0
- data/lib/decidim/api/proposal_type.rb +59 -9
- data/lib/decidim/proposals/admin_engine.rb +3 -3
- data/lib/decidim/proposals/admin_filter.rb +3 -3
- data/lib/decidim/proposals/api.rb +5 -0
- data/lib/decidim/proposals/component.rb +44 -36
- data/lib/decidim/proposals/engine.rb +18 -83
- data/lib/decidim/proposals/evaluable.rb +22 -0
- data/lib/decidim/proposals/import/proposal_creator.rb +1 -1
- data/lib/decidim/proposals/proposal_serializer.rb +9 -11
- data/lib/decidim/proposals/seeds.rb +17 -28
- data/lib/decidim/proposals/test/factories.rb +21 -53
- data/lib/decidim/proposals/version.rb +1 -1
- data/lib/decidim/proposals.rb +3 -3
- data/lib/tasks/proposals/upgrade/decidim_proposals_upgrade_tasks.rake +11 -11
- metadata +57 -47
- data/app/commands/decidim/proposals/hashtags_methods.rb +0 -36
- data/app/controllers/decidim/proposals/admin/valuation_assignments_controller.rb +0 -55
- data/app/events/decidim/proposals/proposal_endorsed_event.rb +0 -33
- data/app/forms/decidim/proposals/admin/proposals_file_import_form.rb +0 -31
- data/app/forms/decidim/proposals/admin/valuation_assignment_form.rb +0 -38
- data/app/queries/decidim/proposals/metrics/accepted_proposals_metric_manage.rb +0 -32
- data/app/queries/decidim/proposals/metrics/endorsements_metric_manage.rb +0 -58
- data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +0 -58
- data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +0 -74
- data/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb +0 -48
- data/app/queries/decidim/proposals/metrics/votes_metric_manage.rb +0 -52
- data/app/views/decidim/proposals/admin/imports/_proposals_fields.html.erb +0 -11
- data/app/views/decidim/proposals/admin/proposals/_endorsers.html.erb +0 -25
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_valuator.html.erb +0 -19
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_valuator.html.erb +0 -19
- data/lib/decidim/proposals/valuatable.rb +0 -22
|
@@ -103,7 +103,7 @@ module Decidim
|
|
|
103
103
|
|
|
104
104
|
initializer "decidim_proposals.remove_space_admins" do
|
|
105
105
|
ActiveSupport::Notifications.subscribe("decidim.admin.participatory_space.destroy_admin:after") do |_event_name, data|
|
|
106
|
-
Decidim::Proposals::
|
|
106
|
+
Decidim::Proposals::EvaluationAssignment.where(evaluator_role_type: data.fetch(:class_name), evaluator_role_id: data.fetch(:role)).destroy_all
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -111,44 +111,26 @@ module Decidim
|
|
|
111
111
|
Decidim::Gamification.register_badge(:proposals) do |badge|
|
|
112
112
|
badge.levels = [1, 5, 10, 30, 60]
|
|
113
113
|
|
|
114
|
-
badge.valid_for = [:user
|
|
114
|
+
badge.valid_for = [:user]
|
|
115
115
|
|
|
116
116
|
badge.reset = lambda { |model|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
author: model,
|
|
122
|
-
user_group: nil
|
|
123
|
-
).count
|
|
124
|
-
when UserGroup
|
|
125
|
-
Decidim::Coauthorship.where(
|
|
126
|
-
coauthorable_type: "Decidim::Proposals::Proposal",
|
|
127
|
-
user_group: model
|
|
128
|
-
).count
|
|
129
|
-
end
|
|
117
|
+
Decidim::Coauthorship.where(
|
|
118
|
+
coauthorable_type: "Decidim::Proposals::Proposal",
|
|
119
|
+
author: model
|
|
120
|
+
).count
|
|
130
121
|
}
|
|
131
122
|
end
|
|
132
123
|
|
|
133
124
|
Decidim::Gamification.register_badge(:accepted_proposals) do |badge|
|
|
134
125
|
badge.levels = [1, 5, 15, 30, 50]
|
|
135
126
|
|
|
136
|
-
badge.valid_for = [:user
|
|
127
|
+
badge.valid_for = [:user]
|
|
137
128
|
|
|
138
129
|
badge.reset = lambda { |model|
|
|
139
|
-
proposal_ids =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
author: model,
|
|
144
|
-
user_group: nil
|
|
145
|
-
).select(:coauthorable_id)
|
|
146
|
-
when UserGroup
|
|
147
|
-
Decidim::Coauthorship.where(
|
|
148
|
-
coauthorable_type: "Decidim::Proposals::Proposal",
|
|
149
|
-
user_group: model
|
|
150
|
-
).select(:coauthorable_id)
|
|
151
|
-
end
|
|
130
|
+
proposal_ids = Decidim::Coauthorship.where(
|
|
131
|
+
coauthorable_type: "Decidim::Proposals::Proposal",
|
|
132
|
+
author: model
|
|
133
|
+
).select(:coauthorable_id)
|
|
152
134
|
|
|
153
135
|
Decidim::Proposals::Proposal.where(id: proposal_ids).accepted.count
|
|
154
136
|
}
|
|
@@ -163,60 +145,7 @@ module Decidim
|
|
|
163
145
|
end
|
|
164
146
|
end
|
|
165
147
|
|
|
166
|
-
initializer "decidim_proposals.
|
|
167
|
-
Decidim.metrics_registry.register(:proposals) do |metric_registry|
|
|
168
|
-
metric_registry.manager_class = "Decidim::Proposals::Metrics::ProposalsMetricManage"
|
|
169
|
-
|
|
170
|
-
metric_registry.settings do |settings|
|
|
171
|
-
settings.attribute :highlighted, type: :boolean, default: true
|
|
172
|
-
settings.attribute :scopes, type: :array, default: %w(home participatory_process)
|
|
173
|
-
settings.attribute :weight, type: :integer, default: 2
|
|
174
|
-
settings.attribute :stat_block, type: :string, default: "medium"
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
Decidim.metrics_registry.register(:accepted_proposals) do |metric_registry|
|
|
179
|
-
metric_registry.manager_class = "Decidim::Proposals::Metrics::AcceptedProposalsMetricManage"
|
|
180
|
-
|
|
181
|
-
metric_registry.settings do |settings|
|
|
182
|
-
settings.attribute :highlighted, type: :boolean, default: false
|
|
183
|
-
settings.attribute :scopes, type: :array, default: %w(home participatory_process)
|
|
184
|
-
settings.attribute :weight, type: :integer, default: 3
|
|
185
|
-
settings.attribute :stat_block, type: :string, default: "small"
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
Decidim.metrics_registry.register(:votes) do |metric_registry|
|
|
190
|
-
metric_registry.manager_class = "Decidim::Proposals::Metrics::VotesMetricManage"
|
|
191
|
-
|
|
192
|
-
metric_registry.settings do |settings|
|
|
193
|
-
settings.attribute :highlighted, type: :boolean, default: true
|
|
194
|
-
settings.attribute :scopes, type: :array, default: %w(home participatory_process)
|
|
195
|
-
settings.attribute :weight, type: :integer, default: 3
|
|
196
|
-
settings.attribute :stat_block, type: :string, default: "medium"
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
Decidim.metrics_registry.register(:endorsements) do |metric_registry|
|
|
201
|
-
metric_registry.manager_class = "Decidim::Proposals::Metrics::EndorsementsMetricManage"
|
|
202
|
-
|
|
203
|
-
metric_registry.settings do |settings|
|
|
204
|
-
settings.attribute :highlighted, type: :boolean, default: false
|
|
205
|
-
settings.attribute :scopes, type: :array, default: %w(participatory_process)
|
|
206
|
-
settings.attribute :weight, type: :integer, default: 4
|
|
207
|
-
settings.attribute :stat_block, type: :string, default: "medium"
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
Decidim.metrics_operation.register(:participants, :proposals) do |metric_operation|
|
|
212
|
-
metric_operation.manager_class = "Decidim::Proposals::Metrics::ProposalParticipantsMetricMeasure"
|
|
213
|
-
end
|
|
214
|
-
Decidim.metrics_operation.register(:followers, :proposals) do |metric_operation|
|
|
215
|
-
metric_operation.manager_class = "Decidim::Proposals::Metrics::ProposalFollowersMetricMeasure"
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
initializer "decidim_proposals.webpacker.assets_path" do
|
|
148
|
+
initializer "decidim_proposals.shakapacker.assets_path" do
|
|
220
149
|
Decidim.register_assets_path File.expand_path("app/packs", root)
|
|
221
150
|
end
|
|
222
151
|
|
|
@@ -235,6 +164,12 @@ module Decidim
|
|
|
235
164
|
end
|
|
236
165
|
end
|
|
237
166
|
end
|
|
167
|
+
|
|
168
|
+
initializer "decidim_proposals.register_mutations", before: "decidim_api.graphiql" do
|
|
169
|
+
Decidim::MutationRegistry.instance.register(
|
|
170
|
+
Decidim::Proposals::ProposalsMutationType
|
|
171
|
+
)
|
|
172
|
+
end
|
|
238
173
|
end
|
|
239
174
|
end
|
|
240
175
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Proposals
|
|
5
|
+
# A set of methods and features related to proposal evaluations.
|
|
6
|
+
module Evaluable
|
|
7
|
+
extend ActiveSupport::Concern
|
|
8
|
+
include Decidim::Comments::Commentable
|
|
9
|
+
|
|
10
|
+
included do
|
|
11
|
+
has_many :evaluation_assignments, foreign_key: "decidim_proposal_id", dependent: :destroy,
|
|
12
|
+
counter_cache: :evaluation_assignments_count, class_name: "Decidim::Proposals::EvaluationAssignment"
|
|
13
|
+
|
|
14
|
+
def evaluators
|
|
15
|
+
evaluator_role_ids = evaluation_assignments.where(proposal: self).pluck(:evaluator_role_id)
|
|
16
|
+
user_ids = participatory_space.user_roles(:evaluator).where(id: evaluator_role_ids).pluck(:decidim_user_id)
|
|
17
|
+
participatory_space.organization.users.where(id: user_ids)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -40,9 +40,9 @@ module Decidim
|
|
|
40
40
|
answered_at: proposal.answered_at,
|
|
41
41
|
votes: (proposal.proposal_votes_count unless
|
|
42
42
|
proposal.component.current_settings.votes_hidden?),
|
|
43
|
-
|
|
44
|
-
total_count: proposal.
|
|
45
|
-
|
|
43
|
+
likes: {
|
|
44
|
+
total_count: proposal.likes.size,
|
|
45
|
+
user_likes:
|
|
46
46
|
},
|
|
47
47
|
comments: proposal.comments_count,
|
|
48
48
|
attachments: proposal.attachments.size,
|
|
@@ -89,8 +89,8 @@ module Decidim
|
|
|
89
89
|
Decidim::ResourceLocatorPresenter.new(proposal).url
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
def
|
|
93
|
-
proposal.
|
|
92
|
+
def user_likes
|
|
93
|
+
proposal.likes.for_listing.map { |identity| identity.author&.name }
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
def original_proposal_url
|
|
@@ -107,22 +107,20 @@ module Decidim
|
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
def author_fields
|
|
110
|
-
is_author_user_group = resource.coauthorships.map(&:decidim_user_group_id).any?
|
|
111
|
-
|
|
112
110
|
{
|
|
113
111
|
id: resource.authors.map(&:id),
|
|
114
112
|
name: resource.authors.map do |author|
|
|
115
|
-
author_name(
|
|
113
|
+
author_name(author)
|
|
116
114
|
end,
|
|
117
115
|
url: resource.authors.map do |author|
|
|
118
|
-
author_url(
|
|
116
|
+
author_url(author)
|
|
119
117
|
end
|
|
120
118
|
}
|
|
121
119
|
end
|
|
122
120
|
|
|
123
121
|
def author_name(author)
|
|
124
122
|
if author.respond_to?(:name)
|
|
125
|
-
translated_attribute(author.name) # is a Decidim::User or Decidim::Organization
|
|
123
|
+
translated_attribute(author.name) # is a Decidim::User or Decidim::Organization
|
|
126
124
|
elsif author.respond_to?(:title)
|
|
127
125
|
translated_attribute(author.title) # is a Decidim::Meetings::Meeting
|
|
128
126
|
end
|
|
@@ -130,7 +128,7 @@ module Decidim
|
|
|
130
128
|
|
|
131
129
|
def author_url(author)
|
|
132
130
|
if author.respond_to?(:nickname)
|
|
133
|
-
profile_url(author) # is a Decidim::User
|
|
131
|
+
profile_url(author) # is a Decidim::User
|
|
134
132
|
elsif author.respond_to?(:title)
|
|
135
133
|
meeting_url(author) # is a Decidim::Meetings::Meeting
|
|
136
134
|
else
|
|
@@ -17,7 +17,9 @@ module Decidim
|
|
|
17
17
|
|
|
18
18
|
Decidim::Proposals.create_default_states!(component, admin_user)
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
number_of_records = slow_seeds? ? 10 : rand(25..50)
|
|
21
|
+
|
|
22
|
+
(5..number_of_records).to_a.sample.times do |n|
|
|
21
23
|
proposal = create_proposal!(component:)
|
|
22
24
|
|
|
23
25
|
if proposal.state.nil? && component.settings.amendments_enabled?
|
|
@@ -50,7 +52,12 @@ module Decidim
|
|
|
50
52
|
|
|
51
53
|
def create_component!
|
|
52
54
|
step_settings = if participatory_space.allows_steps?
|
|
53
|
-
{ participatory_space.active_step.id => {
|
|
55
|
+
{ participatory_space.active_step.id => {
|
|
56
|
+
votes_enabled: true,
|
|
57
|
+
votes_blocked: [false, true].sample,
|
|
58
|
+
votes_hidden: [false, true].sample,
|
|
59
|
+
creation_enabled: true
|
|
60
|
+
} }
|
|
54
61
|
else
|
|
55
62
|
{}
|
|
56
63
|
end
|
|
@@ -61,7 +68,10 @@ module Decidim
|
|
|
61
68
|
published_at: Time.current,
|
|
62
69
|
participatory_space:,
|
|
63
70
|
settings: {
|
|
64
|
-
|
|
71
|
+
minimum_votes_per_user: (0..2).to_a.sample,
|
|
72
|
+
vote_limit: (0..5).to_a.sample,
|
|
73
|
+
threshold_per_proposal: [0, (10..100).to_a.sample].sample,
|
|
74
|
+
can_accumulate_votes_beyond_threshold: [true, false].sample,
|
|
65
75
|
attachments_allowed: [true, false].sample,
|
|
66
76
|
amendments_enabled: participatory_space.id.odd?,
|
|
67
77
|
collaborative_drafts_enabled: true,
|
|
@@ -146,15 +156,13 @@ module Decidim
|
|
|
146
156
|
end
|
|
147
157
|
|
|
148
158
|
def random_coauthor
|
|
149
|
-
n = rand(
|
|
150
|
-
n =
|
|
159
|
+
n = rand(4)
|
|
160
|
+
n = 2 if n == 1 && !Decidim.module_installed?(:meetings)
|
|
151
161
|
|
|
152
162
|
case n
|
|
153
163
|
when 0
|
|
154
164
|
Decidim::User.where(organization:).sample
|
|
155
165
|
when 1
|
|
156
|
-
Decidim::UserGroup.where(organization:).sample
|
|
157
|
-
when 2
|
|
158
166
|
meeting_component = participatory_space.components.find_by(manifest_name: "meetings")
|
|
159
167
|
|
|
160
168
|
Decidim::Meetings::Meeting.where(component: meeting_component).sample
|
|
@@ -164,7 +172,7 @@ module Decidim
|
|
|
164
172
|
end
|
|
165
173
|
|
|
166
174
|
def random_nickname
|
|
167
|
-
"#{::Faker::
|
|
175
|
+
"#{::Faker::Twitter.unique.screen_name}-#{SecureRandom.hex(4)}"[0, 20]
|
|
168
176
|
end
|
|
169
177
|
|
|
170
178
|
def random_email(suffix:)
|
|
@@ -176,25 +184,6 @@ module Decidim
|
|
|
176
184
|
def create_emendation!(proposal:)
|
|
177
185
|
author = find_or_initialize_user_by(email: random_email(suffix: "amendment"))
|
|
178
186
|
|
|
179
|
-
group = Decidim::UserGroup.create!(
|
|
180
|
-
name: ::Faker::Name.name,
|
|
181
|
-
nickname: random_nickname,
|
|
182
|
-
email: ::Faker::Internet.email,
|
|
183
|
-
extended_data: {
|
|
184
|
-
document_number: ::Faker::Code.isbn,
|
|
185
|
-
phone: ::Faker::PhoneNumber.phone_number,
|
|
186
|
-
verified_at: Time.current
|
|
187
|
-
},
|
|
188
|
-
organization:,
|
|
189
|
-
confirmed_at: Time.current
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
Decidim::UserGroupMembership.create!(
|
|
193
|
-
user: author,
|
|
194
|
-
role: "creator",
|
|
195
|
-
user_group: group
|
|
196
|
-
)
|
|
197
|
-
|
|
198
187
|
params = {
|
|
199
188
|
component: proposal.component,
|
|
200
189
|
title: Decidim::Faker::Localized.literal(proposal.title[I18n.locale]),
|
|
@@ -212,7 +201,7 @@ module Decidim
|
|
|
212
201
|
visibility: "public-only"
|
|
213
202
|
) do
|
|
214
203
|
emendation = Decidim::Proposals::Proposal.new(params)
|
|
215
|
-
emendation.add_coauthor(author
|
|
204
|
+
emendation.add_coauthor(author)
|
|
216
205
|
emendation.save!
|
|
217
206
|
emendation
|
|
218
207
|
end
|
|
@@ -29,18 +29,18 @@ FactoryBot.define do
|
|
|
29
29
|
Decidim::Proposals.create_default_states!(proposal_component, nil, with_traceability: false)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
trait :
|
|
32
|
+
trait :with_likes_enabled do
|
|
33
33
|
step_settings do
|
|
34
34
|
{
|
|
35
|
-
participatory_space.active_step.id => {
|
|
35
|
+
participatory_space.active_step.id => { likes_enabled: true }
|
|
36
36
|
}
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
trait :
|
|
40
|
+
trait :with_likes_disabled do
|
|
41
41
|
step_settings do
|
|
42
42
|
{
|
|
43
|
-
participatory_space.active_step.id => {
|
|
43
|
+
participatory_space.active_step.id => { likes_enabled: false }
|
|
44
44
|
}
|
|
45
45
|
end
|
|
46
46
|
end
|
|
@@ -105,12 +105,12 @@ FactoryBot.define do
|
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
trait :
|
|
108
|
+
trait :with_likes_blocked do
|
|
109
109
|
step_settings do
|
|
110
110
|
{
|
|
111
111
|
participatory_space.active_step.id => {
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
likes_enabled: true,
|
|
113
|
+
likes_blocked: true
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
end
|
|
@@ -233,23 +233,6 @@ FactoryBot.define do
|
|
|
233
233
|
end
|
|
234
234
|
end
|
|
235
235
|
|
|
236
|
-
trait :with_extra_hashtags do
|
|
237
|
-
transient do
|
|
238
|
-
automatic_hashtags { "AutoHashtag AnotherAutoHashtag" }
|
|
239
|
-
suggested_hashtags { "SuggestedHashtag AnotherSuggestedHashtag" }
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
step_settings do
|
|
243
|
-
{
|
|
244
|
-
participatory_space.active_step.id => {
|
|
245
|
-
automatic_hashtags:,
|
|
246
|
-
suggested_hashtags:,
|
|
247
|
-
creation_enabled: true
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
|
|
253
236
|
trait :without_publish_answers_immediately do
|
|
254
237
|
step_settings do
|
|
255
238
|
{
|
|
@@ -296,8 +279,6 @@ FactoryBot.define do
|
|
|
296
279
|
factory :proposal, class: "Decidim::Proposals::Proposal" do
|
|
297
280
|
transient do
|
|
298
281
|
users { nil }
|
|
299
|
-
# user_groups correspondence to users is by sorting order
|
|
300
|
-
user_groups { [] }
|
|
301
282
|
skip_injection { false }
|
|
302
283
|
state { :not_answered }
|
|
303
284
|
end
|
|
@@ -334,14 +315,13 @@ FactoryBot.define do
|
|
|
334
315
|
evaluator.body
|
|
335
316
|
end
|
|
336
317
|
|
|
337
|
-
proposal.title = Decidim::ContentProcessor.
|
|
338
|
-
proposal.body = Decidim::ContentProcessor.parse_with_processor(:
|
|
318
|
+
proposal.title = Decidim::ContentProcessor.parse(proposal.title, current_organization: proposal.organization).rewrite
|
|
319
|
+
proposal.body = Decidim::ContentProcessor.parse_with_processor(:inline_images, proposal.body, current_organization: proposal.organization).rewrite
|
|
339
320
|
|
|
340
321
|
if proposal.component
|
|
341
322
|
users = evaluator.users || [create(:user, :confirmed, organization: proposal.component.participatory_space.organization, skip_injection: evaluator.skip_injection)]
|
|
342
|
-
users.
|
|
343
|
-
|
|
344
|
-
proposal.coauthorships.build(author: user, user_group:)
|
|
323
|
+
users.each do |user|
|
|
324
|
+
proposal.coauthorships.build(author: user)
|
|
345
325
|
end
|
|
346
326
|
end
|
|
347
327
|
end
|
|
@@ -362,15 +342,6 @@ FactoryBot.define do
|
|
|
362
342
|
end
|
|
363
343
|
end
|
|
364
344
|
|
|
365
|
-
trait :user_group_author do
|
|
366
|
-
after :build do |proposal, evaluator|
|
|
367
|
-
proposal.coauthorships.clear
|
|
368
|
-
user = create(:user, organization: proposal.component.participatory_space.organization, skip_injection: evaluator.skip_injection)
|
|
369
|
-
user_group = create(:user_group, :verified, organization: user.organization, users: [user], skip_injection: evaluator.skip_injection)
|
|
370
|
-
proposal.coauthorships.build(author: user, user_group:)
|
|
371
|
-
end
|
|
372
|
-
end
|
|
373
|
-
|
|
374
345
|
trait :official do
|
|
375
346
|
after :build do |proposal|
|
|
376
347
|
proposal.coauthorships.clear
|
|
@@ -410,9 +381,9 @@ FactoryBot.define do
|
|
|
410
381
|
|
|
411
382
|
trait :accepted_not_published do
|
|
412
383
|
state { :accepted }
|
|
384
|
+
answer { generate_localized_title }
|
|
413
385
|
answered_at { Time.current }
|
|
414
386
|
state_published_at { nil }
|
|
415
|
-
answer { generate_localized_title }
|
|
416
387
|
end
|
|
417
388
|
|
|
418
389
|
trait :with_answer do
|
|
@@ -442,12 +413,12 @@ FactoryBot.define do
|
|
|
442
413
|
end
|
|
443
414
|
end
|
|
444
415
|
|
|
445
|
-
trait :
|
|
416
|
+
trait :with_likes do
|
|
446
417
|
after :create do |proposal, evaluator|
|
|
447
418
|
5.times.collect do
|
|
448
|
-
create(:
|
|
449
|
-
|
|
450
|
-
|
|
419
|
+
create(:like, resource: proposal,
|
|
420
|
+
author: build(:user, :confirmed, organization: proposal.participatory_space.organization, skip_injection: evaluator.skip_injection),
|
|
421
|
+
skip_injection: evaluator.skip_injection)
|
|
451
422
|
end
|
|
452
423
|
end
|
|
453
424
|
end
|
|
@@ -514,8 +485,6 @@ FactoryBot.define do
|
|
|
514
485
|
transient do
|
|
515
486
|
skip_injection { false }
|
|
516
487
|
users { nil }
|
|
517
|
-
# user_groups correspondence to users is by sorting order
|
|
518
|
-
user_groups { [] }
|
|
519
488
|
end
|
|
520
489
|
|
|
521
490
|
title { generate_localized_title(:collaborative_draft_title, skip_injection:)["en"] }
|
|
@@ -527,9 +496,8 @@ FactoryBot.define do
|
|
|
527
496
|
after(:build) do |collaborative_draft, evaluator|
|
|
528
497
|
if collaborative_draft.component
|
|
529
498
|
users = evaluator.users || [create(:user, organization: collaborative_draft.component.participatory_space.organization, skip_injection: evaluator.skip_injection)]
|
|
530
|
-
users.
|
|
531
|
-
|
|
532
|
-
collaborative_draft.coauthorships.build(author: user, user_group:)
|
|
499
|
+
users.each do |user|
|
|
500
|
+
collaborative_draft.coauthorships.build(author: user)
|
|
533
501
|
end
|
|
534
502
|
end
|
|
535
503
|
end
|
|
@@ -566,15 +534,15 @@ FactoryBot.define do
|
|
|
566
534
|
component { create(:proposal_component, skip_injection:) }
|
|
567
535
|
end
|
|
568
536
|
|
|
569
|
-
factory :
|
|
537
|
+
factory :evaluation_assignment, class: "Decidim::Proposals::EvaluationAssignment" do
|
|
570
538
|
transient do
|
|
571
539
|
skip_injection { false }
|
|
572
540
|
end
|
|
573
541
|
proposal
|
|
574
|
-
|
|
542
|
+
evaluator_role do
|
|
575
543
|
space = proposal.component.participatory_space
|
|
576
544
|
organization = space.organization
|
|
577
|
-
build(:participatory_process_user_role, role: :
|
|
545
|
+
build(:participatory_process_user_role, role: :evaluator, skip_injection:, user: build(:user, organization:, skip_injection:))
|
|
578
546
|
end
|
|
579
547
|
end
|
|
580
548
|
end
|
data/lib/decidim/proposals.rb
CHANGED
|
@@ -22,20 +22,20 @@ module Decidim
|
|
|
22
22
|
autoload :ParticipatoryTextSection, "decidim/proposals/participatory_text_section"
|
|
23
23
|
autoload :DocToMarkdown, "decidim/proposals/doc_to_markdown"
|
|
24
24
|
autoload :OdtToMarkdown, "decidim/proposals/odt_to_markdown"
|
|
25
|
-
autoload :
|
|
25
|
+
autoload :Evaluable, "decidim/proposals/evaluable"
|
|
26
26
|
|
|
27
27
|
include ActiveSupport::Configurable
|
|
28
28
|
|
|
29
29
|
# Public Setting that defines how many proposals will be shown in the
|
|
30
30
|
# participatory_space_highlighted_elements view hook
|
|
31
31
|
config_accessor :participatory_space_highlighted_proposals_limit do
|
|
32
|
-
4
|
|
32
|
+
Decidim::Env.new("PROPOSALS_PARTICIPATORY_SPACE_HIGHLIGHTED_PROPOSALS_LIMIT", 4).to_i
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Public Setting that defines how many proposals will be shown in the
|
|
36
36
|
# process_group_highlighted_elements view hook
|
|
37
37
|
config_accessor :process_group_highlighted_proposals_limit do
|
|
38
|
-
3
|
|
38
|
+
Decidim::Env.new("PROPOSALS_PROCESS_GROUP_HIGHLIGHTED_PROPOSALS_LIMIT", 3).to_i
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def self.proposal_states_colors
|
|
@@ -37,29 +37,29 @@ namespace :decidim_proposals do
|
|
|
37
37
|
puts "FINISHED"
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
desc "Removes all proposal
|
|
41
|
-
task
|
|
40
|
+
desc "Removes all proposal evaluator records of which the role assignment does not exists"
|
|
41
|
+
task remove_evaluator_orphan_records: :environment do
|
|
42
42
|
if Decidim.module_installed?("participatory_processes")
|
|
43
|
-
Decidim::Proposals::
|
|
44
|
-
.where(
|
|
43
|
+
Decidim::Proposals::EvaluationAssignment
|
|
44
|
+
.where(evaluator_role_type: "Decidim::ParticipatoryProcessUserRole")
|
|
45
45
|
.where
|
|
46
|
-
.not(
|
|
46
|
+
.not(evaluator_role_id: Decidim::ParticipatoryProcessUserRole.pluck(:id))
|
|
47
47
|
.destroy_all
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
if Decidim.module_installed?("assemblies")
|
|
51
|
-
Decidim::Proposals::
|
|
52
|
-
.where(
|
|
51
|
+
Decidim::Proposals::EvaluationAssignment
|
|
52
|
+
.where(evaluator_role_type: "Decidim::AssemblyUserRole")
|
|
53
53
|
.where
|
|
54
|
-
.not(
|
|
54
|
+
.not(evaluator_role_id: Decidim::AssemblyUserRole.pluck(:id))
|
|
55
55
|
.destroy_all
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
if Decidim.module_installed?("conferences")
|
|
59
|
-
Decidim::Proposals::
|
|
60
|
-
.where(
|
|
59
|
+
Decidim::Proposals::EvaluationAssignment
|
|
60
|
+
.where(evaluator_role_type: "Decidim::ConferenceUserRole")
|
|
61
61
|
.where
|
|
62
|
-
.not(
|
|
62
|
+
.not(evaluator_role_id: Decidim::ConferenceUserRole.pluck(:id))
|
|
63
63
|
.destroy_all
|
|
64
64
|
end
|
|
65
65
|
end
|