Remove obsolete questions index in the admin area

We removed the link to this page in commit 83e8d6035 because poll
questions don't really make sense without a poll.

However, this page also contained information about successful
proposals, which might be interesting so administrators don't have to
navigate to the public area in order to find and create questions based
on successful proposals.

So we're keeping the part about successful proposals and linking it from
the proposals part of the admin area.

Note we're using translation keys like `successful_proposals_tab`, which
don't make sense anymore, for the successful proposals. We're doing so
because we've already got translations for these keys and, if we renamed
them, we'd lose the existing translations and our translators would have
to add them again.

Also note we're changing one poll question test a little bit so we
create the question from a successful proposal using the new page. There
are other tests checking how to create a question from the
admin/proposals#show action and other tests checking what happens when
accessing a successful proposal in the admin section, so we don't lose
any test coverage by changing an existing test instead of adding a new
one.

Finally, note that we've removing the `search` method in poll question
because we no longer use it. This currently makes the
`author_visible_name` database column useless; we aren't removing it
right now because we don't want to risk a possible data loss in a patch
release (we're about to release version 2.3.1), but we might remove it
in the future.
This commit is contained in:
Javi Martín
2025-02-23 14:51:48 +01:00
parent cf5863b29f
commit 2239b8fdca
23 changed files with 81 additions and 180 deletions

View File

@@ -4,14 +4,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
load_and_authorize_resource :poll
load_resource class: "Poll::Question"
authorize_resource except: [:new, :index]
def index
@polls = Poll.not_budget
@questions = @questions.search(search_params).page(params[:page]).order("created_at DESC")
@proposals = Proposal.successful.sort_by_confidence_score
end
authorize_resource except: :new
def new
proposal = Proposal.find(params[:proposal_id]) if params[:proposal_id].present?
@@ -61,8 +54,4 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
attributes = [:poll_id, :question, :proposal_id, votation_type_attributes: [:vote_type, :max_votes]]
[*attributes, translation_params(Poll::Question)]
end
def search_params
params.permit(:poll_id, :search)
end
end