Fix all rubocop Metrics/LineLength issues (140+)
This commit is contained in:
@@ -23,10 +23,12 @@ class AccountController < ApplicationController
|
||||
|
||||
def account_params
|
||||
if @account.organization?
|
||||
params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name])
|
||||
params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter,
|
||||
organization_attributes: [:name, :responsible_name])
|
||||
else
|
||||
params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter, :official_position_badge)
|
||||
params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply,
|
||||
:email_on_direct_message, :email_digest, :newsletter, :official_position_badge)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,8 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
|
||||
|
||||
def create
|
||||
if @draft_version.save
|
||||
redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe)
|
||||
link = legislation_process_draft_version_path(@process, @draft_version).html_safe
|
||||
redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice', link: link)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.draft_versions.create.error')
|
||||
render :new
|
||||
@@ -17,7 +18,9 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
|
||||
|
||||
def update
|
||||
if @draft_version.update(draft_version_params)
|
||||
redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: t('admin.legislation.draft_versions.update.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe)
|
||||
link = legislation_process_draft_version_path(@process, @draft_version).html_safe
|
||||
notice = t('admin.legislation.draft_versions.update.notice', link: link)
|
||||
redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: notice
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.draft_versions.update.error')
|
||||
render :edit
|
||||
|
||||
@@ -9,7 +9,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
|
||||
def create
|
||||
if @process.save
|
||||
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice', link: legislation_process_path(@process).html_safe)
|
||||
link = legislation_process_path(@process).html_safe
|
||||
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice', link: link)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.processes.create.error')
|
||||
render :new
|
||||
@@ -18,7 +19,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
|
||||
def update
|
||||
if @process.update(process_params)
|
||||
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: legislation_process_path(@process).html_safe)
|
||||
link = legislation_process_path(@process).html_safe
|
||||
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: link)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.processes.update.error')
|
||||
render :edit
|
||||
|
||||
@@ -13,7 +13,8 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
|
||||
def create
|
||||
@question.author = current_user
|
||||
if @question.save
|
||||
redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.create.notice', link: legislation_process_question_path(@process, @question).html_safe)
|
||||
notice = t('admin.legislation.questions.create.notice', link: legislation_process_question_path(@process, @question).html_safe)
|
||||
redirect_to admin_legislation_process_questions_path, notice: notice
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.questions.create.error')
|
||||
render :new
|
||||
@@ -22,7 +23,8 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
|
||||
|
||||
def update
|
||||
if @question.update(question_params)
|
||||
redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: t('admin.legislation.questions.update.notice', link: legislation_process_question_path(@process, @question).html_safe)
|
||||
notice = t('admin.legislation.questions.update.notice', link: legislation_process_question_path(@process, @question).html_safe)
|
||||
redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: notice
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.questions.update.error')
|
||||
render :edit
|
||||
|
||||
@@ -15,12 +15,14 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def show
|
||||
@booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id])
|
||||
@booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters,
|
||||
officer_assignments: [officer: [:user]]).find(params[:id])
|
||||
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
|
||||
end
|
||||
|
||||
def create
|
||||
@booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll_id], booth_id: booth_assignment_params[:booth_id])
|
||||
@booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll_id],
|
||||
booth_id: booth_assignment_params[:booth_id])
|
||||
|
||||
if @booth_assignment.save
|
||||
notice = t("admin.poll_booth_assignments.flash.create")
|
||||
@@ -63,4 +65,4 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
|
||||
@search = search_params[:search]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,7 +43,9 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
|
||||
else
|
||||
notice = t("admin.poll_officer_assignments.flash.error_create")
|
||||
end
|
||||
redirect_to by_officer_admin_poll_officer_assignments_path(poll_id: create_params[:poll_id], officer_id: create_params[:officer_id]), notice: notice
|
||||
|
||||
redirect_params = { poll_id: create_params[:poll_id], officer_id: create_params[:officer_id] }
|
||||
redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -54,7 +56,9 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
|
||||
else
|
||||
notice = t("admin.poll_officer_assignments.flash.error_destroy")
|
||||
end
|
||||
redirect_to by_officer_admin_poll_officer_assignments_path(poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id), notice: notice
|
||||
|
||||
redirect_params = { poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id }
|
||||
redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice
|
||||
end
|
||||
|
||||
private
|
||||
@@ -68,7 +72,8 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def load_booth_assignment
|
||||
@booth_assignment = ::Poll::BoothAssignment.includes(:poll).find_by(poll_id: create_params[:poll_id], booth_id: create_params[:booth_id])
|
||||
find_params = { poll_id: create_params[:poll_id], booth_id: create_params[:booth_id] }
|
||||
@booth_assignment = ::Poll::BoothAssignment.includes(:poll).find_by(find_params)
|
||||
end
|
||||
|
||||
def load_poll
|
||||
@@ -89,4 +94,4 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
|
||||
@search = search_params[:search]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,9 @@ class Admin::SpendingProposalsController < Admin::BaseController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@spending_proposals = SpendingProposal.scoped_filter(params, @current_filter).order(cached_votes_up: :desc, created_at: :desc).page(params[:page])
|
||||
@spending_proposals = SpendingProposal.scoped_filter(params, @current_filter)
|
||||
.order(cached_votes_up: :desc, created_at: :desc)
|
||||
.page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -33,13 +35,15 @@ class Admin::SpendingProposalsController < Admin::BaseController
|
||||
|
||||
def summary
|
||||
@spending_proposals = SpendingProposal.group(:geozone).sum(:price).sort_by{|geozone, count| geozone.present? ? geozone.name : "z"}
|
||||
@spending_proposals_with_supports = SpendingProposal.with_supports.group(:geozone).sum(:price).sort_by{|geozone, count| geozone.present? ? geozone.name : "z"}
|
||||
@spending_proposals_with_supports = SpendingProposal.with_supports.group(:geozone).sum(:price)
|
||||
.sort_by{|geozone, count| geozone.present? ? geozone.name : "z"}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def spending_proposal_params
|
||||
params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, :administrator_id, :tag_list, valuator_ids: [])
|
||||
params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name,
|
||||
:administrator_id, :tag_list, valuator_ids: [])
|
||||
end
|
||||
|
||||
def load_admins
|
||||
@@ -54,4 +58,4 @@ class Admin::SpendingProposalsController < Admin::BaseController
|
||||
@tags = ActsAsTaggableOn::Tag.spending_proposal_tags
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,8 @@ module Budgets
|
||||
respond_to :html, :js
|
||||
|
||||
def index
|
||||
@investments = @investments.apply_filters_and_search(@budget, params, @current_filter).send("sort_by_#{@current_order}").page(params[:page]).per(10).for_render
|
||||
@investments = @investments.apply_filters_and_search(@budget, params, @current_filter)
|
||||
.send("sort_by_#{@current_order}").page(params[:page]).per(10).for_render
|
||||
@investment_ids = @investments.pluck(:id)
|
||||
load_investment_votes(@investments)
|
||||
@tag_cloud = tag_cloud
|
||||
@@ -102,7 +103,8 @@ module Budgets
|
||||
end
|
||||
|
||||
def investment_params
|
||||
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list, :organization_name, :location, :terms_of_service)
|
||||
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list,
|
||||
:organization_name, :location, :terms_of_service)
|
||||
end
|
||||
|
||||
def load_ballot
|
||||
|
||||
@@ -88,7 +88,8 @@ module CommentableActions
|
||||
end
|
||||
|
||||
def set_geozone
|
||||
@resource.geozone = Geozone.find(params[resource_name.to_sym].try(:[], :geozone_id)) if params[resource_name.to_sym].try(:[], :geozone_id).present?
|
||||
geozone_id = params[resource_name.to_sym].try(:[], :geozone_id)
|
||||
@resource.geozone = Geozone.find(geozone_id) if geozone_id.present?
|
||||
end
|
||||
|
||||
def load_categories
|
||||
@@ -109,4 +110,4 @@ module CommentableActions
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,8 +102,9 @@ class Legislation::AnnotationsController < ApplicationController
|
||||
end
|
||||
|
||||
def convert_ranges_parameters
|
||||
if params[:legislation_annotation] && params[:legislation_annotation][:ranges] && params[:legislation_annotation][:ranges].is_a?(String)
|
||||
params[:legislation_annotation][:ranges] = JSON.parse(params[:legislation_annotation][:ranges])
|
||||
annotation = params[:legislation_annotation]
|
||||
if annotation && annotation[:ranges] && annotation[:ranges].is_a?(String)
|
||||
params[:legislation_annotation][:ranges] = JSON.parse(annotation[:ranges])
|
||||
end
|
||||
rescue JSON::ParserError
|
||||
end
|
||||
|
||||
@@ -18,9 +18,10 @@ class Legislation::AnswersController < Legislation::BaseController
|
||||
format.html { redirect_to legislation_process_question_path(@process, @question) }
|
||||
end
|
||||
else
|
||||
alert = t('legislation.questions.participation.phase_not_open')
|
||||
respond_to do |format|
|
||||
format.js { render json: {}, status: :not_found }
|
||||
format.html { redirect_to legislation_process_question_path(@process, @question), alert: t('legislation.questions.participation.phase_not_open') }
|
||||
format.html { redirect_to legislation_process_question_path(@process, @question), alert: alert }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,7 +43,8 @@ class Management::DocumentVerificationsController < Management::BaseController
|
||||
end
|
||||
|
||||
def clean_document_number
|
||||
params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase unless params[:document_verification][:document_number].blank?
|
||||
return if params[:document_verification][:document_number].blank?
|
||||
params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,7 +34,8 @@ class Management::ProposalsController < Management::BaseController
|
||||
end
|
||||
|
||||
def proposal_params
|
||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id)
|
||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url,
|
||||
:responsible_name, :tag_list, :terms_of_service, :geozone_id)
|
||||
end
|
||||
|
||||
def resource_model
|
||||
@@ -53,4 +54,4 @@ class Management::ProposalsController < Management::BaseController
|
||||
@comment_flags = managed_user ? managed_user.comment_flags(comments) : {}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,8 @@ class Management::SpendingProposalsController < Management::BaseController
|
||||
@spending_proposal.author = managed_user
|
||||
|
||||
if @spending_proposal.save
|
||||
redirect_to management_spending_proposal_path(@spending_proposal), notice: t('flash.actions.create.notice', resource_name: t("activerecord.models.spending_proposal", count: 1))
|
||||
notice = t('flash.actions.create.notice', resource_name: t("activerecord.models.spending_proposal", count: 1))
|
||||
redirect_to management_spending_proposal_path(@spending_proposal), notice: notice
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
||||
@@ -15,7 +15,8 @@ class Officing::FinalRecountsController < Officing::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
@final_recount = ::Poll::FinalRecount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, date: final_recount_params[:date])
|
||||
@final_recount = ::Poll::FinalRecount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: final_recount_params[:date])
|
||||
@final_recount.officer_assignment_id = @officer_assignment.id
|
||||
@final_recount.count = final_recount_params[:count]
|
||||
|
||||
@@ -45,4 +46,4 @@ class Officing::FinalRecountsController < Officing::BaseController
|
||||
params.permit(:officer_assignment_id, :count, :date)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,8 @@ class Officing::RecountsController < Officing::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
@recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, date: @officer_assignment.date)
|
||||
@recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: @officer_assignment.date)
|
||||
@recount.officer_assignment_id = @officer_assignment.id
|
||||
@recount.count = recount_params[:count]
|
||||
|
||||
@@ -44,4 +45,4 @@ class Officing::RecountsController < Officing::BaseController
|
||||
params.permit(:officer_assignment_id, :count)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -126,7 +126,8 @@ class Officing::ResultsController < Officing::BaseController
|
||||
|
||||
def load_partial_results
|
||||
if @officer_assignments.present?
|
||||
@partial_results = ::Poll::PartialResult.where(officer_assignment_id: @officer_assignments.map(&:id)).order(:booth_assignment_id, :date)
|
||||
@partial_results = ::Poll::PartialResult.where(officer_assignment_id: @officer_assignments.map(&:id))
|
||||
.order(:booth_assignment_id, :date)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ class Organizations::RegistrationsController < Devise::RegistrationsController
|
||||
private
|
||||
|
||||
def sign_up_params
|
||||
params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :terms_of_service, organization_attributes: [:name, :responsible_name])
|
||||
params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :terms_of_service,
|
||||
organization_attributes: [:name, :responsible_name])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -74,7 +74,8 @@ class ProposalsController < ApplicationController
|
||||
private
|
||||
|
||||
def proposal_params
|
||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id)
|
||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url,
|
||||
:responsible_name, :tag_list, :terms_of_service, :geozone_id)
|
||||
end
|
||||
|
||||
def retired_params
|
||||
@@ -109,7 +110,8 @@ class ProposalsController < ApplicationController
|
||||
end
|
||||
|
||||
def load_featured
|
||||
@featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?)
|
||||
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?
|
||||
@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))
|
||||
|
||||
@@ -30,7 +30,8 @@ class SpendingProposalsController < ApplicationController
|
||||
@spending_proposal.author = current_user
|
||||
|
||||
if @spending_proposal.save
|
||||
notice = t('flash.actions.create.spending_proposal', activity: "<a href='#{user_path(current_user, filter: :spending_proposals)}'>#{t('layouts.header.my_activity_link')}</a>")
|
||||
activity = "<a href='#{user_path(current_user, filter: :spending_proposals)}'>#{t('layouts.header.my_activity_link')}</a>"
|
||||
notice = t('flash.actions.create.spending_proposal', activity: activity)
|
||||
redirect_to @spending_proposal, notice: notice, flash: { html_safe: true }
|
||||
else
|
||||
render :new
|
||||
|
||||
@@ -12,11 +12,13 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
|
||||
def index
|
||||
@heading_filters = heading_filters
|
||||
if current_user.valuator? && @budget.present?
|
||||
@investments = @budget.investments.scoped_filter(params_for_current_valuator, @current_filter).order(cached_votes_up: :desc).page(params[:page])
|
||||
else
|
||||
@investments = Budget::Investment.none.page(params[:page])
|
||||
end
|
||||
@investments = if current_user.valuator? && @budget.present?
|
||||
@budget.investments.scoped_filter(params_for_current_valuator, @current_filter)
|
||||
.order(cached_votes_up: :desc)
|
||||
.page(params[:page])
|
||||
else
|
||||
Budget::Investment.none.page(params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
def valuate
|
||||
@@ -63,11 +65,14 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
end
|
||||
|
||||
def valuation_params
|
||||
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation, :feasibility, :unfeasibility_explanation, :duration, :valuation_finished, :internal_comments)
|
||||
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation, :feasibility, :unfeasibility_explanation,
|
||||
:duration, :valuation_finished, :internal_comments)
|
||||
end
|
||||
|
||||
def restrict_access_to_assigned_items
|
||||
raise ActionController::RoutingError.new('Not Found') unless current_user.administrator? || Budget::ValuatorAssignment.exists?(investment_id: params[:id], valuator_id: current_user.valuator.id)
|
||||
return if current_user.administrator? ||
|
||||
Budget::ValuatorAssignment.exists?(investment_id: params[:id], valuator_id: current_user.valuator.id)
|
||||
raise ActionController::RoutingError.new('Not Found')
|
||||
end
|
||||
|
||||
def valid_price_params?
|
||||
|
||||
@@ -10,11 +10,13 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
|
||||
|
||||
def index
|
||||
@geozone_filters = geozone_filters
|
||||
if current_user.valuator?
|
||||
@spending_proposals = SpendingProposal.scoped_filter(params_for_current_valuator, @current_filter).order(cached_votes_up: :desc).page(params[:page])
|
||||
else
|
||||
@spending_proposals = SpendingProposal.none.page(params[:page])
|
||||
end
|
||||
@spending_proposals = if current_user.valuator?
|
||||
SpendingProposal.scoped_filter(params_for_current_valuator, @current_filter)
|
||||
.order(cached_votes_up: :desc)
|
||||
.page(params[:page])
|
||||
else
|
||||
SpendingProposal.none.page(params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
def valuate
|
||||
@@ -54,7 +56,8 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
|
||||
def valuation_params
|
||||
params[:spending_proposal][:feasible] = nil if params[:spending_proposal][:feasible] == 'nil'
|
||||
|
||||
params.require(:spending_proposal).permit(:price, :price_first_year, :price_explanation, :feasible, :feasible_explanation, :time_scope, :valuation_finished, :internal_comments)
|
||||
params.require(:spending_proposal).permit(:price, :price_first_year, :price_explanation, :feasible, :feasible_explanation,
|
||||
:time_scope, :valuation_finished, :internal_comments)
|
||||
end
|
||||
|
||||
def params_for_current_valuator
|
||||
@@ -62,7 +65,9 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
|
||||
end
|
||||
|
||||
def restrict_access_to_assigned_items
|
||||
raise ActionController::RoutingError.new('Not Found') unless current_user.administrator? || ValuationAssignment.exists?(spending_proposal_id: params[:id], valuator_id: current_user.valuator.id)
|
||||
return if current_user.administrator? ||
|
||||
ValuationAssignment.exists?(spending_proposal_id: params[:id], valuator_id: current_user.valuator.id)
|
||||
raise ActionController::RoutingError.new('Not Found')
|
||||
end
|
||||
|
||||
def valid_price_params?
|
||||
@@ -77,4 +82,4 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
|
||||
@spending_proposal.errors.empty?
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,7 +78,9 @@ module CommentsHelper
|
||||
def require_verified_resident_for_commentable?(commentable, current_user)
|
||||
return false if current_user.administrator? || current_user.moderator?
|
||||
|
||||
commentable.respond_to?(:comments_for_verified_residents_only?) && commentable.comments_for_verified_residents_only? && !current_user.residence_verified?
|
||||
commentable.respond_to?(:comments_for_verified_residents_only?) &&
|
||||
commentable.comments_for_verified_residents_only? &&
|
||||
!current_user.residence_verified?
|
||||
end
|
||||
|
||||
def comments_closed_for_commentable?(commentable)
|
||||
|
||||
@@ -2,7 +2,9 @@ module ValuationHelper
|
||||
|
||||
def valuator_select_options(valuator = nil)
|
||||
if valuator.present?
|
||||
Valuator.where.not(id: valuator.id).order("description ASC").order("users.email ASC").includes(:user).collect { |v| [ v.description_or_email, v.id ] }.prepend([valuator.description_or_email, valuator.id])
|
||||
Valuator.where.not(id: valuator.id).order("description ASC").order("users.email ASC")
|
||||
.includes(:user).collect { |v| [ v.description_or_email, v.id ] }
|
||||
.prepend([valuator.description_or_email, valuator.id])
|
||||
else
|
||||
Valuator.all.order("description ASC").order("users.email ASC").includes(:user).collect { |v| [ v.description_or_email, v.id ] }
|
||||
end
|
||||
@@ -27,4 +29,4 @@ module ValuationHelper
|
||||
simple_format_no_tags_no_sanitize(safe_html_with_links(field.html_safe)) if field.present?
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,8 @@ class Mailer < ApplicationMailer
|
||||
@email_to = @commentable.author.email
|
||||
|
||||
with_user(@commentable.author) do
|
||||
mail(to: @email_to, subject: t('mailers.comment.subject', commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase)) if @commentable.present? && @commentable.author.present?
|
||||
subject = t('mailers.comment.subject', commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase)
|
||||
mail(to: @email_to, subject: subject) if @commentable.present? && @commentable.author.present?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ module Abilities
|
||||
can :mark_featured, Debate
|
||||
can :unmark_featured, Debate
|
||||
|
||||
can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment, Legislation::Question, Legislation::Annotation]
|
||||
can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment,
|
||||
Legislation::Question, Legislation::Annotation]
|
||||
|
||||
can [:search, :create, :index, :destroy], ::Administrator
|
||||
can [:search, :create, :index, :destroy], ::Moderator
|
||||
|
||||
@@ -5,7 +5,8 @@ module Abilities
|
||||
def initialize(user)
|
||||
merge Abilities::Moderation.new(user)
|
||||
|
||||
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question, Legislation::Question, Legislation::Annotation]
|
||||
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question,
|
||||
Legislation::Question, Legislation::Annotation]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,7 +22,8 @@ class Budget
|
||||
end
|
||||
|
||||
def check_valid_heading
|
||||
errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected") unless ballot.valid_heading?(heading)
|
||||
return if ballot.valid_heading?(heading)
|
||||
errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected")
|
||||
end
|
||||
|
||||
def check_selected
|
||||
|
||||
@@ -3,6 +3,8 @@ class Comment < ActiveRecord::Base
|
||||
include HasPublicAuthor
|
||||
include Graphqlable
|
||||
|
||||
COMMENTABLE_TYPES = %w(Debate Proposal Budget::Investment Poll::Question Legislation::Question Legislation::Annotation).freeze
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
acts_as_votable
|
||||
@@ -13,7 +15,7 @@ class Comment < ActiveRecord::Base
|
||||
validates :body, presence: true
|
||||
validates :user, presence: true
|
||||
|
||||
validates :commentable_type, inclusion: { in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] }
|
||||
validates :commentable_type, inclusion: { in: COMMENTABLE_TYPES }
|
||||
|
||||
validate :validate_body_length
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@ class Legislation::Answer < ActiveRecord::Base
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id', inverse_of: :answers, counter_cache: true
|
||||
belongs_to :question_option, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_option_id', inverse_of: :answers, counter_cache: true
|
||||
belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id',
|
||||
inverse_of: :answers, counter_cache: true
|
||||
belongs_to :question_option, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_option_id',
|
||||
inverse_of: :answers, counter_cache: true
|
||||
belongs_to :user, dependent: :destroy, inverse_of: :legislation_answers
|
||||
|
||||
validates :question, presence: true, uniqueness: { scope: :user_id}
|
||||
|
||||
@@ -4,8 +4,10 @@ class Legislation::Process < ActiveRecord::Base
|
||||
|
||||
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase draft_publication result_publication).freeze
|
||||
|
||||
has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
has_one :final_draft_version, -> { where final_version: true, status: 'published' }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id'
|
||||
has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion',
|
||||
foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
has_one :final_draft_version, -> { where final_version: true, status: 'published' }, class_name: 'Legislation::DraftVersion',
|
||||
foreign_key: 'legislation_process_id'
|
||||
has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
|
||||
validates :title, presence: true
|
||||
@@ -64,7 +66,9 @@ class Legislation::Process < ActiveRecord::Base
|
||||
def valid_date_ranges
|
||||
errors.add(:end_date, :invalid_date_range) if end_date && start_date && end_date < start_date
|
||||
errors.add(:debate_end_date, :invalid_date_range) if debate_end_date && debate_start_date && debate_end_date < debate_start_date
|
||||
errors.add(:allegations_end_date, :invalid_date_range) if allegations_end_date && allegations_start_date && allegations_end_date < allegations_start_date
|
||||
if allegations_end_date && allegations_start_date && allegations_end_date < allegations_start_date
|
||||
errors.add(:allegations_end_date, :invalid_date_range)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,8 @@ class Legislation::Question < ActiveRecord::Base
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :process, class_name: 'Legislation::Process', foreign_key: 'legislation_process_id'
|
||||
|
||||
has_many :question_options, -> { order(:id) }, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question
|
||||
has_many :question_options, -> { order(:id) }, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id',
|
||||
dependent: :destroy, inverse_of: :question
|
||||
has_many :answers, class_name: 'Legislation::Answer', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question
|
||||
has_many :comments, as: :commentable, dependent: :destroy
|
||||
|
||||
|
||||
@@ -35,7 +35,11 @@ class Organization < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.search(text)
|
||||
text.present? ? joins(:user).where("users.email = ? OR users.phone_number = ? OR organizations.name ILIKE ?", text, text, "%#{text}%") : none
|
||||
if text.present?
|
||||
joins(:user).where("users.email = ? OR users.phone_number = ? OR organizations.name ILIKE ?", text, text, "%#{text}%")
|
||||
else
|
||||
none
|
||||
end
|
||||
end
|
||||
|
||||
def self.name_max_length
|
||||
|
||||
@@ -14,8 +14,10 @@ class ProposalNotification < ActiveRecord::Base
|
||||
|
||||
def minimum_interval
|
||||
return true if proposal.try(:notifications).blank?
|
||||
if proposal.notifications.last.created_at > (Time.current - Setting[:proposal_notification_minimum_interval_in_days].to_i.days).to_datetime
|
||||
errors.add(:title, I18n.t('activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid', interval: Setting[:proposal_notification_minimum_interval_in_days]))
|
||||
interval = Setting[:proposal_notification_minimum_interval_in_days]
|
||||
minimum_interval = (Time.current - interval.to_i.days).to_datetime
|
||||
if proposal.notifications.last.created_at > minimum_interval
|
||||
errors.add(:title, I18n.t('activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid', interval: interval))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ class Verification::Residence
|
||||
end
|
||||
|
||||
def allowed_age
|
||||
return if errors[:date_of_birth].any?
|
||||
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless Age.in_years(date_of_birth) >= User.minimum_required_age
|
||||
return if errors[:date_of_birth].any? || Age.in_years(date_of_birth) >= User.minimum_required_age
|
||||
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age'))
|
||||
end
|
||||
|
||||
def document_number_uniqueness
|
||||
|
||||
Reference in New Issue
Block a user