From bce6d97a4fd3adfe10842806066f6d33ab2c192b Mon Sep 17 00:00:00 2001 From: Lucie Grau <87868063+luciegrau@users.noreply.github.com> Date: Wed, 20 Nov 2024 17:24:05 +0100 Subject: [PATCH] revert: "fix: Flash message on proposal limit per user reached (#609)" (#634) This reverts commit 28003b5d45a89c7233596c4b751b1dabdf7690aa. --- .../proposals_controller_override.rb | 17 ----------------- config/i18n-tasks.yml | 2 -- .../proposals/proposals_controller_spec.rb | 12 ------------ 3 files changed, 31 deletions(-) diff --git a/app/controllers/concerns/decidim/simple_proposal/proposals_controller_override.rb b/app/controllers/concerns/decidim/simple_proposal/proposals_controller_override.rb index b627ce8e14..0b0aab5612 100644 --- a/app/controllers/concerns/decidim/simple_proposal/proposals_controller_override.rb +++ b/app/controllers/concerns/decidim/simple_proposal/proposals_controller_override.rb @@ -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, @@ -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 diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index fef7c18f22..7a81861781 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -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: diff --git a/spec/controllers/decidim/proposals/proposals_controller_spec.rb b/spec/controllers/decidim/proposals/proposals_controller_spec.rb index fff754b530..2775493f10 100644 --- a/spec/controllers/decidim/proposals/proposals_controller_spec.rb +++ b/spec/controllers/decidim/proposals/proposals_controller_spec.rb @@ -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