Fix line length issues at User model
This commit is contained in:
@@ -57,7 +57,9 @@ class User < ActiveRecord::Base
|
||||
scope :officials, -> { where("official_level > 0") }
|
||||
scope :newsletter, -> { where(newsletter: true) }
|
||||
scope :for_render, -> { includes(:organization) }
|
||||
scope :by_document, ->(document_type, document_number) { where(document_type: document_type, document_number: document_number) }
|
||||
scope :by_document, ->(document_type, document_number) do
|
||||
where(document_type: document_type, document_number: document_number)
|
||||
end
|
||||
scope :email_digest, -> { where(email_digest: true) }
|
||||
scope :active, -> { where(erased_at: nil) }
|
||||
scope :erased, -> { where.not(erased_at: nil) }
|
||||
@@ -211,7 +213,8 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
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
|
||||
erased_user = User.erased.where(document_number: document_number)
|
||||
.where(document_type: document_type).first
|
||||
if erased_user.present?
|
||||
take_votes_from(erased_user)
|
||||
erased_user.update(document_number: nil, document_type: nil)
|
||||
@@ -223,7 +226,8 @@ class User < ActiveRecord::Base
|
||||
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')}")
|
||||
data_log = "id: #{other_user.id} - #{Time.current.strftime('%Y-%m-%d %H:%M:%S')}"
|
||||
update(former_users_data_log: "#{former_users_data_log} | #{data_log}")
|
||||
end
|
||||
|
||||
def locked?
|
||||
@@ -327,7 +331,8 @@ class User < ActiveRecord::Base
|
||||
private
|
||||
|
||||
def clean_document_number
|
||||
self.document_number = document_number.gsub(/[^a-z0-9]+/i, "").upcase if document_number.present?
|
||||
return unless document_number.present?
|
||||
self.document_number = document_number.gsub(/[^a-z0-9]+/i, "").upcase
|
||||
end
|
||||
|
||||
def validate_username_length
|
||||
|
||||
Reference in New Issue
Block a user