1 class Artist < Pettanr::Owner
3 has_many :original_pictures
5 has_many :resource_pictures
7 validates :name, :presence => true, :length => {:maximum => 30}
8 validates :user_id, :numericality => true, :existence => {:both => false}
9 validates :provider_id, :numericality => {:allow_nil => true}
11 def self.valid_encode_columns
15 def self.visible_count_options
16 {:conditions => ['artists.author_id is not null']}
20 self.name = 'no name' if self.name.blank?
23 def self.find_by_author author
24 Artist.find( :first, :conditions => ['author_id = ?', author.id])
28 'artists.provider = 0'
32 'artists.created_at desc'
36 {:user => {:author => {}} }
39 def self.list_json_opt
40 {:include => {:user => {:author => {}}} }
44 {:include => {:user => {:author => {}}} }
47 def self.show_json_opt
48 {:include => {:user => {:author => {}}} }
51 def self.export(dt = nil)
54 ['artists.artists.provider = 0 and artists.updated_at >= ?', dt]
56 'artists.artists.provider = 0'
58 opt.merge!({:conditions => cond})
59 opt.merge!({:order => 'id'})
60 Artist.find(:all, opt)