Skip to content

Commit

Permalink
Revert "fix: Flash message on proposal limit per user reached (#609)"
Browse files Browse the repository at this point in the history
This reverts commit 28003b5.
  • Loading branch information
luciegrau authored Nov 20, 2024
1 parent e584dab commit 1f58479
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ def create
enforce_permission_to :create, :proposal
@step = Decidim::Proposals::ProposalsController::STEP1
@form = form(Decidim::Proposals::ProposalForm).from_params(proposal_creation_params)
if proposal_limit_reached?
@form.errors.add(:base, I18n.t("decidim.proposals.new.limit_reached"))
flash.now[:alert] = I18n.t("proposals.create.error", scope: "decidim")
render :new
return
end

@proposal = Decidim::Proposals::Proposal.new(@form.attributes.except(
:user_group_id,
Expand Down Expand Up @@ -192,17 +186,6 @@ def map_attachment_objects(attachments)
end
end
end

def proposal_limit_reached?(form = form_proposal_params)
proposal_limit = form.current_component.settings.proposal_limit
return false if proposal_limit.zero?

current_user_proposals(form).count >= proposal_limit
end

def current_user_proposals(form)
Decidim::Proposals::Proposal.from_author(current_user).where(component: form.current_component).except_withdrawn
end
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ ignore_missing:
- decidim.term_customizer.admin.actions.*
- decidim.term_customizer.admin.add_translations.index.*
- decidim.term_customizer.admin.models.translations.fields.*
- decidim.proposals.new.limit_reached
- decidim.proposals.create.error

# Consider these keys used:
ignore_unused:
Expand Down
12 changes: 0 additions & 12 deletions spec/controllers/decidim/proposals/proposals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,6 @@ module Proposals
expect(flash[:notice]).not_to be_empty
expect(response).to have_http_status(:found)
end

context "and proposals limit is reached" do
before do
allow(controller).to receive(:proposal_limit_reached?).and_return(true)
end

it "does not create a proposal and raises an error" do
post :create, params: params
expect(response).to have_http_status(:ok)
expect(flash[:alert]).not_to be_empty
end
end
end
end

Expand Down

0 comments on commit 1f58479

Please sign in to comment.