Merge branch 'master' into proposal-dashboard

This commit is contained in:
decabeza
2019-04-23 17:12:47 +02:00
643 changed files with 2814 additions and 1417 deletions

View File

@@ -39,7 +39,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
if @investment.update(budget_investment_params)
redirect_to admin_budget_budget_investment_path(@budget,
@investment,
Budget::Investment.filter_params(params)),
Budget::Investment.filter_params(params).to_h),
notice: t("flash.actions.update.budget_investment")
else
load_admins
@@ -69,7 +69,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end
def resource_name
resource_model.parameterize("_")
resource_model.parameterize(separator: "_")
end
def load_investments
@@ -107,7 +107,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end
def load_tags
@tags = Budget::Investment.tags_on(:valuation).order(:name).uniq
@tags = Budget::Investment.tags_on(:valuation).order(:name).distinct
end
def load_ballot

View File

@@ -9,7 +9,8 @@ class Admin::Legislation::HomepagesController < Admin::Legislation::BaseControll
def update
if @process.update(process_params)
link = legislation_process_path(@process).html_safe
redirect_to :back, notice: t("admin.legislation.processes.update.notice", link: link)
redirect_back(fallback_location: (request.referrer || root_path),
notice: t("admin.legislation.processes.update.notice", link: link))
else
flash.now[:error] = t("admin.legislation.processes.update.error")
render :edit

View File

@@ -27,7 +27,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
set_tag_list
link = legislation_process_path(@process).html_safe
redirect_to :back, notice: t("admin.legislation.processes.update.notice", link: link)
redirect_back(fallback_location: (request.referrer || root_path),
notice: t("admin.legislation.processes.update.notice", link: link))
else
flash.now[:error] = t("admin.legislation.processes.update.error")
render :edit

View File

@@ -7,13 +7,11 @@ 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
@poll = Poll.includes(:questions).
order("poll_questions.title").
find(params[:id])
@poll = Poll.find(params[:id])
end
def new
@@ -22,7 +20,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
@@ -62,8 +65,9 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
end
def poll_params
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
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

@@ -38,7 +38,7 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
else
t("flash.actions.destroy.error")
end
redirect_to :back, notice: notice
redirect_back(fallback_location: (request.referrer || root_path), notice: notice)
end
private

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

@@ -46,7 +46,7 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
.keys
languages_to_delete.each do |locale|
I18nContentTranslation.destroy_all(locale: locale)
I18nContentTranslation.where(locale: locale).destroy_all
end
end

View File

@@ -1,5 +1,6 @@
class Admin::SpendingProposalsController < Admin::BaseController
include FeatureFlags
before_action :load_filter_params
feature_flag :spending_proposals
has_filters %w{valuation_open without_admin managed valuating valuation_finished all}, only: :index
@@ -7,7 +8,7 @@ class Admin::SpendingProposalsController < Admin::BaseController
load_and_authorize_resource
def index
@spending_proposals = SpendingProposal.scoped_filter(params, @current_filter)
@spending_proposals = SpendingProposal.scoped_filter(filter_params, @current_filter)
.order(cached_votes_up: :desc, created_at: :desc)
.page(params[:page])
end
@@ -23,7 +24,7 @@ class Admin::SpendingProposalsController < Admin::BaseController
def update
if @spending_proposal.update(spending_proposal_params)
redirect_to admin_spending_proposal_path(@spending_proposal, SpendingProposal.filter_params(params)),
redirect_to admin_spending_proposal_path(@spending_proposal, filter_params),
notice: t("flash.actions.update.spending_proposal")
else
load_admins
@@ -46,6 +47,14 @@ class Admin::SpendingProposalsController < Admin::BaseController
:administrator_id, :tag_list, valuator_ids: [])
end
def filter_params
params.permit(:geozone_id, :administrator_id, :tag_name, :valuator_id)
end
def load_filter_params
@filter_params ||= filter_params
end
def load_admins
@admins = Administrator.includes(:user).all
end

View File

@@ -4,7 +4,7 @@ class Admin::Widget::FeedsController < Admin::BaseController
@feed = ::Widget::Feed.find(params[:id])
@feed.update(feed_params)
render nothing: true
head :ok
end
private
@@ -13,4 +13,4 @@ class Admin::Widget::FeedsController < Admin::BaseController
params.require(:widget_feed).permit(:limit)
end
end
end