decidim-proposals 0.26.2 → 0.27.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +9 -1
- data/app/cells/decidim/proposals/proposal_m_cell.rb +5 -7
- data/app/commands/decidim/proposals/accept_access_to_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/admin/answer_proposal.rb +1 -1
- data/app/commands/decidim/proposals/admin/assign_proposals_to_valuator.rb +1 -1
- data/app/commands/decidim/proposals/admin/create_proposal.rb +8 -2
- data/app/commands/decidim/proposals/admin/create_proposal_note.rb +2 -2
- data/app/commands/decidim/proposals/admin/discard_participatory_text.rb +1 -1
- data/app/commands/decidim/proposals/admin/import_participatory_text.rb +1 -1
- data/app/commands/decidim/proposals/admin/import_proposals.rb +1 -1
- data/app/commands/decidim/proposals/admin/merge_proposals.rb +1 -1
- data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +1 -1
- data/app/commands/decidim/proposals/admin/publish_answers.rb +1 -1
- data/app/commands/decidim/proposals/admin/split_proposals.rb +1 -1
- data/app/commands/decidim/proposals/admin/unassign_proposals_from_valuator.rb +1 -1
- data/app/commands/decidim/proposals/admin/update_participatory_text.rb +1 -1
- data/app/commands/decidim/proposals/admin/update_proposal.rb +8 -2
- data/app/commands/decidim/proposals/admin/update_proposal_category.rb +5 -3
- data/app/commands/decidim/proposals/admin/update_proposal_scope.rb +3 -3
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +5 -5
- data/app/commands/decidim/proposals/create_proposal.rb +1 -1
- data/app/commands/decidim/proposals/destroy_proposal.rb +1 -1
- data/app/commands/decidim/proposals/publish_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/publish_proposal.rb +1 -1
- data/app/commands/decidim/proposals/reject_access_to_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/request_access_to_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/unvote_proposal.rb +1 -1
- data/app/commands/decidim/proposals/update_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/update_proposal.rb +8 -2
- data/app/commands/decidim/proposals/vote_proposal.rb +1 -1
- data/app/commands/decidim/proposals/withdraw_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/withdraw_proposal.rb +1 -1
- data/app/controllers/concerns/decidim/proposals/orderable.rb +7 -5
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +7 -7
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +8 -8
- data/app/controllers/decidim/proposals/proposal_votes_controller.rb +1 -1
- data/app/controllers/decidim/proposals/proposals_controller.rb +24 -17
- data/app/events/decidim/proposals/publish_proposal_event.rb +8 -0
- data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +4 -4
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +4 -4
- data/app/forms/decidim/proposals/admin/proposal_form.rb +2 -0
- data/app/forms/decidim/proposals/admin/proposals_fork_form.rb +2 -2
- data/app/forms/decidim/proposals/admin/proposals_import_form.rb +1 -1
- data/app/forms/decidim/proposals/proposal_form.rb +11 -4
- data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +3 -0
- data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +4 -0
- data/app/helpers/decidim/proposals/application_helper.rb +4 -6
- data/app/helpers/decidim/proposals/proposal_cells_helper.rb +1 -3
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +7 -7
- data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +1 -1
- data/app/models/decidim/proposals/collaborative_draft.rb +10 -0
- data/app/models/decidim/proposals/collaborative_draft_collaborator_request.rb +0 -2
- data/app/models/decidim/proposals/proposal.rb +47 -8
- data/app/queries/decidim/proposals/filtered_proposals.rb +1 -1
- data/app/queries/decidim/proposals/similar_proposals.rb +1 -1
- data/app/services/decidim/proposals/proposal_search.rb +16 -71
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/publish_answers.js.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/update_attribute.js.erb +26 -0
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +8 -16
- data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +4 -4
- data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +3 -1
- data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +3 -1
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +13 -36
- data/app/views/decidim/proposals/proposals/_filters.html.erb +5 -5
- data/app/views/decidim/proposals/proposals/_proposals.html.erb +5 -5
- data/app/views/decidim/proposals/proposals/complete.html.erb +3 -1
- data/app/views/decidim/proposals/proposals/edit.html.erb +3 -1
- data/app/views/decidim/proposals/proposals/edit_draft.html.erb +3 -1
- data/app/views/decidim/proposals/proposals/new.html.erb +3 -1
- data/config/locales/ar.yml +1 -9
- data/config/locales/bg.yml +1 -4
- data/config/locales/ca.yml +13 -8
- data/config/locales/cs.yml +12 -7
- data/config/locales/de.yml +54 -6
- data/config/locales/el.yml +1 -6
- data/config/locales/en.yml +10 -6
- data/config/locales/es-MX.yml +12 -7
- data/config/locales/es-PY.yml +12 -7
- data/config/locales/es.yml +12 -7
- data/config/locales/eu.yml +1 -9
- data/config/locales/fi-plain.yml +11 -6
- data/config/locales/fi.yml +11 -6
- data/config/locales/fr-CA.yml +12 -6
- data/config/locales/fr.yml +12 -6
- data/config/locales/ga-IE.yml +1 -2
- data/config/locales/gl.yml +8 -9
- data/config/locales/hu.yml +8 -6
- data/config/locales/id-ID.yml +1 -5
- data/config/locales/is-IS.yml +2 -2
- data/config/locales/it.yml +2 -9
- data/config/locales/ja.yml +11 -6
- data/config/locales/lb.yml +1 -0
- data/config/locales/lt.yml +996 -0
- data/config/locales/lv.yml +1 -6
- data/config/locales/nl.yml +2 -9
- data/config/locales/no.yml +1 -6
- data/config/locales/pl.yml +1 -9
- data/config/locales/pt-BR.yml +1 -9
- data/config/locales/pt.yml +1 -9
- data/config/locales/ro-RO.yml +2 -9
- data/config/locales/ru.yml +1 -1
- data/config/locales/sk.yml +1 -6
- data/config/locales/sl.yml +1 -0
- data/config/locales/sr-CS.yml +1 -2
- data/config/locales/sv.yml +8 -12
- data/config/locales/tr-TR.yml +1 -9
- data/config/locales/uk.yml +1 -1
- data/config/locales/zh-CN.yml +1 -9
- data/db/migrate/20180529110230_move_authorships_to_coauthorships.rb +1 -0
- data/lib/decidim/proposals/component.rb +19 -14
- data/lib/decidim/proposals/import/proposal_answer_creator.rb +21 -19
- data/lib/decidim/proposals/test/factories.rb +1 -1
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +25 -28
- data/app/services/decidim/proposals/collaborative_draft_search.rb +0 -59
- data/app/views/decidim/proposals/admin/proposals/_js-callout.html.erb +0 -6
- data/app/views/decidim/proposals/admin/proposals/update_category.js.erb +0 -26
- data/app/views/decidim/proposals/admin/proposals/update_scope.js.erb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea49596f347de94f5b94dc0cbece8ba4e8133082ec29279e7d42c8714e32410a
|
4
|
+
data.tar.gz: b03d6e8966b54192f3b072b75927b21c731de2aed19a304ddac65b78459277d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 015b389d3c2adbcbfe3207afeaad76189b8addd3be3fedf5b82ba795afa0b919051df8c7ad889b05135e0b875de6812fc16dcbf32eb4fcbdf0447cad1e866906
|
7
|
+
data.tar.gz: a47beb0b91ca549953af0bd9d02ba96eba2a5b1b44a7341ef90acac42772bd93bd26a455724a0d9e47f71e982095474fdaa0e3899e5e6c38fd4f50aab1c15ac0
|
@@ -19,7 +19,7 @@ module Decidim
|
|
19
19
|
def proposals
|
20
20
|
@proposals ||= Decidim::Proposals::Proposal.published.not_hidden.except_withdrawn
|
21
21
|
.where(component: model)
|
22
|
-
.order_randomly(rand * 2 - 1)
|
22
|
+
.order_randomly((rand * 2) - 1)
|
23
23
|
end
|
24
24
|
|
25
25
|
def proposals_to_render
|
@@ -29,6 +29,14 @@ module Decidim
|
|
29
29
|
def proposals_count
|
30
30
|
@proposals_count ||= proposals.count
|
31
31
|
end
|
32
|
+
|
33
|
+
def cache_hash
|
34
|
+
hash = []
|
35
|
+
hash << "decidim/proposals/highlighted_proposals_for_component"
|
36
|
+
hash << proposals.cache_key_with_version
|
37
|
+
hash << I18n.locale.to_s
|
38
|
+
hash.join(Decidim.cache_key_separator)
|
39
|
+
end
|
32
40
|
end
|
33
41
|
end
|
34
42
|
end
|
@@ -57,13 +57,11 @@ module Decidim
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def base_statuses
|
60
|
-
@base_statuses ||=
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
60
|
+
@base_statuses ||= if endorsements_visible?
|
61
|
+
[:endorsements_count, :comments_count]
|
62
|
+
else
|
63
|
+
[:comments_count]
|
64
|
+
end
|
67
65
|
end
|
68
66
|
|
69
67
|
def statuses
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic to accept a user request to
|
6
6
|
# contribute to a collaborative draft.
|
7
|
-
class AcceptAccessToCollaborativeDraft <
|
7
|
+
class AcceptAccessToCollaborativeDraft < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# form - A form object with the params.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin answers a proposal.
|
7
|
-
class AnswerProposal <
|
7
|
+
class AnswerProposal < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# form - A form object with the params.
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic to assign proposals to a given
|
7
7
|
# valuator.
|
8
|
-
class AssignProposalsToValuator <
|
8
|
+
class AssignProposalsToValuator < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when a user creates a new proposal.
|
7
|
-
class CreateProposal <
|
7
|
+
class CreateProposal < Decidim::Command
|
8
8
|
include ::Decidim::AttachmentMethods
|
9
9
|
include GalleryMethods
|
10
10
|
include HashtagsMethods
|
@@ -37,8 +37,8 @@ module Decidim
|
|
37
37
|
|
38
38
|
transaction do
|
39
39
|
create_proposal
|
40
|
-
create_attachment if process_attachments?
|
41
40
|
create_gallery if process_gallery?
|
41
|
+
create_attachment(weight: first_attachment_weight) if process_attachments?
|
42
42
|
link_author_meeeting if form.created_in_meeting?
|
43
43
|
send_notification
|
44
44
|
end
|
@@ -91,6 +91,12 @@ module Decidim
|
|
91
91
|
}
|
92
92
|
)
|
93
93
|
end
|
94
|
+
|
95
|
+
def first_attachment_weight
|
96
|
+
return 1 if proposal.photos.count.zero?
|
97
|
+
|
98
|
+
proposal.photos.count
|
99
|
+
end
|
94
100
|
end
|
95
101
|
end
|
96
102
|
end
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin creates a private note proposal.
|
7
|
-
class CreateProposalNote <
|
7
|
+
class CreateProposalNote < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# form - A form object with the params.
|
@@ -59,7 +59,7 @@ module Decidim
|
|
59
59
|
affected_users: affected_users
|
60
60
|
}
|
61
61
|
|
62
|
-
Decidim::EventsManager.publish(data)
|
62
|
+
Decidim::EventsManager.publish(**data)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic related with an admin discarding participatory text proposals.
|
7
|
-
class DiscardParticipatoryText <
|
7
|
+
class DiscardParticipatoryText < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# form - A PreviewParticipatoryTextForm form object with the params.
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin imports proposals from
|
7
7
|
# a participatory text.
|
8
|
-
class ImportParticipatoryText <
|
8
|
+
class ImportParticipatoryText < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin imports proposals from
|
7
7
|
# one component to another.
|
8
|
-
class ImportProposals <
|
8
|
+
class ImportProposals < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin merges proposals from
|
7
7
|
# one component to another.
|
8
|
-
class MergeProposals <
|
8
|
+
class MergeProposals < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command to notify about the change of the published state for a proposal.
|
7
|
-
class NotifyProposalAnswer <
|
7
|
+
class NotifyProposalAnswer < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# proposal - The proposal to write the answer for.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic to publish many answers at once.
|
7
|
-
class PublishAnswers <
|
7
|
+
class PublishAnswers < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# component - The component that contains the answers.
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin splits proposals from
|
7
7
|
# one component to another.
|
8
|
-
class SplitProposals <
|
8
|
+
class SplitProposals < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic to unassign proposals from a given
|
7
7
|
# valuator.
|
8
|
-
class UnassignProposalsFromValuator <
|
8
|
+
class UnassignProposalsFromValuator < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin updates participatory text proposals.
|
7
|
-
class UpdateParticipatoryText <
|
7
|
+
class UpdateParticipatoryText < Decidim::Command
|
8
8
|
include Decidim::TranslatableAttributes
|
9
9
|
|
10
10
|
# Public: Initializes the command.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when a user updates a proposal.
|
7
|
-
class UpdateProposal <
|
7
|
+
class UpdateProposal < Decidim::Command
|
8
8
|
include ::Decidim::AttachmentMethods
|
9
9
|
include GalleryMethods
|
10
10
|
include HashtagsMethods
|
@@ -45,8 +45,8 @@ module Decidim
|
|
45
45
|
transaction do
|
46
46
|
update_proposal
|
47
47
|
update_proposal_author
|
48
|
-
create_attachment if process_attachments?
|
49
48
|
create_gallery if process_gallery?
|
49
|
+
create_attachment(weight: first_attachment_weight) if process_attachments?
|
50
50
|
photo_cleanup!
|
51
51
|
end
|
52
52
|
|
@@ -80,6 +80,12 @@ module Decidim
|
|
80
80
|
proposal.save!
|
81
81
|
proposal
|
82
82
|
end
|
83
|
+
|
84
|
+
def first_attachment_weight
|
85
|
+
return 1 if proposal.photos.count.zero?
|
86
|
+
|
87
|
+
proposal.photos.count
|
88
|
+
end
|
83
89
|
end
|
84
90
|
end
|
85
91
|
end
|
@@ -4,7 +4,9 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin batch updates proposals category.
|
7
|
-
class UpdateProposalCategory <
|
7
|
+
class UpdateProposalCategory < Decidim::Command
|
8
|
+
include TranslatableAttributes
|
9
|
+
|
8
10
|
# Public: Initializes the command.
|
9
11
|
#
|
10
12
|
# category_id - the category id to update
|
@@ -33,13 +35,13 @@ module Decidim
|
|
33
35
|
@response[:category_name] = @category.translated_name
|
34
36
|
Proposal.where(id: @proposal_ids).find_each do |proposal|
|
35
37
|
if @category == proposal.category
|
36
|
-
@response[:errored] << proposal.title
|
38
|
+
@response[:errored] << translated_attribute(proposal.title)
|
37
39
|
else
|
38
40
|
transaction do
|
39
41
|
update_proposal_category proposal
|
40
42
|
notify_author proposal if proposal.coauthorships.any?
|
41
43
|
end
|
42
|
-
@response[:successful] << proposal.title
|
44
|
+
@response[:successful] << translated_attribute(proposal.title)
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when an admin batch updates proposals scope.
|
7
|
-
class UpdateProposalScope <
|
7
|
+
class UpdateProposalScope < Decidim::Command
|
8
8
|
include TranslatableAttributes
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
@@ -44,13 +44,13 @@ module Decidim
|
|
44
44
|
@response[:scope_name] = translated_attribute(scope.name, scope.organization)
|
45
45
|
Proposal.where(id: proposal_ids).find_each do |proposal|
|
46
46
|
if scope == proposal.scope
|
47
|
-
@response[:errored] << proposal.title
|
47
|
+
@response[:errored] << translated_attribute(proposal.title)
|
48
48
|
else
|
49
49
|
transaction do
|
50
50
|
update_proposal_scope proposal
|
51
51
|
notify_author proposal if proposal.coauthorships.any?
|
52
52
|
end
|
53
|
-
@response[:successful] << proposal.title
|
53
|
+
@response[:successful] << translated_attribute(proposal.title)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user creates a new collaborative draft.
|
6
|
-
class CreateCollaborativeDraft <
|
7
|
-
include ::Decidim::
|
6
|
+
class CreateCollaborativeDraft < Decidim::Command
|
7
|
+
include ::Decidim::MultipleAttachmentsMethods
|
8
8
|
include HashtagsMethods
|
9
9
|
|
10
10
|
# Public: Initializes the command.
|
@@ -27,13 +27,13 @@ module Decidim
|
|
27
27
|
return broadcast(:invalid) if form.invalid?
|
28
28
|
|
29
29
|
if process_attachments?
|
30
|
-
|
31
|
-
return broadcast(:invalid) if
|
30
|
+
build_attachments
|
31
|
+
return broadcast(:invalid) if attachments_invalid?
|
32
32
|
end
|
33
33
|
|
34
34
|
transaction do
|
35
35
|
create_collaborative_draft
|
36
|
-
|
36
|
+
create_attachments if process_attachments?
|
37
37
|
end
|
38
38
|
|
39
39
|
broadcast(:ok, collaborative_draft)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user destroys a draft proposal.
|
6
|
-
class DestroyProposal <
|
6
|
+
class DestroyProposal < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# proposal - The proposal to destroy.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user publishes a collaborative_draft.
|
6
|
-
class PublishCollaborativeDraft <
|
6
|
+
class PublishCollaborativeDraft < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# collaborative_draft - The collaborative_draft to publish.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user publishes a draft proposal.
|
6
|
-
class PublishProposal <
|
6
|
+
class PublishProposal < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# proposal - The proposal to publish.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic to reject a user request to
|
6
6
|
# contribute to a collaborative draft.
|
7
|
-
class RejectAccessToCollaborativeDraft <
|
7
|
+
class RejectAccessToCollaborativeDraft < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# form - A form object with the params.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user requests access
|
6
6
|
# to edit a collaborative draft.
|
7
|
-
class RequestAccessToCollaborativeDraft <
|
7
|
+
class RequestAccessToCollaborativeDraft < Decidim::Command
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# form - A form object with the params.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user unvotes a proposal.
|
6
|
-
class UnvoteProposal <
|
6
|
+
class UnvoteProposal < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# proposal - A Decidim::Proposals::Proposal object.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user updates a collaborative_draft.
|
6
|
-
class UpdateCollaborativeDraft <
|
6
|
+
class UpdateCollaborativeDraft < Decidim::Command
|
7
7
|
include HashtagsMethods
|
8
8
|
|
9
9
|
# Public: Initializes the command.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user updates a proposal.
|
6
|
-
class UpdateProposal <
|
6
|
+
class UpdateProposal < Decidim::Command
|
7
7
|
include ::Decidim::MultipleAttachmentsMethods
|
8
8
|
include GalleryMethods
|
9
9
|
include HashtagsMethods
|
@@ -50,7 +50,7 @@ module Decidim
|
|
50
50
|
document_cleanup!
|
51
51
|
|
52
52
|
create_gallery if process_gallery?
|
53
|
-
create_attachments if process_attachments?
|
53
|
+
create_attachments(first_weight: first_attachment_weight) if process_attachments?
|
54
54
|
end
|
55
55
|
|
56
56
|
broadcast(:ok, proposal)
|
@@ -116,6 +116,12 @@ module Decidim
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
def first_attachment_weight
|
120
|
+
return 1 if proposal.photos.count.zero?
|
121
|
+
|
122
|
+
proposal.photos.count
|
123
|
+
end
|
124
|
+
|
119
125
|
def user_group
|
120
126
|
@user_group ||= Decidim::UserGroup.find_by(organization: organization, id: form.user_group_id)
|
121
127
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user votes a proposal.
|
6
|
-
class VoteProposal <
|
6
|
+
class VoteProposal < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# proposal - A Decidim::Proposals::Proposal object.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user withdraws a collaborative_draft.
|
6
|
-
class WithdrawCollaborativeDraft <
|
6
|
+
class WithdrawCollaborativeDraft < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# collaborative_draft - The collaborative_draft to withdraw.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user withdraws a new proposal.
|
6
|
-
class WithdrawProposal <
|
6
|
+
class WithdrawProposal < Decidim::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# proposal - The proposal to withdraw.
|
@@ -30,12 +30,14 @@ module Decidim
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def default_order
|
33
|
-
@default_order ||=
|
34
|
-
|
35
|
-
return order_by_default if default_order == "default"
|
33
|
+
@default_order ||= fetch_default_order
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
36
|
+
def fetch_default_order
|
37
|
+
default_order = current_settings.default_sort_order.presence || component_settings.default_sort_order
|
38
|
+
return order_by_default if default_order == "default"
|
39
|
+
|
40
|
+
possible_orders.include?(default_order) ? default_order : order_by_default
|
39
41
|
end
|
40
42
|
|
41
43
|
def order_by_default
|
@@ -65,9 +65,10 @@ module Decidim
|
|
65
65
|
flash.now[:notice] = update_proposals_bulk_response_successful(@response, :category)
|
66
66
|
flash.now[:alert] = update_proposals_bulk_response_errored(@response, :category)
|
67
67
|
end
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
end
|
69
|
+
|
70
|
+
respond_to do |format|
|
71
|
+
format.js { render :update_attribute, locals: { form_selector: "#js-form-recategorize-projects", attribute_selector: "#category_id" } }
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -114,10 +115,9 @@ module Decidim
|
|
114
115
|
flash.now[:notice] = update_proposals_bulk_response_successful(@response, :scope)
|
115
116
|
flash.now[:alert] = update_proposals_bulk_response_errored(@response, :scope)
|
116
117
|
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
end
|
118
|
+
end
|
119
|
+
respond_to do |format|
|
120
|
+
format.js { render :update_attribute, locals: { form_selector: "#js-form-scope-change-projects", attribute_selector: "#scope_id" } }
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -25,7 +25,7 @@ module Decidim
|
|
25
25
|
|
26
26
|
def index
|
27
27
|
@collaborative_drafts = search
|
28
|
-
.
|
28
|
+
.result
|
29
29
|
.not_hidden
|
30
30
|
.includes(:category)
|
31
31
|
.includes(:scope)
|
@@ -134,19 +134,19 @@ module Decidim
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def geocoded_collaborative_draft
|
137
|
-
@geocoded_collaborative_draft ||= search.
|
137
|
+
@geocoded_collaborative_draft ||= search.result.not_hidden.select(&:geocoded_and_valid?)
|
138
138
|
end
|
139
139
|
|
140
|
-
def
|
141
|
-
|
140
|
+
def search_collection
|
141
|
+
CollaborativeDraft.where(component: current_component).not_hidden
|
142
142
|
end
|
143
143
|
|
144
144
|
def default_filter_params
|
145
145
|
{
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
146
|
+
search_text_cont: "",
|
147
|
+
with_any_category: default_filter_category_params,
|
148
|
+
with_any_state: %w(open),
|
149
|
+
with_any_scope: default_filter_scope_params,
|
150
150
|
related_to: ""
|
151
151
|
}
|
152
152
|
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
# Exposes the proposal vote resource so users can vote proposals.
|
6
6
|
class ProposalVotesController < Decidim::Proposals::ApplicationController
|
7
7
|
include ProposalVotesHelper
|
8
|
-
include
|
8
|
+
include Decidim::ControllerHelpers
|
9
9
|
|
10
10
|
helper_method :proposal
|
11
11
|
|