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, :numericality => true
11 @@valid_encode_columns += ['name']
12 @@visible_count_options = {:conditions => ['artists.author_id is not null']}
15 self.name = 'no name' if self.name.blank?
18 def self.find_by_author author
19 Artist.find( :first, :conditions => ['author_id = ?', author.id])
23 'artists.provider = 0'
27 'artists.created_at desc'
34 def self.list_json_opt
35 {:include => {:author => {}} }
39 {:include => {:author => {}} }
42 def self.show_json_opt
43 {:include => {:author => {}} }
46 def self.export(dt = nil)
49 ['artists.artists.provider = 0 and artists.updated_at >= ?', dt]
51 'artists.artists.provider = 0'
53 opt.merge!({:conditions => cond})
54 opt.merge!({:order => 'id'})
55 Artist.find(:all, opt)