Rubocop autocorrections (indentations, revers unless to if, extra spaces)
This commit is contained in:
@@ -15,7 +15,7 @@ class Users::SessionsController < Devise::SessionsController
|
||||
end
|
||||
|
||||
def verifying_via_email?
|
||||
return false unless resource.present?
|
||||
return false if resource.blank?
|
||||
stored_path = session[stored_location_key_for(resource)] || ""
|
||||
stored_path[0..5] == "/email"
|
||||
end
|
||||
|
||||
@@ -59,7 +59,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
end
|
||||
|
||||
def params_for_current_valuator
|
||||
Budget::Investment.filter_params(params).merge({valuator_id: current_user.valuator.id, budget_id: @budget.id})
|
||||
Budget::Investment.filter_params(params).merge(valuator_id: current_user.valuator.id, budget_id: @budget.id)
|
||||
end
|
||||
|
||||
def valuation_params
|
||||
|
||||
@@ -8,7 +8,7 @@ module BudgetsHelper
|
||||
Budget::CURRENCY_SYMBOLS.map { |cs| [ cs, cs ] }
|
||||
end
|
||||
|
||||
def namespaced_budget_investment_path(investment, options={})
|
||||
def namespaced_budget_investment_path(investment, options = {})
|
||||
case namespace
|
||||
when "management/budgets"
|
||||
management_budget_investment_path(investment.budget, investment, options)
|
||||
@@ -17,7 +17,7 @@ module BudgetsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def namespaced_budget_investment_vote_path(investment, options={})
|
||||
def namespaced_budget_investment_vote_path(investment, options = {})
|
||||
case namespace
|
||||
when "management/budgets"
|
||||
vote_management_budget_investment_path(investment.budget, investment, options)
|
||||
@@ -31,7 +31,7 @@ module BudgetsHelper
|
||||
end
|
||||
|
||||
def css_for_ballot_heading(heading)
|
||||
return '' unless current_ballot.present?
|
||||
return '' if current_ballot.blank?
|
||||
current_ballot.has_lines_in_heading?(heading) ? 'active' : ''
|
||||
end
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ module OfficingHelper
|
||||
def booths_for_officer_select_options(officer_assignments)
|
||||
options = []
|
||||
officer_assignments.each do |oa|
|
||||
options << ["#{oa.booth_assignment.booth.name}", oa.id]
|
||||
options << [oa.booth_assignment.booth.name.to_s, oa.id]
|
||||
end
|
||||
options.sort! {|x,y| x[0]<=>y[0]}
|
||||
options.sort! {|x, y| x[0]<=>y[0]}
|
||||
options_for_select(options, params[:oa])
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module PollsHelper
|
||||
|
||||
def poll_select_options(include_all=nil)
|
||||
options = @polls.collect {|poll|
|
||||
def poll_select_options(include_all = nil)
|
||||
options = @polls.collect do |poll|
|
||||
[poll.name, current_path_with_query_params(poll_id: poll.id)]
|
||||
}
|
||||
end
|
||||
options << all_polls if include_all
|
||||
options_for_select(options, request.fullpath)
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ class Budget
|
||||
validate :check_sufficient_funds
|
||||
validate :check_valid_heading
|
||||
|
||||
scope :by_investment, -> (investment_id) { where(investment_id: investment_id) }
|
||||
scope :by_investment, ->(investment_id) { where(investment_id: investment_id) }
|
||||
|
||||
before_validation :set_denormalized_ids
|
||||
|
||||
|
||||
@@ -52,11 +52,11 @@ class Budget
|
||||
scope :unselected, -> { not_unfeasible.where(selected: false) }
|
||||
scope :last_week, -> { where("created_at >= ?", 7.days.ago)}
|
||||
|
||||
scope :by_group, -> (group_id) { where(group_id: group_id) }
|
||||
scope :by_heading, -> (heading_id) { where(heading_id: heading_id) }
|
||||
scope :by_admin, -> (admin_id) { where(administrator_id: admin_id) }
|
||||
scope :by_tag, -> (tag_name) { tagged_with(tag_name) }
|
||||
scope :by_valuator, -> (valuator_id) { where("budget_valuator_assignments.valuator_id = ?", valuator_id).joins(:valuator_assignments) }
|
||||
scope :by_group, ->(group_id) { where(group_id: group_id) }
|
||||
scope :by_heading, ->(heading_id) { where(heading_id: heading_id) }
|
||||
scope :by_admin, ->(admin_id) { where(administrator_id: admin_id) }
|
||||
scope :by_tag, ->(tag_name) { tagged_with(tag_name) }
|
||||
scope :by_valuator, ->(valuator_id) { where("budget_valuator_assignments.valuator_id = ?", valuator_id).joins(:valuator_assignments) }
|
||||
|
||||
scope :for_render, -> { includes(:heading) }
|
||||
|
||||
@@ -65,7 +65,7 @@ class Budget
|
||||
before_validation :set_denormalized_ids
|
||||
|
||||
def self.filter_params(params)
|
||||
params.select{|x,_| %w{heading_id group_id administrator_id tag_name valuator_id}.include? x.to_s }
|
||||
params.select{|x, _| %w{heading_id group_id administrator_id tag_name valuator_id}.include? x.to_s }
|
||||
end
|
||||
|
||||
def self.scoped_filter(params, current_filter)
|
||||
@@ -152,7 +152,7 @@ class Budget
|
||||
return :not_logged_in unless user
|
||||
return :organization if user.organization?
|
||||
return :not_verified unless user.can?(:vote, Budget::Investment)
|
||||
return nil
|
||||
nil
|
||||
end
|
||||
|
||||
def permission_problem?(user)
|
||||
@@ -177,8 +177,8 @@ class Budget
|
||||
end
|
||||
|
||||
def heading_voted_by_user?(user)
|
||||
user.votes.for_budget_investments(budget.investments.where(group: group)).
|
||||
votables.map(&:heading_id).first
|
||||
user.votes.for_budget_investments(budget.investments.where(group: group))
|
||||
.votables.map(&:heading_id).first
|
||||
end
|
||||
|
||||
def ballotable_by?(user)
|
||||
@@ -236,7 +236,7 @@ class Budget
|
||||
budget.formatted_amount(price)
|
||||
end
|
||||
|
||||
def self.apply_filters_and_search(budget, params, current_filter=nil)
|
||||
def self.apply_filters_and_search(_budget, params, current_filter = nil)
|
||||
investments = all
|
||||
investments = investments.send(current_filter) if current_filter.present?
|
||||
investments = investments.by_heading(params[:heading_id]) if params[:heading_id].present?
|
||||
|
||||
@@ -116,7 +116,7 @@ class Officing::Residence
|
||||
end
|
||||
|
||||
def clean_document_number
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank?
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
|
||||
end
|
||||
|
||||
def random_password
|
||||
|
||||
@@ -10,8 +10,8 @@ class Poll::Answer < ActiveRecord::Base
|
||||
validates :answer, presence: true
|
||||
validates :answer, inclusion: {in: ->(a) { a.question.valid_answers }}
|
||||
|
||||
scope :by_author, -> (author_id) { where(author_id: author_id) }
|
||||
scope :by_question, -> (question_id) { where(question_id: question_id) }
|
||||
scope :by_author, ->(author_id) { where(author_id: author_id) }
|
||||
scope :by_question, ->(question_id) { where(question_id: question_id) }
|
||||
|
||||
def record_voter_participation
|
||||
Poll::Voter.create!(user: author, poll: poll)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Poll::NullResult < ActiveRecord::Base
|
||||
|
||||
VALID_ORIGINS = %w{ web booth }
|
||||
VALID_ORIGINS = %w{web booth}
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :booth_assignment
|
||||
@@ -9,7 +9,7 @@ class Poll::NullResult < ActiveRecord::Base
|
||||
validates :author, presence: true
|
||||
validates :origin, inclusion: {in: VALID_ORIGINS}
|
||||
|
||||
scope :by_author, -> (author_id) { where(author_id: author_id) }
|
||||
scope :by_author, ->(author_id) { where(author_id: author_id) }
|
||||
|
||||
before_save :update_logs
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Poll::PartialResult < ActiveRecord::Base
|
||||
|
||||
VALID_ORIGINS = %w{ web booth }
|
||||
VALID_ORIGINS = %w{web booth}
|
||||
|
||||
belongs_to :question, -> { with_hidden }
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
@@ -13,8 +13,8 @@ class Poll::PartialResult < ActiveRecord::Base
|
||||
validates :answer, inclusion: {in: ->(a) { a.question.valid_answers }}
|
||||
validates :origin, inclusion: {in: VALID_ORIGINS}
|
||||
|
||||
scope :by_author, -> (author_id) { where(author_id: author_id) }
|
||||
scope :by_question, -> (question_id) { where(question_id: question_id) }
|
||||
scope :by_author, ->(author_id) { where(author_id: author_id) }
|
||||
scope :by_question, ->(question_id) { where(question_id: question_id) }
|
||||
|
||||
before_save :update_logs
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class Poll
|
||||
before_validation :set_demographic_info, :set_document_info
|
||||
|
||||
def set_demographic_info
|
||||
return unless user.present?
|
||||
return if user.blank?
|
||||
|
||||
self.gender = user.gender
|
||||
self.age = user.age
|
||||
@@ -22,7 +22,7 @@ class Poll
|
||||
end
|
||||
|
||||
def set_document_info
|
||||
return unless user.present?
|
||||
return if user.blank?
|
||||
|
||||
self.document_type = user.document_type
|
||||
self.document_number = user.document_number
|
||||
@@ -51,7 +51,7 @@ class Poll
|
||||
nil
|
||||
else
|
||||
now = Time.current.to_date
|
||||
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1)
|
||||
now.year - dob.year - (now.month > dob.month || (now.month == dob.month && now.day >= dob.day) ? 0 : 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Poll::WhiteResult < ActiveRecord::Base
|
||||
|
||||
VALID_ORIGINS = %w{ web booth }
|
||||
VALID_ORIGINS = %w{web booth}
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :booth_assignment
|
||||
@@ -9,7 +9,7 @@ class Poll::WhiteResult < ActiveRecord::Base
|
||||
validates :author, presence: true
|
||||
validates :origin, inclusion: {in: VALID_ORIGINS}
|
||||
|
||||
scope :by_author, -> (author_id) { where(author_id: author_id) }
|
||||
scope :by_author, ->(author_id) { where(author_id: author_id) }
|
||||
|
||||
before_save :update_logs
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ class SignatureSheet < ActiveRecord::Base
|
||||
belongs_to :signable, polymorphic: true
|
||||
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||||
|
||||
VALID_SIGNABLES = %w( Proposal Budget::Investment SpendingProposal )
|
||||
VALID_SIGNABLES = %w(Proposal Budget::Investment SpendingProposal)
|
||||
|
||||
has_many :signatures
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class SiteCustomization::Image < ActiveRecord::Base
|
||||
has_attached_file :image
|
||||
|
||||
validates :name, presence: true, uniqueness: true, inclusion: { in: VALID_IMAGES.keys }
|
||||
validates_attachment_content_type :image, :content_type => ["image/png"]
|
||||
validates_attachment_content_type :image, content_type: ["image/png"]
|
||||
validate :check_image
|
||||
|
||||
def self.all_images
|
||||
|
||||
@@ -154,7 +154,7 @@ class User < ActiveRecord::Base
|
||||
|
||||
def has_official_email?
|
||||
domain = Setting['email_domain_for_officials']
|
||||
!email.blank? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") )
|
||||
email.present? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") )
|
||||
end
|
||||
|
||||
def display_official_position_badge?
|
||||
@@ -289,7 +289,7 @@ class User < ActiveRecord::Base
|
||||
private
|
||||
|
||||
def clean_document_number
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank?
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
|
||||
end
|
||||
|
||||
def validate_username_length
|
||||
|
||||
@@ -81,7 +81,7 @@ class Verification::Residence
|
||||
end
|
||||
|
||||
def clean_document_number
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank?
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Age
|
||||
def self.in_years(dob, now = Time.current.to_date)
|
||||
return nil unless dob.present?
|
||||
return nil if dob.blank?
|
||||
# reference: http://stackoverflow.com/questions/819263/get-persons-age-in-ruby#comment21200772_819263
|
||||
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1)
|
||||
now.year - dob.year - (now.month > dob.month || (now.month == dob.month && now.day >= dob.day) ? 0 : 1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,18 +26,18 @@ module DocumentParser
|
||||
else
|
||||
letter = nil
|
||||
end
|
||||
return document_number, letter
|
||||
[document_number, letter]
|
||||
end
|
||||
|
||||
# if the number has less digits than it should, pad with zeros to the left and add each variant to the list
|
||||
# For example, if the initial document_number is 1234, and digits=8, the result is
|
||||
# ['1234', '01234', '001234', '0001234']
|
||||
def get_number_variants_with_leading_zeroes_from(document_number, digits=8)
|
||||
def get_number_variants_with_leading_zeroes_from(document_number, digits = 8)
|
||||
document_number = document_number.to_s.last(digits) # Keep only the last x digits
|
||||
document_number = document_number.gsub(/^0+/, '') # Removes leading zeros
|
||||
|
||||
variants = []
|
||||
variants << document_number unless document_number.blank?
|
||||
variants << document_number if document_number.present?
|
||||
while document_number.size < digits
|
||||
document_number = "0#{document_number}"
|
||||
variants << document_number
|
||||
@@ -50,7 +50,7 @@ module DocumentParser
|
||||
# ['1234a', '1234A', '01234a', '01234A']
|
||||
def get_letter_variants(number_variants, letter)
|
||||
variants = []
|
||||
if letter.present? then
|
||||
if letter.present?
|
||||
number_variants.each do |number|
|
||||
variants << number + letter.downcase << number + letter.upcase
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user