Kill trailing whitespace in ruby files
This commit is contained in:
@@ -6,42 +6,42 @@ class Ban < ActiveRecord::Base
|
||||
validate :user_is_inferior
|
||||
validates_presence_of :user_id, :reason, :duration
|
||||
before_validation :initialize_banner_id, :on => :create
|
||||
|
||||
|
||||
def self.is_banned?(user)
|
||||
exists?(["user_id = ? AND expires_at > ?", user.id, Time.now])
|
||||
end
|
||||
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
|
||||
|
||||
if params[:banner_name]
|
||||
q = q.where("banner_id = (select _.id from users _ where lower(_.name) = ?)", params[:banner_name].downcase)
|
||||
end
|
||||
|
||||
|
||||
if params[:banner_id]
|
||||
q = q.where("banner_id = ?", params[:banner_id].to_i)
|
||||
end
|
||||
|
||||
|
||||
if params[:user_name]
|
||||
q = q.where("user_id = (select _.id from users _ where lower(_.name) = ?)", params[:user_name].downcase)
|
||||
end
|
||||
|
||||
|
||||
if params[:user_id]
|
||||
q = q.where("user_id = ?", params[:user_id].to_i)
|
||||
end
|
||||
|
||||
|
||||
q
|
||||
end
|
||||
|
||||
|
||||
def initialize_banner_id
|
||||
self.banner_id = CurrentUser.id
|
||||
end
|
||||
|
||||
|
||||
def user_is_inferior
|
||||
if user
|
||||
if user.is_admin?
|
||||
errors[:base] << "You can never ban an admin."
|
||||
errors[:base] << "You can never ban an admin."
|
||||
false
|
||||
elsif user.is_moderator? && banner.is_admin?
|
||||
true
|
||||
@@ -56,7 +56,7 @@ class Ban < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def update_feedback
|
||||
if user
|
||||
feedback = user.feedback.build
|
||||
@@ -66,24 +66,24 @@ class Ban < ActiveRecord::Base
|
||||
feedback.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def user_name
|
||||
user ? user.name : nil
|
||||
end
|
||||
|
||||
|
||||
def user_name=(username)
|
||||
self.user_id = User.name_to_id(username)
|
||||
end
|
||||
|
||||
|
||||
def duration=(dur)
|
||||
self.expires_at = dur.to_i.days.from_now
|
||||
@duration = dur
|
||||
end
|
||||
|
||||
|
||||
def duration
|
||||
@duration
|
||||
end
|
||||
|
||||
|
||||
def expired?
|
||||
expires_at < Time.now
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user