Merge branch 'refactor_models_2' of https://github.com/buddhamagnet/diaspora
This commit is contained in:
commit
fcc6d95067
13 changed files with 34 additions and 28 deletions
|
|
@ -11,8 +11,8 @@ class Aspect < ActiveRecord::Base
|
||||||
has_many :aspect_visibilities
|
has_many :aspect_visibilities
|
||||||
has_many :posts, :through => :aspect_visibilities
|
has_many :posts, :through => :aspect_visibilities
|
||||||
|
|
||||||
validates_presence_of :name
|
validates :name, :presence => true, :length => { :maximum => 20 }
|
||||||
validates_length_of :name, :maximum => 20
|
|
||||||
validates_uniqueness_of :name, :scope => :user_id, :case_sensitive => false
|
validates_uniqueness_of :name, :scope => :user_id, :case_sensitive => false
|
||||||
|
|
||||||
attr_accessible :name, :contacts_visible, :order_id
|
attr_accessible :name, :contacts_visible, :order_id
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
class AspectVisibility < ActiveRecord::Base
|
class AspectVisibility < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :aspect
|
belongs_to :aspect
|
||||||
validates_presence_of :aspect
|
validates :aspect, :presence => true
|
||||||
|
|
||||||
belongs_to :post
|
belongs_to :post
|
||||||
validates_presence_of :post
|
validates :post, :presence => true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ class Comment < ActiveRecord::Base
|
||||||
belongs_to :post
|
belongs_to :post
|
||||||
belongs_to :author, :class_name => 'Person'
|
belongs_to :author, :class_name => 'Person'
|
||||||
|
|
||||||
validates_presence_of :text, :post
|
validates :text, :presence => true, :length => { :maximum => 2500 }
|
||||||
validates_length_of :text, :maximum => 2500
|
validates :post, :presence => true
|
||||||
|
|
||||||
serialize :youtube_titles, Hash
|
serialize :youtube_titles, Hash
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class Contact < ActiveRecord::Base
|
||||||
validates_presence_of :user
|
validates_presence_of :user
|
||||||
|
|
||||||
belongs_to :person
|
belongs_to :person
|
||||||
validates_presence_of :person
|
validates :person, :presence => true
|
||||||
|
|
||||||
has_many :aspect_memberships
|
has_many :aspect_memberships
|
||||||
has_many :aspects, :through => :aspect_memberships
|
has_many :aspects, :through => :aspect_memberships
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@ class Invitation < ActiveRecord::Base
|
||||||
before_validation :set_email_as_default_service
|
before_validation :set_email_as_default_service
|
||||||
|
|
||||||
# before_create :share_with_exsisting_user, :if => :recipient_id?
|
# before_create :share_with_exsisting_user, :if => :recipient_id?
|
||||||
validates_presence_of :identifier, :service
|
validates :identifier, :presence => true
|
||||||
|
validates :service, :presence => true
|
||||||
validate :valid_identifier?
|
validate :valid_identifier?
|
||||||
validate :recipient_not_on_pod?
|
validate :recipient_not_on_pod?
|
||||||
validates_presence_of :sender, :aspect, :unless => :admin?
|
validates_presence_of :sender, :aspect, :unless => :admin?
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ class Like < ActiveRecord::Base
|
||||||
belongs_to :author, :class_name => 'Person'
|
belongs_to :author, :class_name => 'Person'
|
||||||
|
|
||||||
validates_uniqueness_of :target_id, :scope => [:target_type, :author_id]
|
validates_uniqueness_of :target_id, :scope => [:target_type, :author_id]
|
||||||
validates_presence_of :author, :target
|
validates :author, :presence => true
|
||||||
|
validates :target, :presence => true
|
||||||
|
|
||||||
after_create do
|
after_create do
|
||||||
self.target.update_likes_counter
|
self.target.update_likes_counter
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
class Mention < ActiveRecord::Base
|
class Mention < ActiveRecord::Base
|
||||||
belongs_to :post
|
belongs_to :post
|
||||||
belongs_to :person
|
belongs_to :person
|
||||||
validates_presence_of :post
|
validates :post, :presence => true
|
||||||
validates_presence_of :person
|
validates :person, :presence => true
|
||||||
|
|
||||||
after_destroy :delete_notification
|
after_destroy :delete_notification
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class Message < ActiveRecord::Base
|
||||||
belongs_to :author, :class_name => 'Person'
|
belongs_to :author, :class_name => 'Person'
|
||||||
belongs_to :conversation, :touch => true
|
belongs_to :conversation, :touch => true
|
||||||
|
|
||||||
validates_presence_of :text
|
validates :text, :presence => true
|
||||||
|
|
||||||
after_create do
|
after_create do
|
||||||
#sign comment as commenter
|
#sign comment as commenter
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,10 @@ class Person < ActiveRecord::Base
|
||||||
before_destroy :remove_all_traces
|
before_destroy :remove_all_traces
|
||||||
before_validation :clean_url
|
before_validation :clean_url
|
||||||
|
|
||||||
validates_presence_of :url, :profile, :serialized_public_key
|
validates :url, :presence => true
|
||||||
validates_uniqueness_of :diaspora_handle
|
validates :profile, :presence => true
|
||||||
|
validates :serialized_public_key, :presence => true
|
||||||
|
validates :diaspora_handle, :uniqueness => true
|
||||||
|
|
||||||
scope :searchable, joins(:profile).where(:profiles => {:searchable => true})
|
scope :searchable, joins(:profile).where(:profiles => {:searchable => true})
|
||||||
scope :remote, where('people.owner_id IS NULL')
|
scope :remote, where('people.owner_id IS NULL')
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class Post < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :author, :class_name => 'Person'
|
belongs_to :author, :class_name => 'Person'
|
||||||
|
|
||||||
validates_uniqueness_of :guid
|
validates :guid, :uniqueness => true
|
||||||
|
|
||||||
def diaspora_handle
|
def diaspora_handle
|
||||||
read_attribute(:diaspora_handle) || self.author.diaspora_handle
|
read_attribute(:diaspora_handle) || self.author.diaspora_handle
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class Profile < ActiveRecord::Base
|
||||||
|
|
||||||
acts_as_taggable_on :tags
|
acts_as_taggable_on :tags
|
||||||
extract_tags_from :tag_string
|
extract_tags_from :tag_string
|
||||||
validates_length_of :tag_list, :maximum => 5
|
validates :tag_list, :length => { :maximum => 5 }
|
||||||
|
|
||||||
xml_attr :diaspora_handle
|
xml_attr :diaspora_handle
|
||||||
xml_attr :first_name
|
xml_attr :first_name
|
||||||
|
|
@ -30,8 +30,9 @@ class Profile < ActiveRecord::Base
|
||||||
before_save :strip_names
|
before_save :strip_names
|
||||||
after_validation :strip_names
|
after_validation :strip_names
|
||||||
|
|
||||||
validates_length_of :first_name, :maximum => 32
|
validates :first_name, :length => { :maximum => 32 }
|
||||||
validates_length_of :last_name, :maximum => 32
|
validates :last_name, :length => { :maximum => 32 }
|
||||||
|
|
||||||
validates_format_of :first_name, :with => /\A[^;]+\z/, :allow_blank => true
|
validates_format_of :first_name, :with => /\A[^;]+\z/, :allow_blank => true
|
||||||
validates_format_of :last_name, :with => /\A[^;]+\z/, :allow_blank => true
|
validates_format_of :last_name, :with => /\A[^;]+\z/, :allow_blank => true
|
||||||
validate :max_tags
|
validate :max_tags
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@ class Request
|
||||||
xml_accessor :sender_handle
|
xml_accessor :sender_handle
|
||||||
xml_accessor :recipient_handle
|
xml_accessor :recipient_handle
|
||||||
|
|
||||||
validates_presence_of :sender, :recipient
|
validates :sender, :presence => true
|
||||||
|
validates :recipient, :presence => true
|
||||||
|
|
||||||
validate :not_already_connected
|
validate :not_already_connected
|
||||||
validate :not_friending_yourself
|
validate :not_friending_yourself
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@ class User < ActiveRecord::Base
|
||||||
before_validation :strip_and_downcase_username
|
before_validation :strip_and_downcase_username
|
||||||
before_validation :set_current_language, :on => :create
|
before_validation :set_current_language, :on => :create
|
||||||
|
|
||||||
validates_presence_of :username
|
validates :username, :presence => true, :uniqueness => true
|
||||||
validates_uniqueness_of :username
|
|
||||||
validates_format_of :username, :with => /\A[A-Za-z0-9_]+\z/
|
validates_format_of :username, :with => /\A[A-Za-z0-9_]+\z/
|
||||||
validates_length_of :username, :maximum => 32
|
validates_length_of :username, :maximum => 32
|
||||||
validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES
|
validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue