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 scope :find_index, -> do
17 self.name = 'no name' if self.name.blank?
21 def self.find_by_author author
22 Artist.where(author_id: author.id).first
25 def self.index_list_where list
26 'artists.provider_id is null'
30 {:include => {:user => {:author => {}}} }
33 def self.export(dt = nil)
34 artists = Artist.where('artists.provider = 0')
35 artists = artists.where(['artists.updated_at >= ?', dt]) if dt