Merge branch 'master' into remove_investments_internal_comments
This commit is contained in:
@@ -61,12 +61,13 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def load_investments
|
||||
if params[:project_title].present?
|
||||
@investments = Budget::Investment.where("title ILIKE ?", "%#{params[:project_title].strip}%")
|
||||
else
|
||||
@investments = Budget::Investment.scoped_filter(params, @current_filter)
|
||||
@investments = if params[:project_title].present?
|
||||
Budget::Investment.where("title ILIKE ?",
|
||||
"%#{params[:project_title].strip}%")
|
||||
else
|
||||
Budget::Investment.scoped_filter(params, @current_filter)
|
||||
.order(sort_by(params[:sort_by]))
|
||||
end
|
||||
end
|
||||
@investments = @investments.page(params[:page]) unless request.format.csv?
|
||||
end
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ class BudgetsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@budgets = @budgets.order(created_at: :desc)
|
||||
@budget = current_budget
|
||||
@finished_budgets = @budgets.finished.order(created_at: :desc)
|
||||
@budgets_coordinates = current_budget_map_locations
|
||||
end
|
||||
|
||||
|
||||
@@ -45,12 +45,13 @@ class CommentsController < ApplicationController
|
||||
|
||||
def comment_params
|
||||
params.require(:comment).permit(:commentable_type, :commentable_id, :parent_id,
|
||||
:body, :as_moderator, :as_administrator)
|
||||
:body, :as_moderator, :as_administrator, :valuation)
|
||||
end
|
||||
|
||||
def build_comment
|
||||
@comment = Comment.build(@commentable, current_user, comment_params[:body],
|
||||
comment_params[:parent_id].presence)
|
||||
comment_params[:parent_id].presence,
|
||||
comment_params[:valuation])
|
||||
check_for_special_comments
|
||||
end
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
include FeatureFlags
|
||||
include CommentableActions
|
||||
|
||||
feature_flag :budgets
|
||||
|
||||
before_action :restrict_access_to_assigned_items, only: [:show, :edit, :valuate]
|
||||
before_action :load_budget
|
||||
before_action :load_investment, only: [:show, :edit, :valuate]
|
||||
|
||||
has_orders %w{oldest}, only: [:show, :edit]
|
||||
has_filters %w{valuating valuation_finished}, only: :index
|
||||
|
||||
load_and_authorize_resource :investment, class: "Budget::Investment"
|
||||
@@ -36,8 +39,30 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
load_comments
|
||||
end
|
||||
|
||||
def edit
|
||||
load_comments
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_comments
|
||||
@commentable = @investment
|
||||
@comment_tree = CommentTree.new(@commentable, params[:page], @current_order, valuations: true)
|
||||
set_comment_flags(@comment_tree.comments)
|
||||
end
|
||||
|
||||
def resource_model
|
||||
Budget::Investment
|
||||
end
|
||||
|
||||
def resource_name
|
||||
resource_model.parameterize('_')
|
||||
end
|
||||
|
||||
def load_budget
|
||||
@budget = Budget.find(params[:budget_id])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user