1 class Artist < Peta::Owner
4 has_many :original_pictures
6 has_many :resource_pictures
8 validates :name, :presence => true, :length => {:maximum => 30}
9 validates :user_id, :numericality => true, :existence => {:both => false}
10 validates :provider_id, :numericality => {:allow_nil => true}
13 self.name = 'no name' if self.name.blank?
17 def self.find_by_author author
18 Artist.find( :first, :conditions => ['author_id = ?', author.id])
21 def self.index_list_where list
22 'artists.provider_id is null'
26 {:include => {:user => {:author => {}}} }
29 def self.export(dt = nil)
32 ['artists.artists.provider = 0 and artists.updated_at >= ?', dt]
34 'artists.artists.provider = 0'
36 opt.merge!({:conditions => cond})
37 opt.merge!({:order => 'id'})
38 Artist.find(:all, opt)