Merge branch 'master' into remove_investments_internal_comments

This commit is contained in:
BertoCQ
2018-01-31 13:47:15 +01:00
committed by GitHub
94 changed files with 1213 additions and 697 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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