decidim-proposals 0.10.1 → 0.11.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +3 -3
- data/app/assets/javascripts/decidim/proposals/admin/proposals.es6 +6 -7
- data/app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6 +17 -17
- data/app/assets/javascripts/decidim/proposals/utils.js.es6 +2 -2
- data/app/commands/decidim/proposals/admin/create_proposal.rb +2 -2
- data/app/commands/decidim/proposals/admin/import_proposals.rb +16 -8
- data/app/commands/decidim/proposals/create_proposal.rb +6 -6
- data/app/commands/decidim/proposals/destroy_proposal.rb +33 -0
- data/app/commands/decidim/proposals/update_proposal.rb +4 -4
- data/app/controllers/decidim/proposals/admin/application_controller.rb +2 -2
- data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
- data/app/controllers/decidim/proposals/admin/proposals_imports_controller.rb +4 -4
- data/app/controllers/decidim/proposals/application_controller.rb +5 -5
- data/app/controllers/decidim/proposals/proposal_endorsements_controller.rb +1 -1
- data/app/controllers/decidim/proposals/proposal_votes_controller.rb +1 -1
- data/app/controllers/decidim/proposals/proposal_widgets_controller.rb +1 -1
- data/app/controllers/decidim/proposals/proposals_controller.rb +52 -24
- data/app/events/decidim/proposals/proposal_mentioned_event.rb +19 -0
- data/app/forms/decidim/proposals/admin/proposal_form.rb +3 -3
- data/app/forms/decidim/proposals/admin/proposals_import_form.rb +9 -9
- data/app/forms/decidim/proposals/proposal_form.rb +5 -4
- data/app/helpers/decidim/proposals/application_helper.rb +38 -3
- data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +7 -3
- data/app/helpers/decidim/proposals/proposal_votes_helper.rb +9 -9
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +2 -1
- data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +28 -0
- data/app/jobs/decidim/proposals/settings_change_job.rb +4 -4
- data/app/models/decidim/proposals/abilities/admin_ability.rb +4 -4
- data/app/models/decidim/proposals/abilities/current_user_ability.rb +12 -12
- data/app/models/decidim/proposals/abilities/participatory_process_admin_ability.rb +8 -8
- data/app/models/decidim/proposals/abilities/participatory_process_moderator_ability.rb +1 -1
- data/app/models/decidim/proposals/proposal.rb +7 -7
- data/app/models/decidim/proposals/proposal_endorsement.rb +6 -2
- data/app/presenters/decidim/proposals/proposal_presenter.rb +12 -0
- data/app/queries/decidim/proposals/filtered_proposals.rb +9 -9
- data/app/queries/decidim/proposals/similar_proposals.rb +9 -9
- data/app/services/decidim/proposals/proposal_search.rb +1 -1
- data/app/types/decidim/proposals/proposal_type.rb +17 -2
- data/app/types/decidim/proposals/proposals_type.rb +6 -6
- data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +1 -1
- data/app/views/decidim/participatory_processes/participatory_process_groups/_proposal.html.erb +1 -1
- data/app/views/decidim/participatory_spaces/_highlighted_proposals.html.erb +2 -2
- data/app/views/decidim/participatory_spaces/_proposal.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +2 -2
- data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposal_notes/index.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +2 -2
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/new.html.erb +2 -2
- data/app/views/decidim/proposals/admin/proposals/update_category.js.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +3 -3
- data/app/views/decidim/proposals/admin/shared/_info_proposal.html.erb +1 -1
- data/app/views/decidim/proposals/proposal_endorsements/_identity.html.erb +2 -2
- data/app/views/decidim/proposals/proposal_endorsements/identities.html.erb +2 -2
- data/app/views/decidim/proposals/proposal_endorsements/update_buttons_and_counters.js.erb +19 -8
- data/app/views/decidim/proposals/proposals/_endorsement_button.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_endorsement_identities_cabin.html.erb +3 -3
- data/app/views/decidim/proposals/proposals/_endorsements_card_row.html.erb +4 -4
- data/app/views/decidim/proposals/proposals/_endorsements_count.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_filters.html.erb +10 -10
- data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_identities_listing.html.erb +30 -0
- data/app/views/decidim/proposals/proposals/{_endorsement_xxs.html.erb → _identity_xxs.html.erb} +1 -2
- data/app/views/decidim/proposals/proposals/_proposal.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_tags.html.erb +25 -0
- data/app/views/decidim/proposals/proposals/_vote_button.html.erb +7 -7
- data/app/views/decidim/proposals/proposals/_votes_count.html.erb +6 -5
- data/app/views/decidim/proposals/proposals/_voting_rules.html.erb +7 -7
- data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +5 -5
- data/app/views/decidim/proposals/proposals/compare.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/complete.html.erb +70 -0
- data/app/views/decidim/proposals/proposals/edit.html.erb +3 -3
- data/app/views/decidim/proposals/proposals/edit_draft.html.erb +5 -3
- data/app/views/decidim/proposals/proposals/index.html.erb +5 -5
- data/app/views/decidim/proposals/proposals/new.html.erb +1 -43
- data/app/views/decidim/proposals/proposals/preview.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/show.html.erb +16 -23
- data/config/locales/ca.yml +69 -55
- data/config/locales/en.yml +64 -50
- data/config/locales/es.yml +73 -59
- data/config/locales/eu.yml +64 -50
- data/config/locales/fi.yml +64 -50
- data/config/locales/fr.yml +75 -61
- data/config/locales/gl.yml +64 -50
- data/config/locales/it.yml +64 -50
- data/config/locales/nl.yml +153 -139
- data/config/locales/pl.yml +64 -50
- data/config/locales/pt-BR.yml +64 -50
- data/config/locales/pt.yml +64 -50
- data/config/locales/ru.yml +0 -9
- data/config/locales/sv.yml +64 -50
- data/config/locales/uk.yml +2 -16
- data/db/migrate/20171212102250_enable_pg_extensions.rb +12 -1
- data/db/migrate/20180305133811_rename_features_to_components_at_proposals.rb +11 -0
- data/db/migrate/20180413135249_fix_nil_threshold_per_proposal.rb +18 -0
- data/lib/decidim/content_parsers/proposal_parser.rb +95 -0
- data/lib/decidim/content_renderers/proposal_renderer.rb +33 -0
- data/lib/decidim/proposals.rb +9 -1
- data/lib/decidim/proposals/commentable_proposal.rb +3 -3
- data/lib/decidim/proposals/{feature.rb → component.rb} +39 -38
- data/lib/decidim/proposals/engine.rb +21 -6
- data/lib/decidim/proposals/proposal_serializer.rb +3 -3
- data/lib/decidim/proposals/test/factories.rb +5 -8
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +32 -23
- data/app/views/decidim/proposals/proposals/_endorsements_listing.html.erb +0 -34
@@ -12,8 +12,8 @@ module Decidim
|
|
12
12
|
include Paginable
|
13
13
|
|
14
14
|
helper_method :geocoded_proposals
|
15
|
-
before_action :authenticate_user!, only: [:new, :create]
|
16
|
-
before_action :ensure_is_draft, only: [:
|
15
|
+
before_action :authenticate_user!, only: [:new, :create, :complete]
|
16
|
+
before_action :ensure_is_draft, only: [:preview, :publish, :edit_draft, :update_draft, :destroy_draft]
|
17
17
|
|
18
18
|
def index
|
19
19
|
@proposals = search
|
@@ -38,7 +38,7 @@ module Decidim
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def show
|
41
|
-
@proposal = Proposal.published.not_hidden.where(
|
41
|
+
@proposal = Proposal.published.not_hidden.where(component: current_component).find(params[:id])
|
42
42
|
@report_form = form(Decidim::ReportForm).from_params(reason: "spam")
|
43
43
|
end
|
44
44
|
|
@@ -46,29 +46,27 @@ module Decidim
|
|
46
46
|
authorize! :create, Proposal
|
47
47
|
@step = :step_1
|
48
48
|
if proposal_draft.present?
|
49
|
-
redirect_to edit_draft_proposal_path(proposal_draft,
|
49
|
+
redirect_to edit_draft_proposal_path(proposal_draft, component_id: proposal_draft.component.id, question_slug: proposal_draft.component.participatory_space.slug)
|
50
50
|
else
|
51
|
-
@form = form(ProposalForm).from_params(
|
52
|
-
attachment: form(AttachmentForm).from_params({})
|
53
|
-
)
|
51
|
+
@form = form(ProposalForm).from_params(params)
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
57
55
|
def create
|
58
56
|
authorize! :create, Proposal
|
59
|
-
@step = :
|
57
|
+
@step = :step_3
|
60
58
|
@form = form(ProposalForm).from_params(params)
|
61
59
|
|
62
60
|
CreateProposal.call(@form, current_user) do
|
63
61
|
on(:ok) do |proposal|
|
64
62
|
flash[:notice] = I18n.t("proposals.create.success", scope: "decidim")
|
65
|
-
|
66
|
-
redirect_to
|
63
|
+
|
64
|
+
redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path + "/preview"
|
67
65
|
end
|
68
66
|
|
69
67
|
on(:invalid) do
|
70
68
|
flash.now[:alert] = I18n.t("proposals.create.error", scope: "decidim")
|
71
|
-
render :
|
69
|
+
render :complete
|
72
70
|
end
|
73
71
|
end
|
74
72
|
end
|
@@ -76,25 +74,39 @@ module Decidim
|
|
76
74
|
def compare
|
77
75
|
@step = :step_2
|
78
76
|
@similar_proposals ||= Decidim::Proposals::SimilarProposals
|
79
|
-
.for(
|
77
|
+
.for(current_component, params[:proposal])
|
80
78
|
.all
|
79
|
+
@form = form(ProposalForm).from_params(params)
|
81
80
|
|
82
81
|
if @similar_proposals.blank?
|
83
82
|
flash[:notice] = I18n.t("proposals.proposals.compare.no_similars_found", scope: "decidim")
|
84
|
-
redirect_to
|
83
|
+
redirect_to complete_proposals_path(proposal: { title: @form.title, body: @form.body })
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
88
|
-
def
|
87
|
+
def complete
|
88
|
+
authorize! :create, Proposal
|
89
89
|
@step = :step_3
|
90
|
+
if params[:proposal].present?
|
91
|
+
params[:proposal][:attachment] = form(AttachmentForm).from_params({})
|
92
|
+
@form = form(ProposalForm).from_params(params)
|
93
|
+
else
|
94
|
+
@form = form(ProposalForm).from_params(
|
95
|
+
attachment: form(AttachmentForm).from_params({})
|
96
|
+
)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def preview
|
101
|
+
@step = :step_4
|
90
102
|
end
|
91
103
|
|
92
104
|
def publish
|
93
|
-
@step = :
|
105
|
+
@step = :step_4
|
94
106
|
PublishProposal.call(@proposal, current_user) do
|
95
|
-
on(:ok) do
|
107
|
+
on(:ok) do
|
96
108
|
flash[:notice] = I18n.t("proposals.publish.success", scope: "decidim")
|
97
|
-
redirect_to proposal_path(proposal)
|
109
|
+
redirect_to proposal_path(@proposal)
|
98
110
|
end
|
99
111
|
|
100
112
|
on(:invalid) do
|
@@ -105,7 +117,7 @@ module Decidim
|
|
105
117
|
end
|
106
118
|
|
107
119
|
def edit_draft
|
108
|
-
@step = :
|
120
|
+
@step = :step_3
|
109
121
|
authorize! :edit, Proposal
|
110
122
|
|
111
123
|
@form = form(ProposalForm).from_model(@proposal)
|
@@ -119,7 +131,7 @@ module Decidim
|
|
119
131
|
UpdateProposal.call(@form, current_user, @proposal) do
|
120
132
|
on(:ok) do |proposal|
|
121
133
|
flash[:notice] = I18n.t("proposals.update_draft.success", scope: "decidim")
|
122
|
-
redirect_to
|
134
|
+
redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path + "/preview"
|
123
135
|
end
|
124
136
|
|
125
137
|
on(:invalid) do
|
@@ -129,15 +141,31 @@ module Decidim
|
|
129
141
|
end
|
130
142
|
end
|
131
143
|
|
144
|
+
def destroy_draft
|
145
|
+
authorize! :edit, Proposal
|
146
|
+
|
147
|
+
DestroyProposal.call(@proposal, current_user) do
|
148
|
+
on(:ok) do
|
149
|
+
flash[:notice] = I18n.t("proposals.destroy_draft.success", scope: "decidim")
|
150
|
+
redirect_to new_proposal_path
|
151
|
+
end
|
152
|
+
|
153
|
+
on(:invalid) do
|
154
|
+
flash.now[:alert] = I18n.t("proposals.destroy_draft.error", scope: "decidim")
|
155
|
+
render :edit_draft
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
132
160
|
def edit
|
133
|
-
@proposal = Proposal.published.not_hidden.where(
|
161
|
+
@proposal = Proposal.published.not_hidden.where(component: current_component).find(params[:id])
|
134
162
|
authorize! :edit, @proposal
|
135
163
|
|
136
164
|
@form = form(ProposalForm).from_model(@proposal)
|
137
165
|
end
|
138
166
|
|
139
167
|
def update
|
140
|
-
@proposal = Proposal.not_hidden.where(
|
168
|
+
@proposal = Proposal.not_hidden.where(component: current_component).find(params[:id])
|
141
169
|
authorize! :edit, @proposal
|
142
170
|
|
143
171
|
@form = form(ProposalForm).from_params(params)
|
@@ -155,7 +183,7 @@ module Decidim
|
|
155
183
|
end
|
156
184
|
|
157
185
|
def withdraw
|
158
|
-
@proposal = Proposal.published.not_hidden.where(
|
186
|
+
@proposal = Proposal.published.not_hidden.where(component: current_component).find(params[:id])
|
159
187
|
authorize! :withdraw, @proposal
|
160
188
|
|
161
189
|
WithdrawProposal.call(@proposal, current_user) do
|
@@ -193,11 +221,11 @@ module Decidim
|
|
193
221
|
end
|
194
222
|
|
195
223
|
def proposal_draft
|
196
|
-
Proposal.not_hidden.where(
|
224
|
+
Proposal.not_hidden.where(component: current_component, author: current_user).find_by(published_at: nil)
|
197
225
|
end
|
198
226
|
|
199
227
|
def ensure_is_draft
|
200
|
-
@proposal = Proposal.not_hidden.where(
|
228
|
+
@proposal = Proposal.not_hidden.where(component: current_component).find(params[:id])
|
201
229
|
redirect_to Decidim::ResourceLocatorPresenter.new(@proposal).path unless @proposal.draft?
|
202
230
|
end
|
203
231
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
class ProposalMentionedEvent < Decidim::Events::SimpleEvent
|
6
|
+
i18n_attributes :mentioned_proposal_title
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def mentioned_proposal_title
|
11
|
+
mentioned_proposal.title
|
12
|
+
end
|
13
|
+
|
14
|
+
def mentioned_proposal
|
15
|
+
@mentioned_proposal ||= Decidim::Proposals::Proposal.find(extra[:mentioned_proposal_id])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -17,13 +17,13 @@ module Decidim
|
|
17
17
|
attribute :attachment, AttachmentForm
|
18
18
|
|
19
19
|
validates :title, :body, presence: true
|
20
|
-
validates :address, geocoding: true, if: -> {
|
20
|
+
validates :address, geocoding: true, if: -> { current_component.settings.geocoding_enabled? }
|
21
21
|
validates :category, presence: true, if: ->(form) { form.category_id.present? }
|
22
22
|
validates :scope, presence: true, if: ->(form) { form.scope_id.present? }
|
23
23
|
|
24
24
|
validate :scope_belongs_to_participatory_space_scope
|
25
25
|
|
26
|
-
delegate :categories, to: :
|
26
|
+
delegate :categories, to: :current_component
|
27
27
|
|
28
28
|
def map_model(model)
|
29
29
|
return unless model.categorization
|
@@ -31,7 +31,7 @@ module Decidim
|
|
31
31
|
self.category_id = model.categorization.decidim_category_id
|
32
32
|
end
|
33
33
|
|
34
|
-
alias
|
34
|
+
alias component current_component
|
35
35
|
|
36
36
|
# Finds the Category from the category_id.
|
37
37
|
#
|
@@ -8,11 +8,11 @@ module Decidim
|
|
8
8
|
class ProposalsImportForm < Decidim::Form
|
9
9
|
mimic :proposals_import
|
10
10
|
|
11
|
-
attribute :
|
11
|
+
attribute :origin_component_id, Integer
|
12
12
|
attribute :import_proposals, Boolean
|
13
13
|
attribute :states, Array
|
14
14
|
|
15
|
-
validates :
|
15
|
+
validates :origin_component_id, :origin_component, :states, :current_component, presence: true
|
16
16
|
validates :import_proposals, allow_nil: false, acceptance: true
|
17
17
|
validate :valid_states
|
18
18
|
|
@@ -31,17 +31,17 @@ module Decidim
|
|
31
31
|
super.reject(&:blank?)
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
@
|
34
|
+
def origin_component
|
35
|
+
@origin_component ||= origin_components.find_by(id: origin_component_id)
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
@
|
38
|
+
def origin_components
|
39
|
+
@origin_components ||= current_participatory_space.components.where.not(id: current_component.id).where(manifest_name: :proposals)
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
|
44
|
-
[
|
42
|
+
def origin_components_collection
|
43
|
+
origin_components.map do |component|
|
44
|
+
[component.name[I18n.locale.to_s], component.id]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -26,15 +26,16 @@ module Decidim
|
|
26
26
|
validate :proposal_length
|
27
27
|
validate :scope_belongs_to_participatory_space_scope
|
28
28
|
|
29
|
-
delegate :categories, to: :
|
29
|
+
delegate :categories, to: :current_component
|
30
30
|
|
31
31
|
def map_model(model)
|
32
|
+
self.user_group_id = model.decidim_user_group_id
|
32
33
|
return unless model.categorization
|
33
34
|
|
34
35
|
self.category_id = model.categorization.decidim_category_id
|
35
36
|
end
|
36
37
|
|
37
|
-
alias
|
38
|
+
alias component current_component
|
38
39
|
# Finds the Category from the category_id.
|
39
40
|
#
|
40
41
|
# Returns a Decidim::Category
|
@@ -57,14 +58,14 @@ module Decidim
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def has_address?
|
60
|
-
|
61
|
+
current_component.settings.geocoding_enabled? && has_address
|
61
62
|
end
|
62
63
|
|
63
64
|
private
|
64
65
|
|
65
66
|
def proposal_length
|
66
67
|
return unless body.presence
|
67
|
-
length =
|
68
|
+
length = current_component.settings.proposal_length
|
68
69
|
errors.add(:body, :too_long, count: length) if body.length > length
|
69
70
|
end
|
70
71
|
|
@@ -63,13 +63,48 @@ module Decidim
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def proposal_limit
|
66
|
-
return if
|
66
|
+
return if component_settings.proposal_limit.zero?
|
67
67
|
|
68
|
-
|
68
|
+
component_settings.proposal_limit
|
69
69
|
end
|
70
70
|
|
71
71
|
def current_user_proposals
|
72
|
-
Proposal.where(
|
72
|
+
Proposal.where(component: current_component, author: current_user)
|
73
|
+
end
|
74
|
+
|
75
|
+
def follow_button_for(model)
|
76
|
+
if current_user
|
77
|
+
render partial: "decidim/shared/follow_button", locals: { followable: model }
|
78
|
+
else
|
79
|
+
content_tag(:p, class: "mt-s mb-none") do
|
80
|
+
t("decidim.proposals.proposals.show.sign_in_or_up",
|
81
|
+
in: link_to(t("decidim.proposals.proposals.show.sign_in"), decidim.new_user_session_path),
|
82
|
+
up: link_to(t("decidim.proposals.proposals.show.sign_up"), decidim.new_user_registration_path)).html_safe
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Public - A widget that lists all identities in an xxs card format.
|
88
|
+
# Shows the first 5 identities and hides the rest, but presents a 'see all'
|
89
|
+
# button to make the rest of identities visible.
|
90
|
+
#
|
91
|
+
# @param identities: The list of identities. Each item must have a user_group or author method.
|
92
|
+
# @param widget_id: Mandatory when placing more than 1 widget in a page, optional otherwise. Is the id
|
93
|
+
# uniquely identify this widget in the page.
|
94
|
+
#
|
95
|
+
def identities_list_xxs(identities, widget_id = "identities-xxs")
|
96
|
+
widget_ids = {
|
97
|
+
ellipsis: "#{widget_id}-ellipsis",
|
98
|
+
remaining_identities: "#{widget_id}-remaining-identities",
|
99
|
+
see_all_identities: "#{widget_id}-see-all-identities"
|
100
|
+
}
|
101
|
+
render partial: "identities_listing", locals: { identities: identities, widget_ids: widget_ids }
|
102
|
+
end
|
103
|
+
|
104
|
+
def identities_xxs(identities)
|
105
|
+
identities.collect do |identity|
|
106
|
+
render partial: "identity_xxs", locals: { identity: identity.normalized_author }
|
107
|
+
end.join(", ").html_safe
|
73
108
|
end
|
74
109
|
end
|
75
110
|
end
|
@@ -52,8 +52,12 @@ module Decidim
|
|
52
52
|
endorsements_enabled?
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
|
55
|
+
def endorsement_identity_presenter(endorsement)
|
56
|
+
if endorsement.user_group
|
57
|
+
Decidim::UserGroupPresenter.new(endorsement.user_group)
|
58
|
+
else
|
59
|
+
Decidim::UserPresenter.new(endorsement.author)
|
60
|
+
end
|
57
61
|
end
|
58
62
|
|
59
63
|
# Public: Renders a button to endorse the given proposal.
|
@@ -67,7 +71,7 @@ module Decidim
|
|
67
71
|
from_proposals_list: from_proposals_list,
|
68
72
|
user_group_id: user_group&.id
|
69
73
|
)
|
70
|
-
endorse_label = btn_label || t(".endorse")
|
74
|
+
endorse_label = btn_label || t("decidim.proposals.proposal_endorsements_helper.endorsement_button.endorse")
|
71
75
|
unendorse_label = btn_label || t("decidim.proposals.proposal_endorsements_helper.endorsement_button.already_endorsed")
|
72
76
|
|
73
77
|
render partial: "decidim/proposals/proposals/endorsement_button", locals: { proposal: proposal,
|
@@ -28,11 +28,11 @@ module Decidim
|
|
28
28
|
#
|
29
29
|
# Returns an Integer if set, nil otherwise.
|
30
30
|
def vote_limit
|
31
|
-
return nil if
|
32
|
-
|
31
|
+
return nil if component_settings.vote_limit.zero?
|
32
|
+
component_settings.vote_limit
|
33
33
|
end
|
34
34
|
|
35
|
-
# Check if the vote limit is enabled for the current
|
35
|
+
# Check if the vote limit is enabled for the current component
|
36
36
|
#
|
37
37
|
# Returns true if the vote limit is enabled
|
38
38
|
def vote_limit_enabled?
|
@@ -50,15 +50,15 @@ module Decidim
|
|
50
50
|
#
|
51
51
|
# Returns an Integer with the maximum amount of votes, nil otherwise.
|
52
52
|
def threshold_per_proposal
|
53
|
-
return nil unless
|
54
|
-
|
53
|
+
return nil unless component_settings.threshold_per_proposal.positive?
|
54
|
+
component_settings.threshold_per_proposal
|
55
55
|
end
|
56
56
|
|
57
57
|
# Public: Checks if can accumulate more than maxium is enabled
|
58
58
|
#
|
59
59
|
# Returns true if enabled, false otherwise.
|
60
60
|
def can_accumulate_supports_beyond_threshold?
|
61
|
-
|
61
|
+
component_settings.can_accumulate_supports_beyond_threshold
|
62
62
|
end
|
63
63
|
|
64
64
|
# Public: Checks if voting is enabled in this step.
|
@@ -82,16 +82,16 @@ module Decidim
|
|
82
82
|
current_user && votes_enabled? && vote_limit_enabled? && !votes_blocked?
|
83
83
|
end
|
84
84
|
|
85
|
-
# Return the remaining votes for a user if the current
|
85
|
+
# Return the remaining votes for a user if the current component has a vote limit
|
86
86
|
#
|
87
87
|
# user - A User object
|
88
88
|
#
|
89
89
|
# Returns a number with the remaining votes for that user
|
90
90
|
def remaining_votes_count_for(user)
|
91
91
|
return 0 unless vote_limit_enabled?
|
92
|
-
proposals = Proposal.where(
|
92
|
+
proposals = Proposal.where(component: current_component)
|
93
93
|
votes_count = ProposalVote.where(author: user, proposal: proposals).size
|
94
|
-
|
94
|
+
component_settings.vote_limit - votes_count
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|