OSDN Git Service

fix leaf view
[pettanr/pettanr.git] / app / models / license.rb
index fc264af..3a70d4d 100644 (file)
@@ -1,25 +1,17 @@
 #
-class License < Peta::Item
+class License < Peta::SystemResource
+  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 :license_group_classname, :presence => true, :length => {:maximum => 50}
   validates :name, :presence => true, :length => {:maximum => 50}
   validates :caption, :presence => true, :length => {:maximum => 30}
-  validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => true, :url => {:message => I18n.t('errors.messages.url')} #{:allow_blank => true}
+  validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => {:scope => :name}, :url => {:message => I18n.t('errors.messages.url')} #{:allow_blank => true}
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   
-  def self.valid_encode_columns
-    super + ['name', 'caption', 'url', 'settings', 'credit_pictures']
-  end
-  
-  def supply_default
-  end
-  
-  def overwrite
-  end
-  
   def caption_with_group
     self.license_group.caption + '/' + self.caption
   end
@@ -32,14 +24,6 @@ class License < Peta::Item
     'licenses.name'
   end
   
-  def self.list_opt
-    {:license_group => {}}
-  end
-  
-  def self.list_json_opt
-    {:include => {:license_group => {}}}
-  end
-  
   def self.show_opt
     {:include => {:license_group => {}}}
   end
@@ -54,7 +38,8 @@ class License < Peta::Item
   
   def self.store name, attr
     r = License.replace_system_picture attr
-    attr['credit_pictures'] = attr['credit_pictures'].to_json
+    attr['credit_picture_settings'] = attr['credit_picture_settings'].to_json
+    attr['license_group_settings'] = attr['license_group_settings'].to_json
     l = License.modify_object name, attr
     if r == false
       l.errors.add :base, SystemPicture.model_name.human + I18n.t('errors.not_create')
@@ -75,6 +60,21 @@ class License < Peta::Item
     res
   end
   
+=begin
+  def supply_default
+  end
+  
+  def overwrite
+  end
+  
+  def self.list_opt
+    {:license_group => {}}
+  end
+  
+  def self.list_json_opt
+    {:include => {:license_group => {}}}
+  end
+  
   def credit_pictures_attr
     return @credit_pictures_attr if @credit_pictures_attr
     begin
@@ -84,6 +84,7 @@ class License < Peta::Item
     @credit_pictures_attr = {} unless @credit_pictures_attr
     @credit_pictures_attr
   end
+=end
   
   def self.export(dt = nil)
     opt = {}