Merge pull request #3344 from consul/backport-budget_ballots

Allow voting Budget Investments in booths
This commit is contained in:
Javier Martín
2019-04-09 13:54:00 +02:00
committed by GitHub
23 changed files with 380 additions and 30 deletions

View File

@@ -7,7 +7,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
before_action :load_geozones, only: [:new, :create, :edit, :update]
def index
@polls = Poll.order(starts_at: :desc)
@polls = Poll.not_budget.order(starts_at: :desc)
end
def show
@@ -22,7 +22,12 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
def create
@poll = Poll.new(poll_params.merge(author: current_user))
if @poll.save
redirect_to [:admin, @poll], notice: t("flash.actions.create.poll")
notice = t("flash.actions.create.poll")
if @poll.budget.present?
redirect_to admin_poll_booth_assignments_path(@poll), notice: notice
else
redirect_to [:admin, @poll], notice: notice
end
else
render :new
end
@@ -63,7 +68,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
def poll_params
attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :results_enabled,
:stats_enabled, geozone_ids: [],
:stats_enabled, :budget_id, geozone_ids: [],
image_attributes: image_attributes]
params.require(:poll).permit(*attributes, translation_params(Poll))
end

View File

@@ -6,7 +6,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
load_and_authorize_resource :question, class: "Poll::Question"
def index
@polls = Poll.all
@polls = Poll.not_budget
@search = search_params[:search]
@questions = @questions.search(search_params).page(params[:page]).order("created_at DESC")

View File

@@ -11,7 +11,7 @@ class PollsController < ApplicationController
::Poll::Answer # trigger autoload
def index
@polls = @polls.send(@current_filter).includes(:geozones).sort_for_list.page(params[:page])
@polls = @polls.not_budget.send(@current_filter).includes(:geozones).sort_for_list.page(params[:page])
end
def show