Merge pull request #3318 from consul/backport-refactor_investments_index

Show all investments in the map
This commit is contained in:
Javier Martín
2019-02-20 11:49:06 +01:00
committed by GitHub
2 changed files with 25 additions and 5 deletions

View File

@@ -6,6 +6,8 @@ module Budgets
include FlagActions
include ImageAttributes
PER_PAGE = 10
before_action :authenticate_user!, except: [:index, :show, :json_data]
load_and_authorize_resource :budget, except: :json_data
@@ -37,7 +39,7 @@ module Budgets
respond_to :html, :js
def index
@investments = investments.page(params[:page]).per(10).for_render
@investments = investments.page(params[:page]).per(PER_PAGE).for_render
@investment_ids = @investments.pluck(:id)
@investments_map_coordinates = MapLocation.where(investment: investments).map(&:json_data)
@@ -167,11 +169,11 @@ module Budgets
def investments
if @current_order == 'random'
@investments.apply_filters_and_search(@budget, params, @current_filter)
.send("sort_by_#{@current_order}", params[:random_seed])
@budget.investments.apply_filters_and_search(@budget, params, @current_filter)
.send("sort_by_#{@current_order}", params[:random_seed])
else
@investments.apply_filters_and_search(@budget, params, @current_filter)
.send("sort_by_#{@current_order}")
@budget.investments.apply_filters_and_search(@budget, params, @current_filter)
.send("sort_by_#{@current_order}")
end
end