Fix all Style/RedundantSelf rubocop issues
This commit is contained in:
@@ -475,11 +475,6 @@ Style/RedundantParentheses:
|
||||
- 'spec/features/proposals_spec.rb'
|
||||
- 'spec/models/debate_spec.rb'
|
||||
|
||||
# Offense count: 49
|
||||
# Cop supports --auto-correct.
|
||||
Style/RedundantSelf:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
||||
|
||||
@@ -3,7 +3,7 @@ module Abilities
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
self.merge Abilities::Moderation.new(user)
|
||||
merge Abilities::Moderation.new(user)
|
||||
|
||||
can :restore, Comment
|
||||
cannot :restore, Comment, hidden_at: nil
|
||||
|
||||
@@ -3,7 +3,7 @@ module Abilities
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
self.merge Abilities::Everyone.new(user)
|
||||
merge Abilities::Everyone.new(user)
|
||||
|
||||
can [:read, :update], User, id: user.id
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ module Abilities
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
self.merge Abilities::Common.new(user)
|
||||
merge Abilities::Common.new(user)
|
||||
|
||||
can :read, Organization
|
||||
can(:verify, Organization){ |o| !o.verified? }
|
||||
|
||||
@@ -3,7 +3,7 @@ module Abilities
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
self.merge Abilities::Moderation.new(user)
|
||||
merge Abilities::Moderation.new(user)
|
||||
|
||||
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question, Legislation::Question, Legislation::Annotation]
|
||||
end
|
||||
|
||||
@@ -7,17 +7,17 @@ class Ability
|
||||
alias_action :hide_in_moderation_screen, to: :hide
|
||||
|
||||
if user # logged-in users
|
||||
self.merge Abilities::Valuator.new(user) if user.valuator?
|
||||
merge Abilities::Valuator.new(user) if user.valuator?
|
||||
|
||||
if user.administrator?
|
||||
self.merge Abilities::Administrator.new(user)
|
||||
merge Abilities::Administrator.new(user)
|
||||
elsif user.moderator?
|
||||
self.merge Abilities::Moderator.new(user)
|
||||
merge Abilities::Moderator.new(user)
|
||||
else
|
||||
self.merge Abilities::Common.new(user)
|
||||
merge Abilities::Common.new(user)
|
||||
end
|
||||
else
|
||||
self.merge Abilities::Everyone.new(user)
|
||||
merge Abilities::Everyone.new(user)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class Budget < ActiveRecord::Base
|
||||
scope :current, -> { where.not(phase: "finished") }
|
||||
|
||||
def description
|
||||
self.send("description_#{self.phase}").try(:html_safe)
|
||||
send("description_#{phase}").try(:html_safe)
|
||||
end
|
||||
|
||||
def self.description_max_length
|
||||
@@ -134,8 +134,8 @@ class Budget < ActiveRecord::Base
|
||||
def sanitize_descriptions
|
||||
s = WYSIWYGSanitizer.new
|
||||
PHASES.each do |phase|
|
||||
sanitized = s.sanitize(self.send("description_#{phase}"))
|
||||
self.send("description_#{phase}=", sanitized)
|
||||
sanitized = s.sanitize(send("description_#{phase}"))
|
||||
send("description_#{phase}=", sanitized)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ class Budget
|
||||
end
|
||||
|
||||
def has_lines_in_group?(group)
|
||||
self.groups.include?(group)
|
||||
groups.include?(group)
|
||||
end
|
||||
|
||||
def wrong_budget?(heading)
|
||||
@@ -54,7 +54,7 @@ class Budget
|
||||
end
|
||||
|
||||
def has_lines_with_heading?
|
||||
self.heading_id.present?
|
||||
heading_id.present?
|
||||
end
|
||||
|
||||
def has_lines_in_heading?(heading)
|
||||
@@ -62,12 +62,12 @@ class Budget
|
||||
end
|
||||
|
||||
def has_investment?(investment)
|
||||
self.investment_ids.include?(investment.id)
|
||||
investment_ids.include?(investment.id)
|
||||
end
|
||||
|
||||
def heading_for_group(group)
|
||||
return nil unless has_lines_in_group?(group)
|
||||
self.investments.where(group: group).first.heading
|
||||
investments.where(group: group).first.heading
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ 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?(self.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)
|
||||
end
|
||||
|
||||
def check_selected
|
||||
@@ -32,9 +32,9 @@ class Budget
|
||||
private
|
||||
|
||||
def set_denormalized_ids
|
||||
self.heading_id ||= self.investment.try(:heading_id)
|
||||
self.group_id ||= self.investment.try(:group_id)
|
||||
self.budget_id ||= self.investment.try(:budget_id)
|
||||
self.heading_id ||= investment.try(:heading_id)
|
||||
self.group_id ||= investment.try(:group_id)
|
||||
self.budget_id ||= investment.try(:budget_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -94,7 +94,7 @@ class Budget
|
||||
end
|
||||
|
||||
def self.search(terms)
|
||||
self.pg_search(terms)
|
||||
pg_search(terms)
|
||||
end
|
||||
|
||||
def self.by_heading(heading)
|
||||
@@ -191,7 +191,7 @@ class Budget
|
||||
end
|
||||
|
||||
def enough_money?(ballot)
|
||||
available_money = ballot.amount_available(self.heading)
|
||||
available_money = ballot.amount_available(heading)
|
||||
price.to_i <= available_money
|
||||
end
|
||||
|
||||
@@ -256,8 +256,8 @@ class Budget
|
||||
private
|
||||
|
||||
def set_denormalized_ids
|
||||
self.group_id = self.heading.try(:group_id) if self.heading_id_changed?
|
||||
self.budget_id ||= self.heading.try(:group).try(:budget_id)
|
||||
self.group_id = heading.try(:group_id) if heading_id_changed?
|
||||
self.budget_id ||= heading.try(:group).try(:budget_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ class Budget
|
||||
end
|
||||
|
||||
def ballot_lines_for_investment
|
||||
Budget::Ballot::Line.by_investment(self.id)
|
||||
Budget::Ballot::Line.by_investment(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -100,7 +100,7 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def call_after_commented
|
||||
self.commentable.try(:after_commented)
|
||||
commentable.try(:after_commented)
|
||||
end
|
||||
|
||||
def self.body_max_length
|
||||
|
||||
@@ -9,7 +9,7 @@ module Filterable
|
||||
class_methods do
|
||||
|
||||
def filter(params)
|
||||
resources = self.all
|
||||
resources = all
|
||||
params.each do |filter, value|
|
||||
if allowed_filter?(filter, value)
|
||||
resources = resources.send("by_#{filter}", value)
|
||||
|
||||
@@ -4,33 +4,33 @@ module Graphqlable
|
||||
class_methods do
|
||||
|
||||
def graphql_field_name
|
||||
self.name.gsub('::', '_').underscore.to_sym
|
||||
name.gsub('::', '_').underscore.to_sym
|
||||
end
|
||||
|
||||
def graphql_field_description
|
||||
"Find one #{self.model_name.human} by ID"
|
||||
"Find one #{model_name.human} by ID"
|
||||
end
|
||||
|
||||
def graphql_pluralized_field_name
|
||||
self.name.gsub('::', '_').underscore.pluralize.to_sym
|
||||
name.gsub('::', '_').underscore.pluralize.to_sym
|
||||
end
|
||||
|
||||
def graphql_pluralized_field_description
|
||||
"Find all #{self.model_name.human.pluralize}"
|
||||
"Find all #{model_name.human.pluralize}"
|
||||
end
|
||||
|
||||
def graphql_type_name
|
||||
self.name.gsub('::', '_')
|
||||
name.gsub('::', '_')
|
||||
end
|
||||
|
||||
def graphql_type_description
|
||||
(self.model_name.human).to_s
|
||||
(model_name.human).to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def public_created_at
|
||||
self.created_at.change(min: 0)
|
||||
created_at.change(min: 0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module HasPublicAuthor
|
||||
def public_author
|
||||
self.author.public_activity? ? self.author : nil
|
||||
author.public_activity? ? author : nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,11 +4,11 @@ module Measurable
|
||||
class_methods do
|
||||
|
||||
def title_max_length
|
||||
@@title_max_length ||= (self.columns.find { |c| c.name == 'title' }.limit rescue nil) || 80
|
||||
@@title_max_length ||= (columns.find { |c| c.name == 'title' }.limit rescue nil) || 80
|
||||
end
|
||||
|
||||
def responsible_name_max_length
|
||||
@@responsible_name_max_length ||= (self.columns.find { |c| c.name == 'responsible_name' }.limit rescue nil) || 60
|
||||
@@responsible_name_max_length ||= (columns.find { |c| c.name == 'responsible_name' }.limit rescue nil) || 60
|
||||
end
|
||||
|
||||
def question_max_length
|
||||
|
||||
@@ -17,7 +17,7 @@ module Sanitizable
|
||||
end
|
||||
|
||||
def sanitize_tag_list
|
||||
self.tag_list = TagSanitizer.new.sanitize_tag_list(self.tag_list) if self.class.taggable?
|
||||
self.tag_list = TagSanitizer.new.sanitize_tag_list(tag_list) if self.class.taggable?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ module SearchCache
|
||||
|
||||
def calculate_tsvector
|
||||
ActiveRecord::Base.connection.execute("
|
||||
UPDATE #{self.class.table_name} SET tsv = (#{searchable_values_sql}) WHERE id = #{self.id}")
|
||||
UPDATE #{self.class.table_name} SET tsv = (#{searchable_values_sql}) WHERE id = #{id}")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -12,7 +12,7 @@ module Searchable
|
||||
},
|
||||
ignoring: :accents,
|
||||
ranked_by: '(:tsearch)',
|
||||
order_within_rank: (self.column_names.include?('cached_votes_up') ? "#{self.table_name}.cached_votes_up DESC" : nil)
|
||||
order_within_rank: (column_names.include?('cached_votes_up') ? "#{table_name}.cached_votes_up DESC" : nil)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class Debate < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.search(terms)
|
||||
self.pg_search(terms)
|
||||
pg_search(terms)
|
||||
end
|
||||
|
||||
def to_param
|
||||
@@ -124,15 +124,15 @@ class Debate < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def after_hide
|
||||
self.tags.each{ |t| t.decrement_custom_counter_for('Debate') }
|
||||
tags.each{ |t| t.decrement_custom_counter_for('Debate') }
|
||||
end
|
||||
|
||||
def after_restore
|
||||
self.tags.each{ |t| t.increment_custom_counter_for('Debate') }
|
||||
tags.each{ |t| t.increment_custom_counter_for('Debate') }
|
||||
end
|
||||
|
||||
def featured?
|
||||
self.featured_at.present?
|
||||
featured_at.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -45,7 +45,7 @@ class Legislation::Annotation < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def create_first_comment
|
||||
comments.create(body: self.text, user: self.author)
|
||||
comments.create(body: text, user: author)
|
||||
end
|
||||
|
||||
def title
|
||||
|
||||
@@ -12,7 +12,7 @@ class Notification < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def mark_as_read
|
||||
self.destroy
|
||||
destroy
|
||||
end
|
||||
|
||||
def self.add(user_id, notifiable)
|
||||
|
||||
@@ -23,12 +23,12 @@ class Officing::Residence
|
||||
|
||||
if user_exists?
|
||||
self.user = find_user_by_document
|
||||
self.user.update(verified_at: Time.current)
|
||||
user.update(verified_at: Time.current)
|
||||
else
|
||||
user_params = {
|
||||
document_number: document_number,
|
||||
document_type: document_type,
|
||||
geozone: self.geozone,
|
||||
geozone: geozone,
|
||||
date_of_birth: date_of_birth.to_datetime,
|
||||
gender: gender,
|
||||
residence_verified_at: Time.current,
|
||||
@@ -115,7 +115,7 @@ class Officing::Residence
|
||||
end
|
||||
|
||||
def clean_document_number
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
|
||||
self.document_number = document_number.gsub(/[^a-z0-9]+/i, "").upcase if document_number.present?
|
||||
end
|
||||
|
||||
def random_password
|
||||
|
||||
@@ -39,11 +39,11 @@ class Organization < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.name_max_length
|
||||
@@name_max_length ||= self.columns.find { |c| c.name == 'name' }.limit || 60
|
||||
@@name_max_length ||= columns.find { |c| c.name == 'name' }.limit || 60
|
||||
end
|
||||
|
||||
def self.responsible_name_max_length
|
||||
@@responsible_name_max_length ||= self.columns.find { |c| c.name == 'responsible_name' }.limit || 60
|
||||
@@responsible_name_max_length ||= columns.find { |c| c.name == 'responsible_name' }.limit || 60
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -10,9 +10,9 @@ class Poll
|
||||
before_save :update_logs
|
||||
|
||||
def update_logs
|
||||
if self.count_changed? && self.count_was.present?
|
||||
self.count_log += ":#{self.count_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}"
|
||||
if count_changed? && count_was.present?
|
||||
self.count_log += ":#{count_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,10 +14,10 @@ class Poll::NullResult < ActiveRecord::Base
|
||||
before_save :update_logs
|
||||
|
||||
def update_logs
|
||||
if self.amount_changed? && self.amount_was.present?
|
||||
self.amount_log += ":#{self.amount_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}"
|
||||
self.author_id_log += ":#{self.author_id_was.to_s}"
|
||||
if amount_changed? && amount_was.present?
|
||||
self.amount_log += ":#{amount_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
|
||||
self.author_id_log += ":#{author_id_was.to_s}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,10 +19,10 @@ class Poll::PartialResult < ActiveRecord::Base
|
||||
before_save :update_logs
|
||||
|
||||
def update_logs
|
||||
if self.amount_changed? && self.amount_was.present?
|
||||
self.amount_log += ":#{self.amount_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}"
|
||||
self.author_id_log += ":#{self.author_id_was.to_s}"
|
||||
if amount_changed? && amount_was.present?
|
||||
self.amount_log += ":#{amount_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
|
||||
self.author_id_log += ":#{author_id_was.to_s}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class Poll::Question < ActiveRecord::Base
|
||||
scope :for_render, -> { includes(:author, :proposal) }
|
||||
|
||||
def self.search(params)
|
||||
results = self.all
|
||||
results = all
|
||||
results = results.by_poll_id(params[:poll_id]) if params[:poll_id].present?
|
||||
results = results.pg_search(params[:search]) if params[:search].present?
|
||||
results
|
||||
|
||||
@@ -11,9 +11,9 @@ class Poll
|
||||
before_save :update_logs
|
||||
|
||||
def update_logs
|
||||
if self.count_changed? && self.count_was.present?
|
||||
self.count_log += ":#{self.count_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}"
|
||||
if count_changed? && count_was.present?
|
||||
self.count_log += ":#{count_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,10 +14,10 @@ class Poll::WhiteResult < ActiveRecord::Base
|
||||
before_save :update_logs
|
||||
|
||||
def update_logs
|
||||
if self.amount_changed? && self.amount_was.present?
|
||||
self.amount_log += ":#{self.amount_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}"
|
||||
self.author_id_log += ":#{self.author_id_was.to_s}"
|
||||
if amount_changed? && amount_was.present?
|
||||
self.amount_log += ":#{amount_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
|
||||
self.author_id_log += ":#{author_id_was.to_s}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,12 +71,12 @@ class Proposal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.search(terms)
|
||||
by_code = self.search_by_code(terms.strip)
|
||||
by_code.present? ? by_code : self.pg_search(terms)
|
||||
by_code = search_by_code(terms.strip)
|
||||
by_code.present? ? by_code : pg_search(terms)
|
||||
end
|
||||
|
||||
def self.search_by_code(terms)
|
||||
matched_code = self.match_code(terms)
|
||||
matched_code = match_code(terms)
|
||||
results = where(id: matched_code[1]) if matched_code
|
||||
return results if (results.present? && results.first.code == terms)
|
||||
end
|
||||
@@ -147,11 +147,11 @@ class Proposal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def after_hide
|
||||
self.tags.each{ |t| t.decrement_custom_counter_for('Proposal') }
|
||||
tags.each{ |t| t.decrement_custom_counter_for('Proposal') }
|
||||
end
|
||||
|
||||
def after_restore
|
||||
self.tags.each{ |t| t.increment_custom_counter_for('Proposal') }
|
||||
tags.each{ |t| t.increment_custom_counter_for('Proposal') }
|
||||
end
|
||||
|
||||
def self.votes_needed_for_success
|
||||
@@ -163,7 +163,7 @@ class Proposal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def archived?
|
||||
self.created_at <= Setting["months_to_archive_proposals"].to_i.months.ago
|
||||
created_at <= Setting["months_to_archive_proposals"].to_i.months.ago
|
||||
end
|
||||
|
||||
def notifications
|
||||
|
||||
@@ -59,8 +59,8 @@ class Signature < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def clean_document_number
|
||||
return if self.document_number.blank?
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase
|
||||
return if document_number.blank?
|
||||
self.document_number = document_number.gsub(/[^a-z0-9]+/i, "").upcase
|
||||
end
|
||||
|
||||
def random_password
|
||||
|
||||
@@ -22,7 +22,7 @@ class SignatureSheet < ActiveRecord::Base
|
||||
|
||||
def verify_signatures
|
||||
parsed_document_numbers.each do |document_number|
|
||||
signature = self.signatures.where(document_number: document_number).first_or_create
|
||||
signature = signatures.where(document_number: document_number).first_or_create
|
||||
signature.verify
|
||||
end
|
||||
update(processed: true)
|
||||
|
||||
@@ -66,7 +66,7 @@ class SpendingProposal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.search(terms)
|
||||
self.pg_search(terms)
|
||||
pg_search(terms)
|
||||
end
|
||||
|
||||
def self.by_geozone(geozone)
|
||||
|
||||
@@ -169,7 +169,7 @@ class User < ActiveRecord::Base
|
||||
comments_ids = Comment.where(user_id: id).pluck(:id)
|
||||
proposal_ids = Proposal.where(author_id: id).pluck(:id)
|
||||
|
||||
self.hide
|
||||
hide
|
||||
|
||||
Debate.hide_all debates_ids
|
||||
Comment.hide_all comments_ids
|
||||
@@ -177,7 +177,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def erase(erase_reason = nil)
|
||||
self.update(
|
||||
update(
|
||||
erased_at: Time.current,
|
||||
erase_reason: erase_reason,
|
||||
username: nil,
|
||||
@@ -191,7 +191,7 @@ class User < ActiveRecord::Base
|
||||
confirmed_phone: nil,
|
||||
unconfirmed_phone: nil
|
||||
)
|
||||
self.identities.destroy_all
|
||||
identities.destroy_all
|
||||
end
|
||||
|
||||
def erased?
|
||||
@@ -201,17 +201,17 @@ class User < ActiveRecord::Base
|
||||
def take_votes_if_erased_document(document_number, document_type)
|
||||
erased_user = User.erased.where(document_number: document_number).where(document_type: document_type).first
|
||||
if erased_user.present?
|
||||
self.take_votes_from(erased_user)
|
||||
take_votes_from(erased_user)
|
||||
erased_user.update(document_number: nil, document_type: nil)
|
||||
end
|
||||
end
|
||||
|
||||
def take_votes_from(other_user)
|
||||
return if other_user.blank?
|
||||
Poll::Voter.where(user_id: other_user.id).update_all(user_id: self.id)
|
||||
Budget::Ballot.where(user_id: other_user.id).update_all(user_id: self.id)
|
||||
Vote.where("voter_id = ? AND voter_type = ?", other_user.id, "User").update_all(voter_id: self.id)
|
||||
self.update(former_users_data_log: "#{self.former_users_data_log} | id: #{other_user.id} - #{Time.current.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
Poll::Voter.where(user_id: other_user.id).update_all(user_id: id)
|
||||
Budget::Ballot.where(user_id: other_user.id).update_all(user_id: id)
|
||||
Vote.where("voter_id = ? AND voter_type = ?", other_user.id, "User").update_all(voter_id: id)
|
||||
update(former_users_data_log: "#{former_users_data_log} | id: #{other_user.id} - #{Time.current.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
end
|
||||
|
||||
def locked?
|
||||
@@ -223,7 +223,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.username_max_length
|
||||
@@username_max_length ||= self.columns.find { |c| c.name == 'username' }.limit || 60
|
||||
@@username_max_length ||= columns.find { |c| c.name == 'username' }.limit || 60
|
||||
end
|
||||
|
||||
def self.minimum_required_age
|
||||
@@ -257,10 +257,10 @@ class User < ActiveRecord::Base
|
||||
|
||||
def send_oauth_confirmation_instructions
|
||||
if oauth_email != email
|
||||
self.update(confirmed_at: nil)
|
||||
self.send_confirmation_instructions
|
||||
update(confirmed_at: nil)
|
||||
send_confirmation_instructions
|
||||
end
|
||||
self.update(oauth_email: nil) if oauth_email.present?
|
||||
update(oauth_email: nil) if oauth_email.present?
|
||||
end
|
||||
|
||||
def name_and_email
|
||||
@@ -274,11 +274,11 @@ class User < ActiveRecord::Base
|
||||
def save_requiring_finish_signup
|
||||
begin
|
||||
self.registering_with_oauth = true
|
||||
self.save(validate: false)
|
||||
save(validate: false)
|
||||
# Devise puts unique constraints for the email the db, so we must detect & handle that
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
self.email = nil
|
||||
self.save(validate: false)
|
||||
save(validate: false)
|
||||
end
|
||||
true
|
||||
end
|
||||
@@ -311,7 +311,7 @@ class User < ActiveRecord::Base
|
||||
private
|
||||
|
||||
def clean_document_number
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
|
||||
self.document_number = document_number.gsub(/[^a-z0-9]+/i, "").upcase if document_number.present?
|
||||
end
|
||||
|
||||
def validate_username_length
|
||||
|
||||
@@ -27,7 +27,7 @@ class Verification::Email
|
||||
end
|
||||
|
||||
def self.find(user, token)
|
||||
self.valid_token?(user, token)
|
||||
valid_token?(user, token)
|
||||
end
|
||||
|
||||
def self.valid_token?(user, token)
|
||||
|
||||
@@ -31,7 +31,7 @@ class Verification::Residence
|
||||
|
||||
user.update(document_number: document_number,
|
||||
document_type: document_type,
|
||||
geozone: self.geozone,
|
||||
geozone: geozone,
|
||||
date_of_birth: date_of_birth.to_datetime,
|
||||
gender: gender,
|
||||
residence_verified_at: Time.current)
|
||||
@@ -39,7 +39,7 @@ class Verification::Residence
|
||||
|
||||
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(self.date_of_birth) >= User.minimum_required_age
|
||||
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
|
||||
end
|
||||
|
||||
def document_number_uniqueness
|
||||
@@ -81,7 +81,7 @@ class Verification::Residence
|
||||
end
|
||||
|
||||
def clean_document_number
|
||||
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
|
||||
self.document_number = document_number.gsub(/[^a-z0-9]+/i, "").upcase if document_number.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class Verification::Sms
|
||||
end
|
||||
|
||||
def save
|
||||
return false unless self.valid?
|
||||
return false unless valid?
|
||||
update_user_phone_information
|
||||
send_sms
|
||||
Lock.increase_tries(user)
|
||||
|
||||
@@ -2,7 +2,7 @@ module ActsAsParanoidAliases
|
||||
|
||||
def self.included(base)
|
||||
base.extend(ClassMethods)
|
||||
self.class_eval do
|
||||
class_eval do
|
||||
|
||||
def hide
|
||||
return false if hidden?
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Numeric
|
||||
def percent_of(n)
|
||||
(self.to_f / n * 100).to_i
|
||||
(to_f / n * 100).to_i
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user