Fix linelenght over 100 on multiple files
This commit is contained in:
@@ -44,11 +44,13 @@ class CommentsController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def comment_params
|
def comment_params
|
||||||
params.require(:comment).permit(:commentable_type, :commentable_id, :parent_id, :body, :as_moderator, :as_administrator)
|
params.require(:comment).permit(:commentable_type, :commentable_id, :parent_id,
|
||||||
|
:body, :as_moderator, :as_administrator)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_comment
|
def build_comment
|
||||||
@comment = Comment.build(@commentable, current_user, comment_params[:body], comment_params[:parent_id].presence)
|
@comment = Comment.build(@commentable, current_user, comment_params[:body],
|
||||||
|
comment_params[:parent_id].presence)
|
||||||
check_for_special_comments
|
check_for_special_comments
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -61,30 +63,32 @@ class CommentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def load_commentable
|
def load_commentable
|
||||||
@commentable = Comment.find_commentable(comment_params[:commentable_type], comment_params[:commentable_id])
|
@commentable = Comment.find_commentable(comment_params[:commentable_type],
|
||||||
|
comment_params[:commentable_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def administrator_comment?
|
def administrator_comment?
|
||||||
["1", true].include?(comment_params[:as_administrator]) && can?(:comment_as_administrator, @commentable)
|
["1", true].include?(comment_params[:as_administrator]) &&
|
||||||
|
can?(:comment_as_administrator, @commentable)
|
||||||
end
|
end
|
||||||
|
|
||||||
def moderator_comment?
|
def moderator_comment?
|
||||||
["1", true].include?(comment_params[:as_moderator]) && can?(:comment_as_moderator, @commentable)
|
["1", true].include?(comment_params[:as_moderator]) &&
|
||||||
|
can?(:comment_as_moderator, @commentable)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_notification(comment)
|
def add_notification(comment)
|
||||||
if comment.reply?
|
notifiable = comment.reply? ? comment.parent : comment.commentable
|
||||||
notifiable = comment.parent
|
unless comment.author_id == notifiable.author_id
|
||||||
else
|
Notification.add(notifiable.author_id, notifiable)
|
||||||
notifiable = comment.commentable
|
|
||||||
end
|
end
|
||||||
Notification.add(notifiable.author_id, notifiable) unless comment.author_id == notifiable.author_id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_resident_for_commentable!
|
def verify_resident_for_commentable!
|
||||||
return if current_user.administrator? || current_user.moderator?
|
return if current_user.administrator? || current_user.moderator?
|
||||||
|
|
||||||
if @commentable.respond_to?(:comments_for_verified_residents_only?) && @commentable.comments_for_verified_residents_only?
|
if @commentable.respond_to?(:comments_for_verified_residents_only?) &&
|
||||||
|
@commentable.comments_for_verified_residents_only?
|
||||||
verify_resident!
|
verify_resident!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
Activity.log(current_user, :valuate, @investment)
|
Activity.log(current_user, :valuate, @investment)
|
||||||
redirect_to valuation_budget_budget_investment_path(@budget, @investment), notice: t('valuation.budget_investments.notice.valuate')
|
notice = t('valuation.budget_investments.notice.valuate')
|
||||||
|
redirect_to valuation_budget_budget_investment_path(@budget, @investment), notice: notice
|
||||||
else
|
else
|
||||||
render action: :edit
|
render action: :edit
|
||||||
end
|
end
|
||||||
@@ -46,7 +47,8 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def heading_filters
|
def heading_filters
|
||||||
investments = @budget.investments.by_valuator(current_user.valuator.try(:id)).valuation_open.select(:heading_id).all.to_a
|
investments = @budget.investments.by_valuator(current_user.valuator.try(:id))
|
||||||
|
.valuation_open.select(:heading_id).all.to_a
|
||||||
|
|
||||||
[ { name: t('valuation.budget_investments.index.headings_filter_all'),
|
[ { name: t('valuation.budget_investments.index.headings_filter_all'),
|
||||||
id: nil,
|
id: nil,
|
||||||
@@ -61,17 +63,20 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def params_for_current_valuator
|
def params_for_current_valuator
|
||||||
Budget::Investment.filter_params(params).merge(valuator_id: current_user.valuator.id, budget_id: @budget.id)
|
params = { valuator_id: current_user.valuator.id, budget_id: @budget.id }
|
||||||
|
Budget::Investment.filter_params(params).merge(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def valuation_params
|
def valuation_params
|
||||||
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation, :feasibility, :unfeasibility_explanation,
|
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation,
|
||||||
|
:feasibility, :unfeasibility_explanation,
|
||||||
:duration, :valuation_finished, :internal_comments)
|
:duration, :valuation_finished, :internal_comments)
|
||||||
end
|
end
|
||||||
|
|
||||||
def restrict_access_to_assigned_items
|
def restrict_access_to_assigned_items
|
||||||
return if current_user.administrator? ||
|
return if current_user.administrator? ||
|
||||||
Budget::ValuatorAssignment.exists?(investment_id: params[:id], valuator_id: current_user.valuator.id)
|
Budget::ValuatorAssignment.exists?(investment_id: params[:id],
|
||||||
|
valuator_id: current_user.valuator.id)
|
||||||
raise ActionController::RoutingError.new('Not Found')
|
raise ActionController::RoutingError.new('Not Found')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ class Comment < ActiveRecord::Base
|
|||||||
include Graphqlable
|
include Graphqlable
|
||||||
include Notifiable
|
include Notifiable
|
||||||
|
|
||||||
COMMENTABLE_TYPES = %w(Debate Proposal Budget::Investment Poll Topic Legislation::Question Legislation::Annotation Legislation::Proposal).freeze
|
COMMENTABLE_TYPES = %w(Debate Proposal Budget::Investment Poll Topic Legislation::Question
|
||||||
|
Legislation::Annotation Legislation::Proposal).freeze
|
||||||
|
|
||||||
acts_as_paranoid column: :hidden_at
|
acts_as_paranoid column: :hidden_at
|
||||||
include ActsAsParanoidAliases
|
include ActsAsParanoidAliases
|
||||||
@@ -27,7 +28,9 @@ class Comment < ActiveRecord::Base
|
|||||||
|
|
||||||
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
||||||
scope :with_visible_author, -> { joins(:user).where("users.hidden_at IS NULL") }
|
scope :with_visible_author, -> { joins(:user).where("users.hidden_at IS NULL") }
|
||||||
scope :not_as_admin_or_moderator, -> { where("administrator_id IS NULL").where("moderator_id IS NULL")}
|
scope :not_as_admin_or_moderator, -> do
|
||||||
|
where("administrator_id IS NULL").where("moderator_id IS NULL")
|
||||||
|
end
|
||||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||||
scope :public_for_api, -> do
|
scope :public_for_api, -> do
|
||||||
where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or
|
where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
<%= t("comments.verified_only", verify_account: link_to(t("comments.verify_account"), verification_path )).html_safe %>
|
<%= t("comments.verified_only", verify_account: link_to(t("comments.verify_account"), verification_path )).html_safe %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render 'comments/form', {commentable: commentable, parent_id: nil, toggeable: false} %>
|
<%= render 'comments/form', { commentable: commentable,
|
||||||
|
parent_id: nil,
|
||||||
|
toggeable: false } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user