changes
This commit is contained in:
@@ -40,6 +40,8 @@ class Post < ActiveRecord::Base
|
||||
scope :available_for_moderation, lambda {where(["id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
|
||||
scope :hidden_from_moderation, lambda {where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
|
||||
scope :tag_match, lambda {|query| Post.tag_match_helper(query)}
|
||||
scope :positive, where("score > 1")
|
||||
scope :negative, where("score < -1")
|
||||
search_methods :tag_match
|
||||
scope :after_id, Proc.new {|num|
|
||||
if num.present?
|
||||
|
||||
@@ -7,7 +7,7 @@ class User < ActiveRecord::Base
|
||||
attr_accessor :password, :old_password
|
||||
attr_accessible :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr
|
||||
validates_length_of :name, :within => 2..20, :on => :create
|
||||
validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons"
|
||||
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
||||
validates_uniqueness_of :name, :case_sensitive => false, :on => :create
|
||||
validates_uniqueness_of :email, :case_sensitive => false, :on => :create, :if => lambda {|rec| !rec.email.blank?}
|
||||
validates_length_of :password, :minimum => 5, :if => lambda {|rec| rec.new_record? || !rec.password.blank?}
|
||||
@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
|
||||
has_many :feedback, :class_name => "UserFeedback", :dependent => :destroy
|
||||
has_one :ban
|
||||
has_many :subscriptions, :class_name => "TagSubscription"
|
||||
has_many :note_versions, :foreign_key => "updater_id"
|
||||
belongs_to :inviter, :class_name => "User"
|
||||
scope :named, lambda {|name| where(["lower(name) = ?", name])}
|
||||
scope :admins, where("is_admin = TRUE")
|
||||
@@ -143,6 +144,13 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def level_string
|
||||
if is_admin?
|
||||
"Admin"
|
||||
elsif is_moderator?
|
||||
"Moderator"
|
||||
end
|
||||
|
||||
def normalize_level
|
||||
if is_admin?
|
||||
self.is_moderator = true
|
||||
@@ -254,6 +262,12 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
module PostMethods
|
||||
def posts
|
||||
Post.where("uploader_string = ?", "uploader:#{id}")
|
||||
end
|
||||
end
|
||||
|
||||
include BanMethods
|
||||
include NameMethods
|
||||
include PasswordMethods
|
||||
@@ -264,6 +278,7 @@ class User < ActiveRecord::Base
|
||||
include BlacklistMethods
|
||||
include ForumMethods
|
||||
include LimitMethods
|
||||
include PostMethods
|
||||
|
||||
def initialize_default_image_size
|
||||
self.default_image_size = "Medium"
|
||||
|
||||
Reference in New Issue
Block a user