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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +3 -3
  4. data/app/assets/javascripts/decidim/proposals/admin/proposals.es6 +6 -7
  5. data/app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6 +17 -17
  6. data/app/assets/javascripts/decidim/proposals/utils.js.es6 +2 -2
  7. data/app/commands/decidim/proposals/admin/create_proposal.rb +2 -2
  8. data/app/commands/decidim/proposals/admin/import_proposals.rb +16 -8
  9. data/app/commands/decidim/proposals/create_proposal.rb +6 -6
  10. data/app/commands/decidim/proposals/destroy_proposal.rb +33 -0
  11. data/app/commands/decidim/proposals/update_proposal.rb +4 -4
  12. data/app/controllers/decidim/proposals/admin/application_controller.rb +2 -2
  13. data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +1 -1
  14. data/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb +1 -1
  15. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
  16. data/app/controllers/decidim/proposals/admin/proposals_imports_controller.rb +4 -4
  17. data/app/controllers/decidim/proposals/application_controller.rb +5 -5
  18. data/app/controllers/decidim/proposals/proposal_endorsements_controller.rb +1 -1
  19. data/app/controllers/decidim/proposals/proposal_votes_controller.rb +1 -1
  20. data/app/controllers/decidim/proposals/proposal_widgets_controller.rb +1 -1
  21. data/app/controllers/decidim/proposals/proposals_controller.rb +52 -24
  22. data/app/events/decidim/proposals/proposal_mentioned_event.rb +19 -0
  23. data/app/forms/decidim/proposals/admin/proposal_form.rb +3 -3
  24. data/app/forms/decidim/proposals/admin/proposals_import_form.rb +9 -9
  25. data/app/forms/decidim/proposals/proposal_form.rb +5 -4
  26. data/app/helpers/decidim/proposals/application_helper.rb +38 -3
  27. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +7 -3
  28. data/app/helpers/decidim/proposals/proposal_votes_helper.rb +9 -9
  29. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +2 -1
  30. data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +28 -0
  31. data/app/jobs/decidim/proposals/settings_change_job.rb +4 -4
  32. data/app/models/decidim/proposals/abilities/admin_ability.rb +4 -4
  33. data/app/models/decidim/proposals/abilities/current_user_ability.rb +12 -12
  34. data/app/models/decidim/proposals/abilities/participatory_process_admin_ability.rb +8 -8
  35. data/app/models/decidim/proposals/abilities/participatory_process_moderator_ability.rb +1 -1
  36. data/app/models/decidim/proposals/proposal.rb +7 -7
  37. data/app/models/decidim/proposals/proposal_endorsement.rb +6 -2
  38. data/app/presenters/decidim/proposals/proposal_presenter.rb +12 -0
  39. data/app/queries/decidim/proposals/filtered_proposals.rb +9 -9
  40. data/app/queries/decidim/proposals/similar_proposals.rb +9 -9
  41. data/app/services/decidim/proposals/proposal_search.rb +1 -1
  42. data/app/types/decidim/proposals/proposal_type.rb +17 -2
  43. data/app/types/decidim/proposals/proposals_type.rb +6 -6
  44. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +1 -1
  45. data/app/views/decidim/participatory_processes/participatory_process_groups/_proposal.html.erb +1 -1
  46. data/app/views/decidim/participatory_spaces/_highlighted_proposals.html.erb +2 -2
  47. data/app/views/decidim/participatory_spaces/_proposal.html.erb +1 -1
  48. data/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +3 -3
  49. data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +2 -2
  50. data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +3 -3
  51. data/app/views/decidim/proposals/admin/proposal_notes/index.html.erb +1 -1
  52. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +2 -2
  53. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +3 -3
  54. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +1 -1
  55. data/app/views/decidim/proposals/admin/proposals/index.html.erb +1 -1
  56. data/app/views/decidim/proposals/admin/proposals/new.html.erb +2 -2
  57. data/app/views/decidim/proposals/admin/proposals/update_category.js.erb +3 -3
  58. data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +3 -3
  59. data/app/views/decidim/proposals/admin/shared/_info_proposal.html.erb +1 -1
  60. data/app/views/decidim/proposals/proposal_endorsements/_identity.html.erb +2 -2
  61. data/app/views/decidim/proposals/proposal_endorsements/identities.html.erb +2 -2
  62. data/app/views/decidim/proposals/proposal_endorsements/update_buttons_and_counters.js.erb +19 -8
  63. data/app/views/decidim/proposals/proposals/_endorsement_button.html.erb +2 -2
  64. data/app/views/decidim/proposals/proposals/_endorsement_identities_cabin.html.erb +3 -3
  65. data/app/views/decidim/proposals/proposals/_endorsements_card_row.html.erb +4 -4
  66. data/app/views/decidim/proposals/proposals/_endorsements_count.html.erb +2 -2
  67. data/app/views/decidim/proposals/proposals/_filters.html.erb +10 -10
  68. data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +1 -1
  69. data/app/views/decidim/proposals/proposals/_identities_listing.html.erb +30 -0
  70. data/app/views/decidim/proposals/proposals/{_endorsement_xxs.html.erb → _identity_xxs.html.erb} +1 -2
  71. data/app/views/decidim/proposals/proposals/_proposal.html.erb +2 -2
  72. data/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +1 -1
  73. data/app/views/decidim/proposals/proposals/_tags.html.erb +25 -0
  74. data/app/views/decidim/proposals/proposals/_vote_button.html.erb +7 -7
  75. data/app/views/decidim/proposals/proposals/_votes_count.html.erb +6 -5
  76. data/app/views/decidim/proposals/proposals/_voting_rules.html.erb +7 -7
  77. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +5 -5
  78. data/app/views/decidim/proposals/proposals/compare.html.erb +1 -1
  79. data/app/views/decidim/proposals/proposals/complete.html.erb +70 -0
  80. data/app/views/decidim/proposals/proposals/edit.html.erb +3 -3
  81. data/app/views/decidim/proposals/proposals/edit_draft.html.erb +5 -3
  82. data/app/views/decidim/proposals/proposals/index.html.erb +5 -5
  83. data/app/views/decidim/proposals/proposals/new.html.erb +1 -43
  84. data/app/views/decidim/proposals/proposals/preview.html.erb +1 -1
  85. data/app/views/decidim/proposals/proposals/show.html.erb +16 -23
  86. data/config/locales/ca.yml +69 -55
  87. data/config/locales/en.yml +64 -50
  88. data/config/locales/es.yml +73 -59
  89. data/config/locales/eu.yml +64 -50
  90. data/config/locales/fi.yml +64 -50
  91. data/config/locales/fr.yml +75 -61
  92. data/config/locales/gl.yml +64 -50
  93. data/config/locales/it.yml +64 -50
  94. data/config/locales/nl.yml +153 -139
  95. data/config/locales/pl.yml +64 -50
  96. data/config/locales/pt-BR.yml +64 -50
  97. data/config/locales/pt.yml +64 -50
  98. data/config/locales/ru.yml +0 -9
  99. data/config/locales/sv.yml +64 -50
  100. data/config/locales/uk.yml +2 -16
  101. data/db/migrate/20171212102250_enable_pg_extensions.rb +12 -1
  102. data/db/migrate/20180305133811_rename_features_to_components_at_proposals.rb +11 -0
  103. data/db/migrate/20180413135249_fix_nil_threshold_per_proposal.rb +18 -0
  104. data/lib/decidim/content_parsers/proposal_parser.rb +95 -0
  105. data/lib/decidim/content_renderers/proposal_renderer.rb +33 -0
  106. data/lib/decidim/proposals.rb +9 -1
  107. data/lib/decidim/proposals/commentable_proposal.rb +3 -3
  108. data/lib/decidim/proposals/{feature.rb → component.rb} +39 -38
  109. data/lib/decidim/proposals/engine.rb +21 -6
  110. data/lib/decidim/proposals/proposal_serializer.rb +3 -3
  111. data/lib/decidim/proposals/test/factories.rb +5 -8
  112. data/lib/decidim/proposals/version.rb +1 -1
  113. metadata +32 -23
  114. data/app/views/decidim/proposals/proposals/_endorsements_listing.html.erb +0 -34
@@ -49,7 +49,7 @@ module Decidim
49
49
  private
50
50
 
51
51
  def proposal
52
- @proposal ||= Proposal.where(feature: current_feature).find(params[:proposal_id])
52
+ @proposal ||= Proposal.where(component: current_component).find(params[:proposal_id])
53
53
  end
54
54
  end
55
55
  end
@@ -41,7 +41,7 @@ module Decidim
41
41
  private
42
42
 
43
43
  def proposal
44
- @proposal ||= Proposal.where(feature: current_feature).find(params[:proposal_id])
44
+ @proposal ||= Proposal.where(component: current_component).find(params[:proposal_id])
45
45
  end
46
46
  end
47
47
  end
@@ -8,7 +8,7 @@ module Decidim
8
8
  private
9
9
 
10
10
  def model
11
- @model ||= Proposal.where(feature: params[:feature_id]).find(params[:proposal_id])
11
+ @model ||= Proposal.where(component: params[:component_id]).find(params[:proposal_id])
12
12
  end
13
13
 
14
14
  def iframe_url
@@ -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: [:compare, :preview, :publish, :edit_draft, :update_draft]
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(feature: current_feature).find(params[:id])
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, feature_id: proposal_draft.feature.id, assembly_slug: proposal_draft.feature.participatory_space.slug)
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 = :step_1
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
- compare_path = Decidim::ResourceLocatorPresenter.new(proposal).path + "/compare"
66
- redirect_to compare_path
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 :new
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(current_feature, @proposal)
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 preview_proposal_path(@proposal)
83
+ redirect_to complete_proposals_path(proposal: { title: @form.title, body: @form.body })
85
84
  end
86
85
  end
87
86
 
88
- def preview
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 = :step_3
105
+ @step = :step_4
94
106
  PublishProposal.call(@proposal, current_user) do
95
- on(:ok) do |proposal|
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 = :step_1
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 preview_proposal_path(proposal)
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(feature: current_feature).find(params[:id])
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(feature: current_feature).find(params[:id])
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(feature: current_feature).find(params[:id])
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(feature: current_feature, author: current_user).find_by(published_at: nil)
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(feature: current_feature).find(params[:id])
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: -> { current_feature.settings.geocoding_enabled? }
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: :current_feature
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 feature current_feature
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 :origin_feature_id, Integer
11
+ attribute :origin_component_id, Integer
12
12
  attribute :import_proposals, Boolean
13
13
  attribute :states, Array
14
14
 
15
- validates :origin_feature_id, :origin_feature, :states, :current_feature, presence: true
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 origin_feature
35
- @origin_feature ||= origin_features.find_by(id: origin_feature_id)
34
+ def origin_component
35
+ @origin_component ||= origin_components.find_by(id: origin_component_id)
36
36
  end
37
37
 
38
- def origin_features
39
- @origin_features ||= current_participatory_space.features.where.not(id: current_feature.id).where(manifest_name: :proposals)
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 origin_features_collection
43
- origin_features.map do |feature|
44
- [feature.name[I18n.locale.to_s], feature.id]
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: :current_feature
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 feature current_feature
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
- current_feature.settings.geocoding_enabled? && has_address
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 = current_feature.settings.proposal_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 feature_settings.proposal_limit.zero?
66
+ return if component_settings.proposal_limit.zero?
67
67
 
68
- feature_settings.proposal_limit
68
+ component_settings.proposal_limit
69
69
  end
70
70
 
71
71
  def current_user_proposals
72
- Proposal.where(feature: current_feature, author: current_user)
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 endorsement_identity(endorsement)
56
- endorsement.user_group ? endorsement.user_group : endorsement.author
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 feature_settings.vote_limit.zero?
32
- feature_settings.vote_limit
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 feature
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 feature_settings.threshold_per_proposal.to_i.positive?
54
- feature_settings.threshold_per_proposal
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
- feature_settings.can_accumulate_supports_beyond_threshold
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 feature has a vote limit
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(feature: current_feature)
92
+ proposals = Proposal.where(component: current_component)
93
93
  votes_count = ProposalVote.where(author: user, proposal: proposals).size
94
- feature_settings.vote_limit - votes_count
94
+ component_settings.vote_limit - votes_count
95
95
  end
96
96
  end
97
97
  end