Merge branch 'master' into content_blocks_for_headings
This commit is contained in:
@@ -33,7 +33,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController
|
||||
private
|
||||
|
||||
def budget_heading_params
|
||||
params.require(:budget_heading).permit(:name, :price, :population, :allow_custom_content)
|
||||
params.require(:budget_heading).permit(:name, :price, :population, :allow_custom_content, :latitude, :longitude)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,76 +1,8 @@
|
||||
class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
|
||||
include Translatable
|
||||
|
||||
before_action :load_budget_investment, only: [:index, :new, :create, :edit, :update, :destroy]
|
||||
before_action :load_budget_investment_milestone, only: [:edit, :update, :destroy]
|
||||
before_action :load_statuses, only: [:index, :new, :create, :edit, :update]
|
||||
|
||||
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
|
||||
class Admin::BudgetInvestmentMilestonesController < Admin::MilestonesController
|
||||
|
||||
private
|
||||
|
||||
def milestone_params
|
||||
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
attributes = [:publication_date, :budget_investment_id, :status_id,
|
||||
translation_params(Budget::Investment::Milestone),
|
||||
image_attributes: image_attributes, documents_attributes: documents_attributes]
|
||||
|
||||
params.require(:budget_investment_milestone).permit(*attributes)
|
||||
def milestoneable
|
||||
Budget::Investment.find(params[:budget_investment_id])
|
||||
end
|
||||
|
||||
def load_budget_investment
|
||||
@investment = Budget::Investment.find(params[:budget_investment_id])
|
||||
end
|
||||
|
||||
def load_budget_investment_milestone
|
||||
@milestone = get_milestone
|
||||
end
|
||||
|
||||
def get_milestone
|
||||
Budget::Investment::Milestone.find(params[:id])
|
||||
end
|
||||
|
||||
def resource
|
||||
get_milestone
|
||||
end
|
||||
|
||||
def load_statuses
|
||||
@statuses = Budget::Investment::Status.all
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Admin::ProposalsController < Admin::BaseController
|
||||
class Admin::HiddenProposalsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}, only: :index
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
|
||||
feature_flag :proposals
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
class Admin::BudgetInvestmentStatusesController < Admin::BaseController
|
||||
class Admin::MilestoneStatusesController < Admin::BaseController
|
||||
|
||||
before_action :load_status, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@statuses = Budget::Investment::Status.all
|
||||
@statuses = Milestone::Status.all
|
||||
end
|
||||
|
||||
def new
|
||||
@status = Budget::Investment::Status.new
|
||||
@status = Milestone::Status.new
|
||||
end
|
||||
|
||||
def create
|
||||
@status = Budget::Investment::Status.new(status_params)
|
||||
@status = Milestone::Status.new(status_params)
|
||||
|
||||
if @status.save
|
||||
redirect_to admin_budget_investment_statuses_path,
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t('admin.statuses.create.notice')
|
||||
else
|
||||
render :new
|
||||
@@ -26,7 +26,7 @@ class Admin::BudgetInvestmentStatusesController < Admin::BaseController
|
||||
|
||||
def update
|
||||
if @status.update(status_params)
|
||||
redirect_to admin_budget_investment_statuses_path,
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t('admin.statuses.update.notice')
|
||||
else
|
||||
render :edit
|
||||
@@ -35,17 +35,17 @@ class Admin::BudgetInvestmentStatusesController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
@status.destroy
|
||||
redirect_to admin_budget_investment_statuses_path,
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t('admin.statuses.delete.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_status
|
||||
@status = Budget::Investment::Status.find(params[:id])
|
||||
@status = Milestone::Status.find(params[:id])
|
||||
end
|
||||
|
||||
def status_params
|
||||
params.require(:budget_investment_status).permit([:name, :description])
|
||||
params.require(:milestone_status).permit([:name, :description])
|
||||
end
|
||||
end
|
||||
72
app/controllers/admin/milestones_controller.rb
Normal file
72
app/controllers/admin/milestones_controller.rb
Normal file
@@ -0,0 +1,72 @@
|
||||
class Admin::MilestonesController < Admin::BaseController
|
||||
include Translatable
|
||||
|
||||
before_action :load_milestoneable, only: [:index, :new, :create, :edit, :update, :destroy]
|
||||
before_action :load_milestone, only: [:edit, :update, :destroy]
|
||||
before_action :load_statuses, only: [:index, :new, :create, :edit, :update]
|
||||
helper_method :milestoneable_path
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def new
|
||||
@milestone = @milestoneable.milestones.new
|
||||
end
|
||||
|
||||
def create
|
||||
@milestone = @milestoneable.milestones.new(milestone_params)
|
||||
if @milestone.save
|
||||
redirect_to milestoneable_path, notice: t('admin.milestones.create.notice')
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @milestone.update(milestone_params)
|
||||
redirect_to milestoneable_path, notice: t('admin.milestones.update.notice')
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@milestone.destroy
|
||||
redirect_to milestoneable_path, notice: t('admin.milestones.delete.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def milestone_params
|
||||
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
attributes = [:publication_date, :status_id,
|
||||
translation_params(Milestone),
|
||||
image_attributes: image_attributes, documents_attributes: documents_attributes]
|
||||
|
||||
params.require(:milestone).permit(*attributes)
|
||||
end
|
||||
|
||||
def load_milestoneable
|
||||
@milestoneable = milestoneable
|
||||
end
|
||||
|
||||
def milestoneable
|
||||
raise "Implement in subclass"
|
||||
end
|
||||
|
||||
def load_milestone
|
||||
@milestone = @milestoneable.milestones.find(params[:id])
|
||||
end
|
||||
|
||||
def load_statuses
|
||||
@statuses = Milestone::Status.all
|
||||
end
|
||||
|
||||
def milestoneable_path
|
||||
polymorphic_path([:admin, *resource_hierarchy_for(@milestone.milestoneable)])
|
||||
end
|
||||
end
|
||||
@@ -6,7 +6,7 @@ module Budgets
|
||||
|
||||
def show
|
||||
authorize! :read_executions, @budget
|
||||
@statuses = ::Budget::Investment::Status.all
|
||||
@statuses = Milestone::Status.all
|
||||
|
||||
if params[:status].present?
|
||||
@investments_by_heading = @budget.investments.winners
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module Budgets
|
||||
class InvestmentsController < ApplicationController
|
||||
OSM_DISTRICT_LEVEL_ZOOM = 12
|
||||
|
||||
include FeatureFlags
|
||||
include CommentableActions
|
||||
include FlagActions
|
||||
@@ -33,13 +35,17 @@ module Budgets
|
||||
respond_to :html, :js
|
||||
|
||||
def index
|
||||
if @budget.finished?
|
||||
@investments = investments.winners.page(params[:page]).per(10).for_render
|
||||
else
|
||||
@investments = investments.page(params[:page]).per(10).for_render
|
||||
end
|
||||
all_investments = if @budget.finished?
|
||||
investments.winners
|
||||
else
|
||||
investments
|
||||
end
|
||||
|
||||
@investments = all_investments.page(params[:page]).per(10).for_render
|
||||
|
||||
@investment_ids = @investments.pluck(:id)
|
||||
@investments_map_coordinates = MapLocation.where(investment_id: all_investments).map { |l| l.json_data }
|
||||
|
||||
load_investment_votes(@investments)
|
||||
@tag_cloud = tag_cloud
|
||||
end
|
||||
@@ -143,6 +149,7 @@ module Budgets
|
||||
if params[:heading_id].present?
|
||||
@heading = @budget.headings.find(params[:heading_id])
|
||||
@assigned_heading = @ballot.try(:heading_for_group, @heading.try(:group))
|
||||
load_map
|
||||
end
|
||||
end
|
||||
|
||||
@@ -172,6 +179,13 @@ module Budgets
|
||||
end
|
||||
end
|
||||
|
||||
def load_map
|
||||
@map_location = MapLocation.new
|
||||
@map_location.zoom = OSM_DISTRICT_LEVEL_ZOOM
|
||||
@map_location.latitude = @heading.latitude.to_f
|
||||
@map_location.longitude = @heading.longitude.to_f
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -117,13 +117,12 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def set_random_seed
|
||||
seed = begin
|
||||
Float(params[:random_seed] || session[:random_seed] || (rand(99) / 100.0))
|
||||
rescue
|
||||
0
|
||||
end
|
||||
session[:random_seed], params[:random_seed] = seed
|
||||
seed = (params[:random_seed] || session[:random_seed] || rand).to_f
|
||||
seed = (-1..1).cover?(seed) ? seed : 1
|
||||
|
||||
session[:random_seed] = seed
|
||||
params[:random_seed] = seed
|
||||
|
||||
::Legislation::Proposal.connection.execute "select setseed(#{seed})"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,8 +44,7 @@ class ProposalsController < ApplicationController
|
||||
def index_customization
|
||||
discard_archived
|
||||
load_retired
|
||||
load_successful_proposals
|
||||
load_featured unless @proposal_successful_exists
|
||||
load_featured
|
||||
end
|
||||
|
||||
def vote
|
||||
@@ -131,10 +130,13 @@ class ProposalsController < ApplicationController
|
||||
|
||||
def load_featured
|
||||
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank? && @current_order != "recommendations"
|
||||
@featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3)
|
||||
if @featured_proposals.present?
|
||||
set_featured_proposal_votes(@featured_proposals)
|
||||
@resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id))
|
||||
if Setting['feature.featured_proposals']
|
||||
@featured_proposals = Proposal.not_archived.unsuccessful
|
||||
.sort_by_confidence_score.limit(Setting['featured_proposals_number'])
|
||||
if @featured_proposals.present?
|
||||
set_featured_proposal_votes(@featured_proposals)
|
||||
@resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -142,10 +144,6 @@ class ProposalsController < ApplicationController
|
||||
@view = (params[:view] == "minimal") ? "minimal" : "default"
|
||||
end
|
||||
|
||||
def load_successful_proposals
|
||||
@proposal_successful_exists = Proposal.successful.exists?
|
||||
end
|
||||
|
||||
def destroy_map_location_association
|
||||
map_location = params[:proposal][:map_location_attributes]
|
||||
if map_location && (map_location[:longitude] && map_location[:latitude]).blank? && !map_location[:id].blank?
|
||||
|
||||
Reference in New Issue
Block a user