decidim-proposals 0.26.0 → 0.27.0.rc1
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/collaborative_draft_cell.rb +1 -1
- data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +9 -1
- data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_m_cell.rb +8 -8
- data/app/commands/decidim/proposals/accept_access_to_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/admin/answer_proposal.rb +8 -3
- data/app/commands/decidim/proposals/admin/assign_proposals_to_valuator.rb +1 -1
- data/app/commands/decidim/proposals/admin/create_proposal.rb +9 -3
- 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 +9 -3
- 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/hashtags_methods.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/collaborative_draft_withdrawn_event.rb +5 -1
- data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +4 -4
- data/app/forms/decidim/proposals/admin/proposal_answer_form.rb +1 -1
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +5 -5
- 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 +5 -7
- data/app/helpers/decidim/proposals/proposal_cells_helper.rb +1 -3
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +7 -7
- 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 +53 -8
- data/app/permissions/decidim/proposals/admin/permissions.rb +3 -0
- 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/proposal_answers/_form.html.erb +1 -1
- 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/_proposal_similar.html.erb +1 -1
- 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/index.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/new.html.erb +3 -1
- data/app/views/decidim/proposals/proposals/show.html.erb +3 -3
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +3 -18
- data/config/locales/bg.yml +1 -16
- data/config/locales/ca.yml +23 -18
- data/config/locales/cs.yml +23 -18
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +1 -22
- data/config/locales/el.yml +1 -18
- data/config/locales/en.yml +23 -19
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +23 -18
- data/config/locales/es-PY.yml +23 -18
- data/config/locales/es.yml +24 -19
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +1 -22
- data/config/locales/fi-plain.yml +23 -18
- data/config/locales/fi.yml +25 -20
- data/config/locales/fr-CA.yml +22 -18
- data/config/locales/fr.yml +37 -33
- data/config/locales/ga-IE.yml +1 -2
- data/config/locales/gl.yml +8 -22
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +9 -18
- data/config/locales/id-ID.yml +1 -18
- data/config/locales/is-IS.yml +2 -3
- data/config/locales/it.yml +2 -22
- data/config/locales/ja.yml +24 -19
- data/config/locales/ko.yml +1 -0
- data/config/locales/lb.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +1 -18
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +2 -22
- data/config/locales/no.yml +1 -18
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +1 -22
- data/config/locales/pt-BR.yml +2 -23
- data/config/locales/pt.yml +1 -22
- data/config/locales/ro-RO.yml +2 -22
- data/config/locales/ru.yml +1 -2
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +1 -18
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -0
- data/config/locales/sv.yml +10 -27
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +1 -22
- data/config/locales/uk.yml +1 -2
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +1 -21
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20180529110230_move_authorships_to_coauthorships.rb +1 -0
- data/lib/decidim/content_parsers/proposal_parser.rb +7 -63
- data/lib/decidim/content_renderers/proposal_renderer.rb +3 -19
- data/lib/decidim/proposals/component.rb +22 -16
- data/lib/decidim/proposals/import/proposal_answer_creator.rb +21 -19
- data/lib/decidim/proposals/import/proposal_creator.rb +4 -1
- 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: cf760d1ce319c8806519053c5b3bfe6d48aaa1d91b11f81c0e7fde8b4d6398e4
|
4
|
+
data.tar.gz: 12707f653b6cca47f62a8f34c8204dc8de6a1078fa681a2dd68b6ef89cafb979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55cd9f8ec704001e24cc90dc1d0be2a4153e4a1f2d003b68793924b91e0ffce786726b13e91664304b9dea9d26b2b18c844e9cd1e894962b1762a3a55004136f
|
7
|
+
data.tar.gz: b2f3f6e9760b568fbcee9d4e1cbc0ae724b16430731719c743bf90d8424600724a340aaa5d9788fb4a191a17f08f997c3011d3476bf9fabde5ac35602e726e70
|
@@ -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
|
@@ -122,7 +120,7 @@ module Decidim
|
|
122
120
|
end
|
123
121
|
|
124
122
|
def resource_image_path
|
125
|
-
@resource_image_path ||= has_image? ? model.attachments.find_by("content_type like '%image%'").
|
123
|
+
@resource_image_path ||= has_image? ? model.attachments.find_by("content_type like '%image%'").thumbnail_url : nil
|
126
124
|
end
|
127
125
|
|
128
126
|
def cache_hash
|
@@ -143,6 +141,8 @@ module Decidim
|
|
143
141
|
hash << Digest::MD5.hexdigest(model.authors.map(&:cache_key_with_version).to_s)
|
144
142
|
hash << (model.must_render_translation?(model.organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
|
145
143
|
hash << model.component.participatory_space.active_step.id if model.component.participatory_space.try(:active_step)
|
144
|
+
hash << has_footer?
|
145
|
+
hash << has_actions?
|
146
146
|
|
147
147
|
hash.join(Decidim.cache_key_separator)
|
148
148
|
end
|
@@ -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.
|
@@ -46,13 +46,18 @@ module Decidim
|
|
46
46
|
attributes = {
|
47
47
|
state: form.state,
|
48
48
|
answer: form.answer,
|
49
|
-
answered_at: Time.current,
|
50
49
|
cost: form.cost,
|
51
50
|
cost_report: form.cost_report,
|
52
51
|
execution_period: form.execution_period
|
53
52
|
}
|
54
53
|
|
55
|
-
|
54
|
+
if form.state == "not_answered"
|
55
|
+
attributes[:answered_at] = nil
|
56
|
+
attributes[:state_published_at] = nil
|
57
|
+
else
|
58
|
+
attributes[:answered_at] = Time.current
|
59
|
+
attributes[:state_published_at] = Time.current if !initial_has_state_published && form.publish_answer?
|
60
|
+
end
|
56
61
|
|
57
62
|
proposal.update!(attributes)
|
58
63
|
end
|
@@ -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
|
@@ -61,7 +61,7 @@ module Decidim
|
|
61
61
|
|
62
62
|
def attributes
|
63
63
|
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
|
64
|
-
parsed_body = Decidim::ContentProcessor.
|
64
|
+
parsed_body = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite
|
65
65
|
{
|
66
66
|
title: parsed_title,
|
67
67
|
body: parsed_body,
|
@@ -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
|
|
@@ -59,7 +59,7 @@ module Decidim
|
|
59
59
|
|
60
60
|
def update_proposal
|
61
61
|
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
|
62
|
-
parsed_body = Decidim::ContentProcessor.
|
62
|
+
parsed_body = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite
|
63
63
|
Decidim.traceability.update!(
|
64
64
|
proposal,
|
65
65
|
form.current_user,
|
@@ -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.
|
@@ -13,7 +13,7 @@ module Decidim
|
|
13
13
|
|
14
14
|
def body_with_hashtags
|
15
15
|
@body_with_hashtags ||= begin
|
16
|
-
ret = Decidim::ContentProcessor.
|
16
|
+
ret = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite.strip
|
17
17
|
ret += "\n#{body_extra_hashtags.strip}" unless body_extra_hashtags.empty?
|
18
18
|
ret
|
19
19
|
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 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
|
|