Merge branch 'master' into feature/add_population_to_budget_heading
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
|
||||
|
||||
before_action :load_budget_investment, only: [:index, :new, :create, :edit, :update, :destroy]
|
||||
before_action :load_budget_investment_milestone, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def new
|
||||
@milestone = Budget::Investment::Milestone.new
|
||||
end
|
||||
|
||||
def create
|
||||
@milestone = Budget::Investment::Milestone.new(milestone_params)
|
||||
@milestone.investment = @investment
|
||||
if @milestone.save
|
||||
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.create.notice')
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @milestone.update(milestone_params)
|
||||
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.update.notice')
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@milestone.destroy
|
||||
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.delete.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def milestone_params
|
||||
params.require(:budget_investment_milestone)
|
||||
.permit(:title, :description, :budget_investment_id)
|
||||
end
|
||||
|
||||
def load_budget_investment
|
||||
@investment = Budget::Investment.find params[:budget_investment_id]
|
||||
end
|
||||
|
||||
def load_budget_investment_milestone
|
||||
@milestone = Budget::Investment::Milestone.find params[:id]
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -14,10 +14,15 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
@budget = Budget.includes(groups: :headings).find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
def new; end
|
||||
|
||||
def edit
|
||||
def edit; end
|
||||
|
||||
def calculate_winners
|
||||
return unless @budget.balloting_process?
|
||||
@budget.headings.each { |heading| Budget::Result.new(@budget, heading).calculate_winners }
|
||||
redirect_to admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'winners'),
|
||||
notice: I18n.t("admin.budgets.winners.calculated")
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -67,6 +67,7 @@ class Admin::Poll::PollsController < Admin::BaseController
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_geozones
|
||||
@geozones = Geozone.all.order(:name)
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Admin::UsersController < Admin::BaseController
|
||||
def index
|
||||
if params[:search]
|
||||
s = params[:search]
|
||||
@users = User.where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", "%#{s}%","%#{s}%","%#{s}%").page(params[:page])
|
||||
@users = User.where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", "%#{s}%", "%#{s}%", "%#{s}%").page(params[:page])
|
||||
else
|
||||
@users = @users.page(params[:page])
|
||||
end
|
||||
|
||||
@@ -93,7 +93,7 @@ module Budgets
|
||||
|
||||
def set_random_seed
|
||||
if params[:order] == 'random' || params[:order].blank?
|
||||
params[:random_seed] ||= rand(99)/100.0
|
||||
params[:random_seed] ||= rand(99) / 100.0
|
||||
seed = Float(params[:random_seed]) rescue 0
|
||||
Budget::Investment.connection.execute("select setseed(#{seed})")
|
||||
else
|
||||
|
||||
@@ -19,13 +19,14 @@ class Legislation::AnswersController < Legislation::BaseController
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js { render json: {} , status: :not_found }
|
||||
format.js { render json: {}, status: :not_found }
|
||||
format.html { redirect_to legislation_process_question_path(@process, @question), alert: t('legislation.questions.participation.phase_not_open') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def answer_params
|
||||
params.require(:legislation_answer).permit(
|
||||
:legislation_question_option_id,
|
||||
|
||||
@@ -20,7 +20,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
@investment.author = managed_user
|
||||
|
||||
if @investment.save
|
||||
notice= t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1)
|
||||
notice = t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1)
|
||||
redirect_to management_budget_investment_path(@budget, @investment), notice: notice
|
||||
else
|
||||
render :new
|
||||
|
||||
@@ -28,6 +28,7 @@ class Officing::FinalRecountsController < Officing::BaseController
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_poll
|
||||
@poll = Poll.expired.find(params[:poll_id])
|
||||
end
|
||||
|
||||
@@ -27,6 +27,7 @@ class Officing::RecountsController < Officing::BaseController
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_poll
|
||||
@poll = Poll.find(params[:poll_id])
|
||||
end
|
||||
|
||||
@@ -23,6 +23,6 @@ class StatsController < ApplicationController
|
||||
private
|
||||
|
||||
def daily_cache(key, &block)
|
||||
Rails.cache.fetch("public_stats/#{Time.current.strftime("%Y-%m-%d")}/#{key}", &block)
|
||||
Rails.cache.fetch("public_stats/#{Time.current.strftime('%Y-%m-%d')}/#{key}", &block)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
identity = Identity.first_or_create_from_oauth(auth)
|
||||
@user = current_user || identity.user || User.first_or_initialize_for_oauth(auth)
|
||||
|
||||
if save_user(@user)
|
||||
if save_user
|
||||
identity.update(user: @user)
|
||||
sign_in_and_redirect @user, event: :authentication
|
||||
set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format?
|
||||
@@ -40,8 +40,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
end
|
||||
end
|
||||
|
||||
def save_user(user)
|
||||
def save_user
|
||||
@user.save || @user.save_requiring_finish_signup
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_activity_counts
|
||||
@activity_counts = HashWithIndifferentAccess.new(
|
||||
proposals: Proposal.where(author_id: @user.id).count,
|
||||
|
||||
Reference in New Issue
Block a user