Skip to content

Commit

Permalink
Rename Support to Vote in proposals (decidim#12873)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexandru Emil Lupu <[email protected]>
  • Loading branch information
andreslucena and alecslupu authored Jun 6, 2024
1 parent e2e9bd3 commit 0741e14
Show file tree
Hide file tree
Showing 37 changed files with 164 additions and 164 deletions.
4 changes: 2 additions & 2 deletions decidim-budgets/spec/system/orders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,14 @@
end
end

context "with supports enabled" do
context "with votes enabled" do
let(:proposal_component) do
create(:proposal_component, :with_votes_enabled, participatory_space: project.component.participatory_space)
end

let(:proposals) { create_list(:proposal, 1, :with_votes, component: proposal_component) }

it "does not show the amount of supports" do
it "does not show the amount of votes" do
visit_budget
click_on translated(project.title)

Expand Down
2 changes: 1 addition & 1 deletion decidim-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ User authentication is set up with [`Devise`](https://github.com/plataformatec/d

Core implements an Amendment feature that can be activated in the components. As of now, it is only implemented in the proposal component.

This feature makes it possible for anyone to edit the text of an amendable resource and create a child resource as an amendment. This child resource may receive support and the author of the amendable resource may accept or reject the amendment (or child proposal). In case of rejection, the author of the rejected emendation may raise the child resource to an independent resource.
This feature makes it possible for anyone to edit the text of an amendable resource and create a child resource as an amendment. This child resource may receive votes and the author of the amendable resource may accept or reject the amendment (or child proposal). In case of rejection, the author of the rejected emendation may raise the child resource to an independent resource.

### Key artifacts for Amendments

Expand Down
2 changes: 1 addition & 1 deletion decidim-core/app/commands/decidim/amendable/withdraw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(amendment, current_user)
# Executes the command. Broadcasts these events:
#
# - :ok when everything is valid, together with the resource.
# - :invalid if the resource already has supports or does not belong to current user.
# - :invalid if the resource already has votes or does not belong to current user.
#
# Returns nothing.
def call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def component_stats(conditions)
stats = {}
Decidim.component_manifests.flat_map do |component|
component
.stats.except([:supports_count])
.stats.except([:votes_count])
.filter(conditions)
.with_context(published_components)
.each do |name, data|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
context "when current user is the author of the amendment" do
let(:current_user) { amendment.amender }

context "and the amendment has no supports" do
context "and the amendment has no votes" do
it "withdraws the amendment" do
expect { command.call }.to broadcast(:ok)
expect(amendment.state).to eq("withdrawn")
expect(emendation.state).to eq("withdrawn")
end
end

context "and the amendment has some supports" do
context "and the amendment has some votes" do
before do
emendation.votes.create!(author: other_user)
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-dev/lib/decidim/dev/assets/assemblies.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
"proposal_length": 500,
"proposal_edit_before_minutes": 5,
"threshold_per_proposal": 0,
"can_accumulate_supports_beyond_threshold": false,
"can_accumulate_votes_beyond_threshold": false,
"proposal_answering_enabled": true,
"official_proposals_enabled": true,
"comments_enabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def query
debates_query,
meetings_query,
endorsements_query,
project_supports_query,
project_votes_query,
proposals_query,
proposal_supports_query,
proposal_votes_query,
survey_answer_query
].flatten.uniq.count
end
Expand Down Expand Up @@ -93,7 +93,7 @@ def proposals_query
.uniq
end

def proposal_supports_query
def proposal_votes_query
return [] unless Decidim.module_installed?(:proposals)

Decidim::Proposals::ProposalVote
Expand All @@ -105,7 +105,7 @@ def proposal_supports_query
.uniq
end

def project_supports_query
def project_votes_query
return [] unless Decidim.module_installed?(:budgets)

Decidim::Budgets::Order.joins(budget: [:component])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(proposal, current_user)
#
# Returns nothing.
def call
return broadcast(:invalid) if @proposal.maximum_votes_reached? && !@proposal.can_accumulate_supports_beyond_threshold
return broadcast(:invalid) if @proposal.maximum_votes_reached? && !@proposal.can_accumulate_votes_beyond_threshold

build_proposal_vote
return broadcast(:invalid) unless vote.valid?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def initialize(proposal, current_user)
# Executes the command. Broadcasts these events:
#
# - :ok when everything is valid, together with the proposal.
# - :has_supports if the proposal already has supports or does not belong to current user.
# - :has_votes if the proposal already has votes or does not belong to current user.
#
# Returns nothing.
def call
return broadcast(:has_supports) if @proposal.votes.any?
return broadcast(:has_votes) if @proposal.votes.any?

transaction do
@proposal.withdraw!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def withdraw
flash[:notice] = I18n.t("proposals.update.success", scope: "decidim")
redirect_to Decidim::ResourceLocatorPresenter.new(@proposal).path
end
on(:has_supports) do
flash[:alert] = I18n.t("proposals.withdraw.errors.has_supports", scope: "decidim")
on(:has_votes) do
flash[:alert] = I18n.t("proposals.withdraw.errors.has_votes", scope: "decidim")
redirect_to Decidim::ResourceLocatorPresenter.new(@proposal).path
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def mergeable_to_same_component

proposals.each do |proposal|
errors_set << :not_official unless proposal.official?
errors_set << :supported if proposal.votes.any? || proposal.endorsements.any?
errors_set << :voted if proposal.votes.any? || proposal.endorsements.any?
end

errors_set.each { |error| errors.add(:base, error) } if errors_set.any?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def show_voting_rules?
return true if vote_limit_enabled?
return true if threshold_per_proposal_enabled?
return true if proposal_limit_enabled?
return true if can_accumulate_supports_beyond_threshold?
return true if can_accumulate_votes_beyond_threshold?
return true if minimum_votes_per_user_enabled?
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def threshold_per_proposal
# Public: Checks if can accumulate more than maximum is enabled
#
# Returns true if enabled, false otherwise.
def can_accumulate_supports_beyond_threshold?
component_settings.can_accumulate_supports_beyond_threshold
def can_accumulate_votes_beyond_threshold?
component_settings.can_accumulate_votes_beyond_threshold
end

# Public: Checks if voting is enabled in this step.
Expand Down
4 changes: 2 additions & 2 deletions decidim-proposals/app/models/decidim/proposals/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ def maximum_votes_reached?
# Public: Can accumulate more votes than maximum for this proposal.
#
# Returns true if can accumulate, false otherwise
def can_accumulate_supports_beyond_threshold
component.settings.can_accumulate_supports_beyond_threshold
def can_accumulate_votes_beyond_threshold
component.settings.can_accumulate_votes_beyond_threshold
end

# Checks whether the user can edit the given proposal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Proposals
module Metrics
# Searches for Participants in the following actions
# - Create a proposal (Proposals)
# - Give support to a proposal (Proposals)
# - Vote to a proposal (Proposals)
# - Endorse (Proposals)
class ProposalParticipantsMetricMeasure < Decidim::MetricMeasure
def valid?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<% end %>

<div class="card-section">
<div class="row column" data-supports>
<div class="row column" data-votes>
<span class="component__show-title"><%= t ".votes_count" %></span>
<div class="flex items-center gap-x-2 mt-2">
<%= icon "service-line", class: "fill-gray" %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<span class="sr-only"><%= decidim_html_escape(present(proposal).title) %></span>
<% end %>
<% else %>
<% if proposal.maximum_votes_reached? && !proposal.can_accumulate_supports_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
<% if proposal.maximum_votes_reached? && !proposal.can_accumulate_votes_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
<%= content_tag :button, t("decidim.proposals.proposals.vote_button.maximum_votes_reached"), class: button_classes, disabled: true %>
<% else %>
<% if vote_limit_enabled? && remaining_votes_count_for(current_user) == 0 %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<li><%= t(".threshold_per_proposal.description", limit: threshold_per_proposal) %></li>
<% end %>

<% if can_accumulate_supports_beyond_threshold? %>
<li><%= t(".can_accumulate_supports_beyond_threshold.description", limit: threshold_per_proposal) %></li>
<% if can_accumulate_votes_beyond_threshold? %>
<li><%= t(".can_accumulate_votes_beyond_threshold.description", limit: threshold_per_proposal) %></li>
<% end %>

<% if minimum_votes_per_user_enabled? %>
Expand All @@ -24,7 +24,7 @@
<% if votes_given >= minimum_votes_per_user %>
<%= t(".minimum_votes_per_user.given_enough_votes") %>
<% else %>
<%= t(".minimum_votes_per_user.supports_remaining", remaining_votes: minimum_votes_per_user - votes_given) %>
<%= t(".minimum_votes_per_user.votes_remaining", remaining_votes: minimum_votes_per_user - votes_given) %>
<% end %>
</li>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<span><%= decidim_html_escape(present(proposal).title) %></span>
<% end %>
<% else %>
<% if proposal.maximum_votes_reached? && !proposal.can_accumulate_supports_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
<% if proposal.maximum_votes_reached? && !proposal.can_accumulate_votes_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
<%= content_tag :span, t("decidim.proposals.proposals.vote_button.maximum_votes_reached"), class: "column button light button--sc disabled", disabled: true %>
<% else %>
<% if vote_limit_enabled? && remaining_votes_count_for(current_user) == 0 %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<%= proposal.proposal_votes_count || 0 %>
</button>
<% else %>
<% if proposal.maximum_votes_reached? && !proposal.can_accumulate_supports_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
<% if proposal.maximum_votes_reached? && !proposal.can_accumulate_votes_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
<button type="button" name="button" class="column button button--sc disabled" disabled id="proposal-<%= proposal.id %>-votes-count">
<%= proposal.proposal_votes_count || 0 %>
</button>
Expand Down
Loading

0 comments on commit 0741e14

Please sign in to comment.