Apply Layout/LineLength rubocop rule
Note we're excluding a few files: * Configuration files that weren't generated by us * Migration files that weren't generated by us * The Gemfile, since it includes an important comment that must be on the same line as the gem declaration * The Budget::Stats class, since the heading statistics are a mess and having shorter lines would require a lot of refactoring
This commit is contained in:
@@ -22,7 +22,8 @@ class Admin::Api::StatsController < Admin::Api::BaseController
|
||||
end
|
||||
|
||||
if params[:user_supported_budgets].present?
|
||||
ds.add "User supported budgets", Vote.where(votable_type: "Budget::Investment").group_by_day(:updated_at).count
|
||||
ds.add "User supported budgets",
|
||||
Vote.where(votable_type: "Budget::Investment").group_by_day(:updated_at).count
|
||||
end
|
||||
render json: ds.build
|
||||
end
|
||||
|
||||
@@ -10,7 +10,9 @@ module Budgets
|
||||
|
||||
authorize_resource :budget
|
||||
authorize_resource :ballot
|
||||
load_and_authorize_resource :line, through: :ballot, find_by: :investment_id, class: "Budget::Ballot::Line"
|
||||
load_and_authorize_resource :line, through: :ballot,
|
||||
find_by: :investment_id,
|
||||
class: "Budget::Ballot::Line"
|
||||
|
||||
def create
|
||||
load_investment
|
||||
|
||||
@@ -28,7 +28,8 @@ module Budgets
|
||||
|
||||
has_orders %w[most_voted newest oldest], only: :show
|
||||
has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index
|
||||
has_filters ->(c) { c.instance_variable_get(:@budget).investments_filters }, only: [:index, :show, :suggest]
|
||||
has_filters ->(c) { c.instance_variable_get(:@budget).investments_filters },
|
||||
only: [:index, :show, :suggest]
|
||||
|
||||
invisible_captcha only: [:create, :update], honeypot: :subtitle, scope: :budget_investment
|
||||
|
||||
@@ -79,12 +80,14 @@ module Budgets
|
||||
|
||||
def destroy
|
||||
@investment.destroy!
|
||||
redirect_to user_path(current_user, filter: "budget_investments"), notice: t("flash.actions.destroy.budget_investment")
|
||||
redirect_to user_path(current_user, filter: "budget_investments"),
|
||||
notice: t("flash.actions.destroy.budget_investment")
|
||||
end
|
||||
|
||||
def suggest
|
||||
@resource_path_method = :namespaced_budget_investment_path
|
||||
@resource_relation = resource_model.where(budget: @budget).apply_filters_and_search(@budget, params, @current_filter)
|
||||
@resource_relation = resource_model.where(budget: @budget)
|
||||
.apply_filters_and_search(@budget, params, @current_filter)
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@ module Admin::BudgetHeadingsActions
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
valid_attributes = [:price, :population, :allow_custom_content, :latitude, :longitude, :max_ballot_lines, :geozone_id]
|
||||
valid_attributes = [:price, :population, :allow_custom_content, :latitude, :longitude,
|
||||
:max_ballot_lines, :geozone_id]
|
||||
|
||||
[*valid_attributes, translation_params(Budget::Heading)]
|
||||
end
|
||||
|
||||
@@ -7,7 +7,11 @@ module CommentableActions
|
||||
def index
|
||||
@resources = resource_model.all
|
||||
|
||||
@resources = @current_order == "recommendations" && current_user.present? ? @resources.recommendations(current_user) : @resources.for_render
|
||||
@resources = if @current_order == "recommendations" && current_user.present?
|
||||
@resources.recommendations(current_user)
|
||||
else
|
||||
@resources.for_render
|
||||
end
|
||||
@resources = @resources.search(@search_terms) if @search_terms.present?
|
||||
@resources = @resources.filter_by(@advanced_search_terms)
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ class DirectUploadsController < ApplicationController
|
||||
helper_method :render_destroy_upload_link
|
||||
|
||||
def create
|
||||
@direct_upload = DirectUpload.new(direct_upload_params.merge(user: current_user, attachment: params[:attachment]))
|
||||
@direct_upload = DirectUpload.new(
|
||||
direct_upload_params.merge(user: current_user, attachment: params[:attachment])
|
||||
)
|
||||
|
||||
if @direct_upload.valid?
|
||||
@direct_upload.save_attachment
|
||||
|
||||
@@ -30,7 +30,8 @@ class Legislation::ProposalsController < Legislation::BaseController
|
||||
@proposal = Legislation::Proposal.new(proposal_params.merge(author: current_user))
|
||||
|
||||
if @proposal.save
|
||||
redirect_to legislation_process_proposal_path(params[:process_id], @proposal), notice: I18n.t("flash.actions.create.proposal")
|
||||
redirect_to legislation_process_proposal_path(params[:process_id], @proposal),
|
||||
notice: I18n.t("flash.actions.create.proposal")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
||||
@@ -37,7 +37,10 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
end
|
||||
|
||||
def print
|
||||
@investments = @investments.apply_filters_and_search(@budget, params).order(cached_votes_up: :desc).for_render.limit(15)
|
||||
@investments = @investments.apply_filters_and_search(@budget, params)
|
||||
.order(cached_votes_up: :desc)
|
||||
.for_render
|
||||
.limit(15)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -15,7 +15,9 @@ class Management::DocumentVerificationsController < Management::BaseController
|
||||
elsif @document_verification.user?
|
||||
render :new
|
||||
elsif @document_verification.in_census?
|
||||
redirect_to new_management_email_verification_path(email_verification: document_verification_params.to_h)
|
||||
redirect_to new_management_email_verification_path(
|
||||
email_verification: document_verification_params.to_h
|
||||
)
|
||||
else
|
||||
render :invalid_document
|
||||
end
|
||||
@@ -49,6 +51,8 @@ class Management::DocumentVerificationsController < Management::BaseController
|
||||
def clean_document_number
|
||||
return if params[:document_verification][:document_number].blank?
|
||||
|
||||
params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase
|
||||
params[:document_verification][:document_number] = params[:document_verification][:document_number]
|
||||
.gsub(/[^a-z0-9]+/i, "")
|
||||
.upcase
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,7 +31,9 @@ class Management::ProposalsController < Management::BaseController
|
||||
super
|
||||
@notifications = @proposal.notifications
|
||||
|
||||
redirect_to management_proposal_path(@proposal), status: :moved_permanently if request.path != management_proposal_path(@proposal)
|
||||
if request.path != management_proposal_path(@proposal)
|
||||
redirect_to management_proposal_path(@proposal), status: :moved_permanently
|
||||
end
|
||||
end
|
||||
|
||||
def vote
|
||||
|
||||
@@ -24,7 +24,10 @@ class Management::UsersController < Management::BaseController
|
||||
end
|
||||
|
||||
def erase
|
||||
managed_user.erase(t("management.users.erased_by_manager", manager: current_manager["login"])) if current_manager.present?
|
||||
if current_manager.present?
|
||||
managed_user.erase(t("management.users.erased_by_manager", manager: current_manager["login"]))
|
||||
end
|
||||
|
||||
destroy_session
|
||||
redirect_to management_document_verifications_path, notice: t("management.users.erased_notice")
|
||||
end
|
||||
|
||||
@@ -10,7 +10,8 @@ class Officing::ResidenceController < Officing::BaseController
|
||||
def create
|
||||
@residence = Officing::Residence.new(residence_params.merge(officer: current_user.poll_officer))
|
||||
if @residence.save
|
||||
redirect_to new_officing_voter_path(id: @residence.user.id), notice: t("officing.residence.flash.create")
|
||||
redirect_to new_officing_voter_path(id: @residence.user.id),
|
||||
notice: t("officing.residence.flash.create")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
||||
@@ -46,10 +46,12 @@ class Officing::ResultsController < Officing::BaseController
|
||||
answer = question.question_answers.find_by(given_order: answer_index.to_i + 1).title
|
||||
go_back_to_new if question.blank?
|
||||
|
||||
partial_result = ::Poll::PartialResult.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: Date.current,
|
||||
question_id: question_id,
|
||||
answer: answer)
|
||||
partial_result = ::Poll::PartialResult.find_or_initialize_by(
|
||||
booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: Date.current,
|
||||
question_id: question_id,
|
||||
answer: answer
|
||||
)
|
||||
partial_result.officer_assignment_id = @officer_assignment.id
|
||||
partial_result.amount = count.to_i
|
||||
partial_result.author = current_user
|
||||
@@ -62,8 +64,10 @@ class Officing::ResultsController < Officing::BaseController
|
||||
end
|
||||
|
||||
def build_recounts
|
||||
recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: Date.current)
|
||||
recount = ::Poll::Recount.find_or_initialize_by(
|
||||
booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: Date.current
|
||||
)
|
||||
recount.officer_assignment_id = @officer_assignment.id
|
||||
recount.author = current_user
|
||||
recount.origin = "booth"
|
||||
@@ -90,7 +94,9 @@ class Officing::ResultsController < Officing::BaseController
|
||||
|
||||
def load_officer_assignment
|
||||
@officer_assignment = current_user.poll_officer
|
||||
.officer_assignments.final.find_by(id: results_params[:officer_assignment_id])
|
||||
.officer_assignments
|
||||
.final
|
||||
.find_by(id: results_params[:officer_assignment_id])
|
||||
end
|
||||
|
||||
def load_officer_assignments
|
||||
|
||||
@@ -137,7 +137,10 @@ class ProposalsController < ApplicationController
|
||||
def load_retired
|
||||
if params[:retired].present?
|
||||
@resources = @resources.retired
|
||||
@resources = @resources.where(retired_reason: params[:retired]) if Proposal::RETIRE_OPTIONS.include?(params[:retired])
|
||||
|
||||
if Proposal::RETIRE_OPTIONS.include?(params[:retired])
|
||||
@resources = @resources.where(retired_reason: params[:retired])
|
||||
end
|
||||
else
|
||||
@resources = @resources.not_retired
|
||||
end
|
||||
@@ -152,7 +155,8 @@ class ProposalsController < ApplicationController
|
||||
end
|
||||
|
||||
def load_featured
|
||||
return unless !@advanced_search_terms && @search_terms.blank? && params[:retired].blank? && @current_order != "recommendations"
|
||||
return unless !@advanced_search_terms && @search_terms.blank? &&
|
||||
params[:retired].blank? && @current_order != "recommendations"
|
||||
|
||||
if Setting["feature.featured_proposals"]
|
||||
@featured_proposals = Proposal.not_archived
|
||||
|
||||
@@ -43,7 +43,8 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
|
||||
yield resource if block_given?
|
||||
|
||||
# New condition added to if: when no password was given, display the "show" view (which uses "update" above)
|
||||
# New condition added to if: when no password was given, display the "show" view
|
||||
# (which uses "update" above)
|
||||
if resource.encrypted_password.blank?
|
||||
respond_with_navigational(resource) { render :show }
|
||||
elsif resource.errors.empty?
|
||||
@@ -51,9 +52,14 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
|
||||
if resource.confirm
|
||||
set_flash_message(:notice, :confirmed) if is_flashing_format?
|
||||
respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) }
|
||||
|
||||
respond_with_navigational(resource) do
|
||||
redirect_to after_confirmation_path_for(resource_name, resource)
|
||||
end
|
||||
else
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new, status: :unprocessable_entity }
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity) do
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
else
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Users::RegistrationsController < Devise::RegistrationsController
|
||||
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup]
|
||||
prepend_before_action :authenticate_scope!,
|
||||
only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup]
|
||||
before_action :configure_permitted_parameters
|
||||
|
||||
invisible_captcha only: [:create], honeypot: :address, scope: :user
|
||||
@@ -52,16 +53,21 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
def check_username
|
||||
if User.find_by username: params[:username]
|
||||
render json: { available: false, message: t("devise_views.users.registrations.new.username_is_not_available") }
|
||||
render json: { available: false,
|
||||
message: t("devise_views.users.registrations.new.username_is_not_available") }
|
||||
else
|
||||
render json: { available: true, message: t("devise_views.users.registrations.new.username_is_available") }
|
||||
render json: { available: true,
|
||||
message: t("devise_views.users.registrations.new.username_is_available") }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sign_up_params
|
||||
params[:user].delete(:redeemable_code) if params[:user].present? && params[:user][:redeemable_code].blank?
|
||||
if params[:user].present? && params[:user][:redeemable_code].blank?
|
||||
params[:user].delete(:redeemable_code)
|
||||
end
|
||||
|
||||
params.require(:user).permit(allowed_params)
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ class Verification::EmailController < ApplicationController
|
||||
@email.encrypted_token,
|
||||
@verified_user.document_type,
|
||||
@verified_user.document_number).deliver_later
|
||||
redirect_to account_path, notice: t("verification.email.create.flash.success", email: @verified_user.email)
|
||||
redirect_to account_path,
|
||||
notice: t("verification.email.create.flash.success", email: @verified_user.email)
|
||||
else
|
||||
redirect_to verified_user_path, alert: t("verification.email.create.alert.failure")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user