decidim-proposals 0.31.5 → 0.32.0.rc2
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/README.md +4 -14
- data/app/commands/decidim/proposals/admin/merge_proposals.rb +1 -0
- data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +13 -1
- data/app/commands/decidim/proposals/admin/update_proposal_taxonomies.rb +1 -0
- data/app/commands/decidim/proposals/gallery_methods.rb +1 -2
- data/app/commands/decidim/proposals/unvote_proposal.rb +0 -1
- data/app/controllers/concerns/decidim/proposals/admin/filterable.rb +0 -4
- data/app/controllers/concerns/decidim/proposals/orderable.rb +22 -3
- data/app/controllers/decidim/proposals/admin/evaluation_assignments_controller.rb +2 -2
- data/app/controllers/decidim/proposals/admin/participatory_texts_controller.rb +4 -4
- 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 +1 -1
- data/app/controllers/decidim/proposals/invite_coauthors_controller.rb +2 -2
- data/app/controllers/decidim/proposals/proposal_votes_controller.rb +1 -1
- data/app/controllers/decidim/proposals/proposals_controller.rb +30 -8
- data/app/controllers/decidim/proposals/versions_controller.rb +12 -8
- data/app/events/decidim/proposals/admin/proposal_assigned_to_evaluator_event.rb +1 -1
- data/app/events/decidim/proposals/admin/proposal_note_created_event.rb +1 -1
- data/app/forms/decidim/proposals/admin/proposals_import_form.rb +1 -0
- data/app/forms/decidim/proposals/admin/proposals_merge_form.rb +1 -0
- data/app/helpers/decidim/proposals/application_helper.rb +25 -39
- data/app/jobs/decidim/proposals/hide_all_created_by_author_job.rb +0 -3
- data/app/models/decidim/proposals/proposal.rb +42 -13
- data/app/packs/stylesheets/decidim/proposals/proposals.scss +2 -2
- data/app/permissions/decidim/proposals/permissions.rb +1 -58
- data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +0 -4
- data/app/views/decidim/proposals/admin/proposals/show.html.erb +2 -0
- data/app/views/decidim/proposals/proposals/_proposal_aside.html.erb +0 -1
- data/app/views/decidim/proposals/proposals/index.html.erb +1 -8
- data/app/views/decidim/proposals/proposals/show.html.erb +2 -25
- data/app/views/decidim/proposals/versions/show.html.erb +0 -5
- data/config/locales/ar.yml +0 -98
- data/config/locales/bg.yml +0 -98
- data/config/locales/ca-IT.yml +7 -103
- data/config/locales/ca.yml +7 -103
- data/config/locales/cs.yml +0 -107
- data/config/locales/de.yml +0 -103
- data/config/locales/el.yml +0 -95
- data/config/locales/en.yml +7 -103
- data/config/locales/es-MX.yml +7 -103
- data/config/locales/es-PY.yml +7 -103
- data/config/locales/es.yml +7 -103
- data/config/locales/eu.yml +7 -103
- data/config/locales/fi-plain.yml +7 -103
- data/config/locales/fi.yml +7 -103
- data/config/locales/fr-CA.yml +7 -103
- data/config/locales/fr.yml +7 -103
- data/config/locales/ga-IE.yml +0 -32
- data/config/locales/gl.yml +0 -86
- data/config/locales/hu.yml +0 -86
- data/config/locales/id-ID.yml +0 -80
- data/config/locales/is-IS.yml +0 -24
- data/config/locales/it.yml +0 -86
- data/config/locales/ja.yml +7 -101
- data/config/locales/lt.yml +0 -102
- data/config/locales/lv.yml +0 -84
- data/config/locales/nl.yml +0 -84
- data/config/locales/no.yml +0 -84
- data/config/locales/pl.yml +0 -102
- data/config/locales/pt-BR.yml +7 -103
- data/config/locales/pt.yml +0 -86
- data/config/locales/ro-RO.yml +0 -88
- data/config/locales/ru.yml +0 -31
- data/config/locales/sk.yml +7 -107
- data/config/locales/sl.yml +0 -6
- data/config/locales/sv.yml +6 -103
- data/config/locales/tr-TR.yml +0 -86
- data/config/locales/uk.yml +0 -27
- data/config/locales/zh-CN.yml +0 -84
- data/config/locales/zh-TW.yml +0 -93
- data/db/data/20260224210316_remove_collaborative_drafts_references.rb +119 -0
- data/db/migrate/20171212102250_enable_pg_trgm_extension_for_proposals.rb +1 -1
- data/db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb +2 -2
- data/db/migrate/20200306123652_publish_existing_proposals_state.rb +2 -2
- data/db/migrate/20200827154156_add_commentable_counter_cache_to_proposals.rb +12 -4
- data/db/migrate/20210310120812_add_followable_counter_cache_to_collaborative_drafts.rb +6 -2
- data/db/migrate/20250515132352_drop_collaborative_drafts_tables.rb +12 -0
- data/decidim-proposals.gemspec +12 -15
- data/lib/decidim/api/mutations/answer_proposal_attributes.rb +2 -2
- data/lib/decidim/api/mutations/create_proposal_type.rb +52 -0
- data/lib/decidim/api/mutations/proposal_answer_type.rb +7 -15
- data/lib/decidim/api/mutations/proposal_attributes.rb +17 -0
- data/lib/decidim/api/mutations/proposal_mutation_type.rb +4 -0
- data/lib/decidim/api/mutations/proposals_mutation_type.rb +1 -0
- data/lib/decidim/api/mutations/unvote_proposal_type.rb +26 -0
- data/lib/decidim/api/mutations/update_proposal_type.rb +53 -0
- data/lib/decidim/api/mutations/vote_proposal_type.rb +30 -0
- data/lib/decidim/api/mutations/withdraw_proposal_type.rb +31 -0
- data/lib/decidim/api/proposal_type.rb +0 -2
- data/lib/decidim/proposals/api.rb +6 -0
- data/lib/decidim/proposals/commentable_proposal.rb +0 -6
- data/lib/decidim/proposals/component.rb +16 -13
- data/lib/decidim/proposals/engine.rb +0 -14
- data/lib/decidim/proposals/seeds.rb +1 -54
- data/lib/decidim/proposals/test/factories.rb +3 -63
- data/lib/decidim/proposals/version.rb +1 -1
- data/lib/decidim/proposals.rb +9 -8
- metadata +30 -75
- data/app/cells/decidim/proposals/collaborative_draft_cell.rb +0 -49
- data/app/cells/decidim/proposals/collaborative_draft_l_cell.rb +0 -16
- data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal/show.erb +0 -5
- data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +0 -28
- data/app/cells/decidim/proposals/collaborative_draft_metadata_cell.rb +0 -30
- data/app/cells/decidim/proposals/collaborative_drafts/reported_content/show.erb +0 -3
- data/app/cells/decidim/proposals/collaborative_drafts/reported_content_cell.rb +0 -15
- data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +0 -78
- data/app/cells/decidim/proposals/proposal_link_to_collaborative_draft_cell.rb +0 -28
- data/app/commands/decidim/proposals/accept_access_to_collaborative_draft.rb +0 -70
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +0 -85
- data/app/commands/decidim/proposals/publish_collaborative_draft.rb +0 -92
- data/app/commands/decidim/proposals/reject_access_to_collaborative_draft.rb +0 -62
- data/app/commands/decidim/proposals/request_access_to_collaborative_draft.rb +0 -49
- data/app/commands/decidim/proposals/update_collaborative_draft.rb +0 -70
- data/app/commands/decidim/proposals/withdraw_collaborative_draft.rb +0 -65
- data/app/controllers/decidim/proposals/collaborative_draft_collaborator_requests_controller.rb +0 -53
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +0 -152
- data/app/events/decidim/proposals/collaborative_draft_access_accepted_event.rb +0 -8
- data/app/events/decidim/proposals/collaborative_draft_access_rejected_event.rb +0 -8
- data/app/events/decidim/proposals/collaborative_draft_access_request_event.rb +0 -27
- data/app/events/decidim/proposals/collaborative_draft_access_requested_event.rb +0 -8
- data/app/events/decidim/proposals/collaborative_draft_access_requester_accepted_event.rb +0 -8
- data/app/events/decidim/proposals/collaborative_draft_access_requester_rejected_event.rb +0 -8
- data/app/events/decidim/proposals/collaborative_draft_withdrawn_event.rb +0 -33
- data/app/forms/decidim/proposals/accept_access_to_collaborative_draft_form.rb +0 -10
- data/app/forms/decidim/proposals/access_to_collaborative_draft_form.rb +0 -33
- data/app/forms/decidim/proposals/collaborative_draft_form.rb +0 -8
- data/app/forms/decidim/proposals/reject_access_to_collaborative_draft_form.rb +0 -9
- data/app/forms/decidim/proposals/request_access_to_collaborative_draft_form.rb +0 -20
- data/app/helpers/decidim/proposals/collaborative_draft_cells_helper.rb +0 -48
- data/app/helpers/decidim/proposals/collaborative_draft_helper.rb +0 -69
- data/app/models/decidim/proposals/collaborative_draft.rb +0 -79
- data/app/models/decidim/proposals/collaborative_draft_collaborator_request.rb +0 -11
- data/app/presenters/decidim/proposals/collaborative_draft_presenter.rb +0 -20
- data/app/services/decidim/proposals/collaborative_draft_diff_renderer.rb +0 -22
- data/app/views/decidim/proposals/collaborative_drafts/_accept_request_access_form.html.erb +0 -8
- data/app/views/decidim/proposals/collaborative_drafts/_collaborative_actions.html.erb +0 -9
- data/app/views/decidim/proposals/collaborative_drafts/_collaborative_draft_aside.html.erb +0 -38
- data/app/views/decidim/proposals/collaborative_drafts/_collaborative_drafts.html.erb +0 -15
- data/app/views/decidim/proposals/collaborative_drafts/_collaborator_requests.html.erb +0 -16
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +0 -26
- data/app/views/decidim/proposals/collaborative_drafts/_reject_request_access_form.html.erb +0 -8
- data/app/views/decidim/proposals/collaborative_drafts/_request_access_form.html.erb +0 -7
- data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +0 -31
- data/app/views/decidim/proposals/collaborative_drafts/index.html.erb +0 -35
- data/app/views/decidim/proposals/collaborative_drafts/index.js.erb +0 -5
- data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +0 -30
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +0 -74
- data/lib/decidim/proposals/commentable_collaborative_draft.rb +0 -38
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5fc06798927baa41252173d448c8d8cd405218e02eae208975061a6b6a736a87
|
|
4
|
+
data.tar.gz: 021d02221b22c4008ad24667e8f0a1e685aaf90647cdd2dbd1fb3d390c099248
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 021c9c0a741e00b52bfed523c93268e8bd620212a90b9eb03d4e796720aecadbe45cf8235dfa8bd1b80f0ceb08ff80c58b9ef4515f92675d5ebea85b7a43f406
|
|
7
|
+
data.tar.gz: 97027564f5c0183ac1f93614e38212dedb57e7160bd28621e525c86fb81285a8d0894b43e5c728cb2ee2222257d1a736b1dcdee6e2cf0644bd07bac911cabb71
|
data/README.md
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# decidim-proposals
|
|
2
2
|
|
|
3
|
-
The Proposals module adds one of the main components of Decidim: allows users to contribute to a participatory
|
|
3
|
+
The Proposals module adds one of the main components of Decidim: allows users to contribute to a participatory space by creating proposals.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
Proposals will be available as a Component for a Participatory
|
|
7
|
+
Proposals will be available as a Component for a Participatory Space.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```ruby
|
|
14
|
-
gem 'decidim-proposals'
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
And then execute:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
bundle
|
|
21
|
-
```
|
|
11
|
+
This is on the default Decidim installation so you should not change anything to use this component.
|
|
22
12
|
|
|
23
13
|
## Global Search
|
|
24
14
|
|
|
@@ -27,6 +27,7 @@ module Decidim
|
|
|
27
27
|
transaction do
|
|
28
28
|
increment_score
|
|
29
29
|
notify_followers
|
|
30
|
+
notify_authors
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
|
|
@@ -48,11 +49,22 @@ module Decidim
|
|
|
48
49
|
event: "decidim.events.proposals.proposal_state_changed",
|
|
49
50
|
event_class: Decidim::Proposals::ProposalStateChangedEvent,
|
|
50
51
|
resource: proposal,
|
|
51
|
-
affected_users: proposal.notifiable_identities,
|
|
52
52
|
followers: proposal.followers - proposal.notifiable_identities
|
|
53
53
|
)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
+
def notify_authors
|
|
57
|
+
return if proposal.state == "not_answered"
|
|
58
|
+
|
|
59
|
+
Decidim::EventsManager.publish(
|
|
60
|
+
event: "decidim.events.proposals.proposal_state_changed_for_authors",
|
|
61
|
+
event_class: Decidim::Proposals::ProposalStateChangedEvent,
|
|
62
|
+
resource: proposal,
|
|
63
|
+
affected_users: proposal.authors,
|
|
64
|
+
extra: { force_email: true }
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
56
68
|
def increment_score
|
|
57
69
|
if proposal.accepted?
|
|
58
70
|
proposal.coauthorships.find_each do |coauthorship|
|
|
@@ -6,6 +6,7 @@ module Decidim
|
|
|
6
6
|
# A command with all the business logic when an admin batch updates proposals taxonomies.
|
|
7
7
|
class UpdateProposalTaxonomies < UpdateResourcesTaxonomies
|
|
8
8
|
include TranslatableAttributes
|
|
9
|
+
|
|
9
10
|
# Public: Initializes the command.
|
|
10
11
|
#
|
|
11
12
|
# taxonomy_ids - the taxonomy ids to update
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Proposals
|
|
5
|
-
# A module with all the gallery common methods for proposals
|
|
6
|
-
# and collaborative draft commands.
|
|
5
|
+
# A module with all the gallery common methods for proposals commands.
|
|
7
6
|
# Allows to create several image attachments at once
|
|
8
7
|
module GalleryMethods
|
|
9
8
|
include ::Decidim::GalleryMethods
|
|
@@ -32,10 +32,6 @@ module Decidim
|
|
|
32
32
|
collection.with_evaluation_assigned_to(current_user, current_participatory_space)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def search_field_predicate
|
|
36
|
-
:id_string_or_title_cont
|
|
37
|
-
end
|
|
38
|
-
|
|
39
35
|
def filter_config
|
|
40
36
|
@filter_config ||= Decidim::AdminFilter.new(:proposals).build_for(self)
|
|
41
37
|
end
|
|
@@ -22,9 +22,10 @@ module Decidim
|
|
|
22
22
|
@possible_orders ||= begin
|
|
23
23
|
possible_orders = %w(random recent)
|
|
24
24
|
possible_orders << "most_voted" if most_voted_order_available?
|
|
25
|
-
possible_orders << "most_liked" if
|
|
26
|
-
possible_orders << "most_commented" if
|
|
27
|
-
possible_orders << "most_followed"
|
|
25
|
+
possible_orders << "most_liked" if most_liked_order_available?
|
|
26
|
+
possible_orders << "most_commented" if most_commented_order_available?
|
|
27
|
+
possible_orders << "most_followed" # always shown, as the author automatically follows their proposals
|
|
28
|
+
possible_orders << "with_more_authors" if with_more_authors_order_available?
|
|
28
29
|
possible_orders
|
|
29
30
|
end
|
|
30
31
|
end
|
|
@@ -52,6 +53,24 @@ module Decidim
|
|
|
52
53
|
current_settings.votes_enabled? && !current_settings.votes_hidden?
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
def with_more_authors_order_available?
|
|
57
|
+
return @with_more_authors_order_available if defined?(@with_more_authors_order_available)
|
|
58
|
+
|
|
59
|
+
@with_more_authors_order_available = Decidim::Proposals::Proposal.with_more_authors_available?(current_component)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def most_commented_order_available?
|
|
63
|
+
return @most_commented_order_available if defined?(@most_commented_order_available)
|
|
64
|
+
|
|
65
|
+
@most_commented_order_available = Decidim::Proposals::Proposal.most_commented_available?(current_component)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def most_liked_order_available?
|
|
69
|
+
return @most_liked_order_available if defined?(@most_liked_order_available)
|
|
70
|
+
|
|
71
|
+
@most_liked_order_available = Decidim::Proposals::Proposal.most_liked_available?(current_component)
|
|
72
|
+
end
|
|
73
|
+
|
|
55
74
|
def order_by_votes?
|
|
56
75
|
most_voted_order_available? && current_settings.votes_blocked?
|
|
57
76
|
end
|
|
@@ -34,12 +34,12 @@ module Decidim
|
|
|
34
34
|
Admin::UnassignProposalsFromEvaluator.call(@form) do
|
|
35
35
|
on(:ok) do |_proposal|
|
|
36
36
|
flash.keep[:notice] = I18n.t("evaluation_assignments.delete.success", scope: "decidim.proposals.admin")
|
|
37
|
-
|
|
37
|
+
redirect_back_or_to(EngineRouter.admin_proxy(current_component).root_path)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
on(:invalid) do
|
|
41
41
|
flash.keep[:alert] = I18n.t("evaluation_assignments.delete.invalid", scope: "decidim.proposals.admin")
|
|
42
|
-
|
|
42
|
+
redirect_back_or_to(EngineRouter.admin_proxy(current_component).root_path)
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -32,12 +32,12 @@ module Decidim
|
|
|
32
32
|
|
|
33
33
|
on(:invalid) do
|
|
34
34
|
flash.now[:alert] = I18n.t("participatory_texts.import.invalid", scope: "decidim.proposals.admin")
|
|
35
|
-
render action: "new_import", status: :
|
|
35
|
+
render action: "new_import", status: :unprocessable_content
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
on(:invalid_file) do
|
|
39
39
|
flash.now[:alert] = I18n.t("participatory_texts.import.invalid_file", scope: "decidim.proposals.admin")
|
|
40
|
-
render action: "new_import", status: :
|
|
40
|
+
render action: "new_import", status: :unprocessable_content
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -62,7 +62,7 @@ module Decidim
|
|
|
62
62
|
failures.each_pair { |id, msg| alert_msg << "ID:[#{id}] #{msg}" }
|
|
63
63
|
flash.now[:alert] = alert_msg.join("<br/>").html_safe
|
|
64
64
|
index
|
|
65
|
-
render action: "index", status: :
|
|
65
|
+
render action: "index", status: :unprocessable_content
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
else
|
|
@@ -77,7 +77,7 @@ module Decidim
|
|
|
77
77
|
failures.each_pair { |id, msg| alert_msg << "ID:[#{id}] #{msg}" }
|
|
78
78
|
flash.now[:alert] = alert_msg.join("<br/>").html_safe
|
|
79
79
|
index
|
|
80
|
-
render action: "index", status: :
|
|
80
|
+
render action: "index", status: :unprocessable_content
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
end
|
|
@@ -34,7 +34,7 @@ module Decidim
|
|
|
34
34
|
|
|
35
35
|
on(:invalid) do
|
|
36
36
|
flash.keep[:alert] = I18n.t("proposals.answer.invalid", scope: "decidim.proposals.admin")
|
|
37
|
-
render template: "decidim/proposals/admin/proposals/show", status: :
|
|
37
|
+
render template: "decidim/proposals/admin/proposals/show", status: :unprocessable_content
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -30,7 +30,7 @@ module Decidim
|
|
|
30
30
|
on(:invalid) do
|
|
31
31
|
flash.keep[:alert] = I18n.t("proposal_states.create.error", scope: "decidim.proposals.admin")
|
|
32
32
|
|
|
33
|
-
render action: :new, status: :
|
|
33
|
+
render action: :new, status: :unprocessable_content
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -54,7 +54,7 @@ module Decidim
|
|
|
54
54
|
on(:invalid) do
|
|
55
55
|
flash.now[:alert] = I18n.t("proposal_states.update.error", scope: "decidim.proposals.admin")
|
|
56
56
|
|
|
57
|
-
render action: :edit, status: :
|
|
57
|
+
render action: :edit, status: :unprocessable_content
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
end
|
|
@@ -44,7 +44,7 @@ module Decidim
|
|
|
44
44
|
|
|
45
45
|
on(:invalid) do
|
|
46
46
|
flash.now[:alert] = I18n.t("proposals.create.invalid", scope: "decidim.proposals.admin")
|
|
47
|
-
render action: "new", status: :
|
|
47
|
+
render action: "new", status: :unprocessable_content
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -129,7 +129,7 @@ module Decidim
|
|
|
129
129
|
|
|
130
130
|
on(:invalid) do
|
|
131
131
|
flash.now[:alert] = t("proposals.update.error", scope: "decidim")
|
|
132
|
-
render :edit, status: :
|
|
132
|
+
render :edit, status: :unprocessable_content
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
end
|
|
@@ -23,7 +23,7 @@ module Decidim
|
|
|
23
23
|
|
|
24
24
|
on(:invalid) do
|
|
25
25
|
flash.now[:alert] = I18n.t("proposals_imports.create.invalid", scope: "decidim.proposals.admin")
|
|
26
|
-
render action: "new", status: :
|
|
26
|
+
render action: "new", status: :unprocessable_content
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -53,7 +53,7 @@ module Decidim
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
on(:invalid) do
|
|
56
|
-
render json: { message: I18n.t("update.error", scope: "decidim.proposals.invite_coauthors") }, status: :
|
|
56
|
+
render json: { message: I18n.t("update.error", scope: "decidim.proposals.invite_coauthors") }, status: :unprocessable_content
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -68,7 +68,7 @@ module Decidim
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
on(:invalid) do
|
|
71
|
-
render json: { message: I18n.t("destroy.error", scope: "decidim.proposals.invite_coauthors") }, status: :
|
|
71
|
+
render json: { message: I18n.t("destroy.error", scope: "decidim.proposals.invite_coauthors") }, status: :unprocessable_content
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
end
|
|
@@ -29,7 +29,7 @@ module Decidim
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
on(:invalid) do
|
|
32
|
-
render json: { error: I18n.t("proposal_votes.create.error", scope: "decidim.proposals") }, status: :
|
|
32
|
+
render json: { error: I18n.t("proposal_votes.create.error", scope: "decidim.proposals") }, status: :unprocessable_content
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -20,7 +20,7 @@ module Decidim
|
|
|
20
20
|
|
|
21
21
|
before_action :authenticate_user!, only: [:new, :create]
|
|
22
22
|
before_action :ensure_is_draft, only: [:preview, :publish, :edit_draft, :update_draft, :destroy_draft]
|
|
23
|
-
before_action :
|
|
23
|
+
before_action :proposal, only: [:show, :edit, :update, :withdraw]
|
|
24
24
|
before_action :edit_form, only: [:edit_draft, :edit]
|
|
25
25
|
before_action :set_view_mode, only: [:index]
|
|
26
26
|
|
|
@@ -79,7 +79,7 @@ module Decidim
|
|
|
79
79
|
|
|
80
80
|
on(:invalid) do
|
|
81
81
|
flash.now[:alert] = I18n.t("proposals.create.error", scope: "decidim")
|
|
82
|
-
render :new, status: :
|
|
82
|
+
render :new, status: :unprocessable_content
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
end
|
|
@@ -101,7 +101,7 @@ module Decidim
|
|
|
101
101
|
|
|
102
102
|
on(:invalid) do
|
|
103
103
|
flash.now[:alert] = I18n.t("proposals.publish.error", scope: "decidim")
|
|
104
|
-
render :edit_draft, status: :
|
|
104
|
+
render :edit_draft, status: :unprocessable_content
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
end
|
|
@@ -124,7 +124,7 @@ module Decidim
|
|
|
124
124
|
|
|
125
125
|
on(:invalid) do
|
|
126
126
|
flash.now[:alert] = I18n.t("proposals.update_draft.error", scope: "decidim")
|
|
127
|
-
render :edit_draft, status: :
|
|
127
|
+
render :edit_draft, status: :unprocessable_content
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
end
|
|
@@ -140,7 +140,7 @@ module Decidim
|
|
|
140
140
|
|
|
141
141
|
on(:invalid) do
|
|
142
142
|
flash.now[:alert] = I18n.t("proposals.destroy_draft.error", scope: "decidim")
|
|
143
|
-
render :edit_draft, status: :
|
|
143
|
+
render :edit_draft, status: :unprocessable_content
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
end
|
|
@@ -161,7 +161,7 @@ module Decidim
|
|
|
161
161
|
|
|
162
162
|
on(:invalid) do
|
|
163
163
|
flash.now[:alert] = I18n.t("proposals.update.error", scope: "decidim")
|
|
164
|
-
render :edit, status: :
|
|
164
|
+
render :edit, status: :unprocessable_content
|
|
165
165
|
end
|
|
166
166
|
end
|
|
167
167
|
end
|
|
@@ -216,8 +216,8 @@ module Decidim
|
|
|
216
216
|
redirect_to Decidim::ResourceLocatorPresenter.new(@proposal).path unless @proposal.draft?
|
|
217
217
|
end
|
|
218
218
|
|
|
219
|
-
def
|
|
220
|
-
@proposal
|
|
219
|
+
def proposal
|
|
220
|
+
@proposal ||= Proposal.published.not_hidden.where(component: current_component).find_by(id: params[:id])
|
|
221
221
|
end
|
|
222
222
|
|
|
223
223
|
# Returns true if the proposal is NOT an emendation or the user IS an admin.
|
|
@@ -295,6 +295,28 @@ module Decidim
|
|
|
295
295
|
def default_view_mode
|
|
296
296
|
@default_view_mode ||= current_component.settings.attachments_allowed? ? "grid" : "list"
|
|
297
297
|
end
|
|
298
|
+
|
|
299
|
+
def add_parent_breadcrumb_item
|
|
300
|
+
return {} if proposal.blank?
|
|
301
|
+
|
|
302
|
+
object = proposal.emendation? ? proposal.amendable : proposal
|
|
303
|
+
{
|
|
304
|
+
label: translated_attribute(object.title),
|
|
305
|
+
url: Decidim::EngineRouter.main_proxy(current_component).proposal_path(object),
|
|
306
|
+
active: false
|
|
307
|
+
}
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def add_breadcrumb_item
|
|
311
|
+
return {} if proposal.blank?
|
|
312
|
+
return {} if proposal.amendable?
|
|
313
|
+
|
|
314
|
+
{
|
|
315
|
+
label: I18n.t("decidim.amendments.name"),
|
|
316
|
+
url: Decidim::EngineRouter.main_proxy(current_component).proposal_path(proposal),
|
|
317
|
+
active: false
|
|
318
|
+
}
|
|
319
|
+
end
|
|
298
320
|
end
|
|
299
321
|
end
|
|
300
322
|
end
|
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Proposals
|
|
5
|
-
# Exposes Proposals versions so users can see how a Proposal
|
|
6
|
-
# has been updated through time.
|
|
5
|
+
# Exposes Proposals versions so users can see how a Proposal has been updated through time.
|
|
7
6
|
class VersionsController < Decidim::Proposals::ApplicationController
|
|
8
7
|
include Decidim::ApplicationHelper
|
|
9
8
|
include Decidim::ResourceVersionsConcern
|
|
10
9
|
|
|
11
10
|
def versioned_resource
|
|
12
|
-
@versioned_resource ||=
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
@versioned_resource ||= Proposal.not_hidden.published.where(component: current_component).find(params[:proposal_id])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def add_breadcrumb_item
|
|
15
|
+
return {} if versioned_resource.blank?
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
label: translated_attribute(versioned_resource.title),
|
|
19
|
+
url: Decidim::EngineRouter.main_proxy(current_component).proposal_path(versioned_resource),
|
|
20
|
+
active: false
|
|
21
|
+
}
|
|
18
22
|
end
|
|
19
23
|
end
|
|
20
24
|
end
|
|
@@ -8,6 +8,7 @@ module Decidim
|
|
|
8
8
|
class ProposalsMergeForm < ProposalBaseForm
|
|
9
9
|
include Decidim::HasUploadValidations
|
|
10
10
|
include Decidim::AttachmentAttributes
|
|
11
|
+
|
|
11
12
|
translatable_attribute :title, String do |field, _locale|
|
|
12
13
|
validates field, length: { in: 15..150 }, if: proc { |resource| resource.send(field).present? }
|
|
13
14
|
end
|
|
@@ -12,7 +12,6 @@ module Decidim
|
|
|
12
12
|
include ::Decidim::FollowableHelper
|
|
13
13
|
include Decidim::MapHelper
|
|
14
14
|
include Decidim::Proposals::MapHelper
|
|
15
|
-
include CollaborativeDraftHelper
|
|
16
15
|
include ControlVersionHelper
|
|
17
16
|
include Decidim::RichTextEditorHelper
|
|
18
17
|
include Decidim::CheckBoxesTreeHelper
|
|
@@ -54,49 +53,19 @@ module Decidim
|
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
|
|
57
|
-
# Public: The state of a proposal in a way a human can understand.
|
|
58
|
-
#
|
|
59
|
-
# state - The String state of the proposal.
|
|
60
|
-
#
|
|
61
|
-
# Returns a String.
|
|
62
|
-
def humanize_collaborative_draft_state(state)
|
|
63
|
-
I18n.t("decidim.proposals.collaborative_drafts.states.#{state}", default: :open)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Public: The css class applied based on the collaborative draft state.
|
|
67
|
-
#
|
|
68
|
-
# state - The String state of the collaborative draft.
|
|
69
|
-
#
|
|
70
|
-
# Returns a String.
|
|
71
|
-
def collaborative_draft_state_badge_css_class(state)
|
|
72
|
-
case state
|
|
73
|
-
when "open"
|
|
74
|
-
"success"
|
|
75
|
-
when "withdrawn"
|
|
76
|
-
"alert"
|
|
77
|
-
when "published"
|
|
78
|
-
"secondary"
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
56
|
def proposal_limit_enabled?
|
|
83
57
|
proposal_limit.present?
|
|
84
58
|
end
|
|
85
59
|
|
|
86
|
-
def not_from_collaborative_draft(proposal)
|
|
87
|
-
proposal.linked_resources(:proposals, "created_from_collaborative_draft").empty?
|
|
88
|
-
end
|
|
89
|
-
|
|
90
60
|
def not_from_participatory_text(proposal)
|
|
91
61
|
proposal.participatory_text_level.nil?
|
|
92
62
|
end
|
|
93
63
|
|
|
94
64
|
# If the proposal is official or the rich text editor is enabled on the
|
|
95
65
|
# frontend, the proposal body is considered as safe content; that is unless
|
|
96
|
-
# the proposal comes from a
|
|
66
|
+
# safe_content_admin? is used and the proposal comes from a participatory text.
|
|
97
67
|
def safe_content?
|
|
98
|
-
|
|
99
|
-
safe_content_admin?
|
|
68
|
+
rich_text_editor_in_public_views? || safe_content_admin?
|
|
100
69
|
end
|
|
101
70
|
|
|
102
71
|
# For admin entered content, the proposal body can contain certain extra
|
|
@@ -203,26 +172,43 @@ module Decidim
|
|
|
203
172
|
@filter_sections ||= begin
|
|
204
173
|
items = []
|
|
205
174
|
if component_settings.proposal_answering_enabled && current_settings.proposal_answering_enabled
|
|
206
|
-
items.append(method: :with_any_state, collection: filter_proposals_state_values, label: t("decidim.proposals.proposals.filters.state"),
|
|
175
|
+
items.append(method: :with_any_state, name: "[with_any_state]", collection: filter_proposals_state_values, label: t("decidim.proposals.proposals.filters.state"),
|
|
176
|
+
id: "state")
|
|
207
177
|
end
|
|
208
178
|
current_component.available_taxonomy_filters.each do |taxonomy_filter|
|
|
209
|
-
items.append(method:
|
|
179
|
+
items.append(method: :with_any_taxonomies,
|
|
180
|
+
name: "[with_any_taxonomies][#{taxonomy_filter.root_taxonomy_id}]",
|
|
210
181
|
collection: filter_taxonomy_values_for(taxonomy_filter),
|
|
211
182
|
label: decidim_sanitize_translated(taxonomy_filter.name),
|
|
212
183
|
id: "taxonomy-#{taxonomy_filter.root_taxonomy_id}")
|
|
213
184
|
end
|
|
214
185
|
if component_settings.official_proposals_enabled
|
|
215
|
-
items.append(method: :with_any_origin,
|
|
186
|
+
items.append(method: :with_any_origin,
|
|
187
|
+
name: "[with_any_origin]",
|
|
188
|
+
collection: filter_origin_values,
|
|
189
|
+
label: t("decidim.proposals.proposals.filters.origin"),
|
|
190
|
+
id: "origin")
|
|
216
191
|
end
|
|
217
192
|
if current_user
|
|
218
|
-
items.append(method: :activity,
|
|
193
|
+
items.append(method: :activity,
|
|
194
|
+
name: "[activity]",
|
|
195
|
+
collection: activity_filter_values,
|
|
196
|
+
label: t("decidim.proposals.proposals.filters.activity"),
|
|
197
|
+
id: "activity",
|
|
198
|
+
type: :radio_buttons)
|
|
219
199
|
end
|
|
220
200
|
if @proposals.only_emendations.any?
|
|
221
|
-
items.append(method: :type,
|
|
201
|
+
items.append(method: :type,
|
|
202
|
+
name: "[type]",
|
|
203
|
+
collection: filter_type_values,
|
|
204
|
+
label: t("decidim.proposals.proposals.filters.amendment_type"),
|
|
205
|
+
id: "amendment_type",
|
|
206
|
+
type: :radio_buttons)
|
|
222
207
|
end
|
|
223
208
|
if linked_classes_for(Decidim::Proposals::Proposal).any?
|
|
224
209
|
items.append(
|
|
225
210
|
method: :related_to,
|
|
211
|
+
name: "[related_to]",
|
|
226
212
|
collection: linked_classes_filter_values_for(Decidim::Proposals::Proposal),
|
|
227
213
|
label: t("decidim.proposals.proposals.filters.related_to"),
|
|
228
214
|
id: "related_to",
|
|
@@ -235,7 +221,7 @@ module Decidim
|
|
|
235
221
|
end
|
|
236
222
|
|
|
237
223
|
def component_name
|
|
238
|
-
i18n_key =
|
|
224
|
+
i18n_key = "decidim.components.proposals.name"
|
|
239
225
|
(defined?(current_component) && translated_attribute(current_component&.name).presence) || t(i18n_key)
|
|
240
226
|
end
|
|
241
227
|
|
|
@@ -11,9 +11,6 @@ module Decidim
|
|
|
11
11
|
Decidim::Proposals::Proposal.not_hidden.from_author(resource).find_each do |content|
|
|
12
12
|
hide_content(content, extra[:event_author], extra[:justification])
|
|
13
13
|
end
|
|
14
|
-
Decidim::Proposals::CollaborativeDraft.not_hidden.from_author(resource).find_each do |content|
|
|
15
|
-
hide_content(content, extra[:event_author], extra[:justification])
|
|
16
|
-
end
|
|
17
14
|
end
|
|
18
15
|
end
|
|
19
16
|
end
|