OSDN Git Service

fic picture publishing
[pettanr/pettanr.git] / app / models / picture.rb
index 0725faf..85c68ef 100644 (file)
@@ -3,6 +3,7 @@ class Picture < Peta::Content
   load_manifest
   belongs_to :original_picture
   belongs_to :license
+  belongs_to :system_picture
   belongs_to :artist
   has_one :resource_picture
   
@@ -14,6 +15,7 @@ class Picture < Peta::Content
   validates :filesize, :presence => true, :numericality => {:greater_than => 0, :less_than_or_equal_to => 2000000}, :natural_number => true
   validates :md5, :presence => true, :length => {:minimum => 32, :maximum => 32}
   validates :license_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :artist_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :artist_name, :presence => true
   validates :license_group_classname, :presence => true, :length => {:maximum => 50}
@@ -23,7 +25,8 @@ class Picture < Peta::Content
   
   def overwrite rp
     attr = {:width => rp.width, :height => rp.height, :ext => rp.ext, :filesize => rp.filesize, 
-      :original_picture_id => rp.original_picture_id, :license_id => rp.license_id, :artist_id => rp.artist_id, 
+      :original_picture_id => rp.original_picture_id, :license_id => rp.license_id, 
+      :system_picture_id => rp.system_picture_id, :artist_id => rp.artist_id, 
       :md5 => rp.md5, :artist_name => rp.artist_name, 
       :license_group_classname => rp.license_group_classname, 
       :license_group_settings => rp.license_group_settings, 
@@ -78,6 +81,10 @@ class Picture < Peta::Content
     {:src => img, :width => tw, :height => th}
   end
   
+  def alt_name
+    self.license.license_group.caption.to_s + '[' + self.license.caption.to_s + ']'
+  end
+  
   def symbol_option
     self.tmb_opt_img_tag
   end