OSDN Git Service

t#:
[pettanr/pettanr.git] / app / models / license.rb
index f98d601..e06e621 100644 (file)
@@ -1,7 +1,9 @@
 #
-class License < ActiveRecord::Base
+class License < Peta::Item
+  load_manifest
   belongs_to :license_group
   belongs_to :system_picture
+  has_many :resource_pictures
   
   validates :license_group_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :name, :presence => true, :length => {:maximum => 50}
@@ -9,15 +11,6 @@ class License < ActiveRecord::Base
   validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => {:message => I18n.t('errors.messages.url')} #{:allow_blank => true}
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   
-  before_validation :valid_encode
-  
-  def valid_encode
-    ['name', 'caption', 'url', 'settings', 'credit_pictures'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
-  end
-  
   def supply_default
   end
   
@@ -28,29 +21,22 @@ class License < ActiveRecord::Base
     self.license_group.caption + '/' + self.caption
   end
   
-  def self.list
-    opt = {}
-    opt.merge!(License.list_opt)
-    opt.merge!({:order => 'name'})
-    License.find(:all, opt)
+  def self.list_where
+    ''
+  end
+  
+  def self.list_order
+    'licenses.name'
   end
   
   def self.list_opt
-    {:include => {:license_group => {}}}
+    {:license_group => {}}
   end
   
   def self.list_json_opt
     {:include => {:license_group => {}}}
   end
   
-  def self.show rid
-    opt = {}
-    opt.merge!(License.show_opt)
-    res = License.find(rid, opt)
-#    raise ActiveRecord::Forbidden unless res.visible?(au)
-    res
-  end
-  
   def self.show_opt
     {:include => {:license_group => {}}}
   end