OSDN Git Service

add lg_id in resource picture
[pettanr/pettanr.git] / app / models / resource_picture.rb
index c6975ef..a43698a 100644 (file)
@@ -2,6 +2,7 @@
 class ResourcePicture < Peta::Content
   load_manifest
   belongs_to :artist
+  belongs_to :license_group
   belongs_to :license
   belongs_to :system_picture
   belongs_to :picture
@@ -16,16 +17,19 @@ class ResourcePicture < Peta::Content
   validates :license_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :original_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
-  validates :artist_name, :presence => true
-  validates :license_group_classname, :presence => true, :length => {:maximum => 50}
+  validates :license_group_module_name, :presence => true, :length => {:maximum => 50}
   validates :picture_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :license_settings, :boost => {:boost_name => :license}
+  validates :license_group_settings, :boost => {:boost_name => :license_group}
+  validates :credit_picture_settings, :boost => {:boost_name => :credit_picture}
   
   def supply_default
   end
   
   def overwrite op
     attr = {:width => op.width, :height => op.height, :ext => op.ext, :filesize => op.filesize, 
-      :original_picture_id => op.id, :artist_id => op.artist_id, :md5 => op.md5
+      :original_picture_id => op.id, :artist_id => op.artist_id, :md5 => op.md5,
+      :created_at => Time.now, :updated_at => Time.now
     }
     self.attributes = attr
   end
@@ -199,11 +203,11 @@ class ResourcePicture < Peta::Content
   end
   
   def credit_template
-    "#{self.license_group_classname.tableize}/attributes/credit"
+    "#{self.license_group_module_name.tableize}/attributes/credit"
   end
   
   def full_credit_template
-    "#{self.license_group_classname.tableize}/attributes/full_credit"
+    "#{self.license_group_module_name.tableize}/attributes/full_credit"
   end
   
 end