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}
12 def self.visible_count_options
13 {:conditions => ['artists.author_id is not null']}
17 self.name = 'no name' if self.name.blank?
20 def self.find_by_author author
21 Artist.find( :first, :conditions => ['author_id = ?', author.id])
25 'artists.provider_id is null'
29 'artists.created_at desc'
33 {:user => {:author => {}} }
36 def self.list_json_opt
37 {:include => {:user => {:author => {}}} }
41 {:include => {:user => {:author => {}}} }
44 def self.show_json_opt
45 {:include => {:user => {:author => {}}} }
48 def self.export(dt = nil)
51 ['artists.artists.provider = 0 and artists.updated_at >= ?', dt]
53 'artists.artists.provider = 0'
55 opt.merge!({:conditions => cond})
56 opt.merge!({:order => 'id'})
57 Artist.find(:all, opt)