OSDN Git Service

fix bucket
[pettanr/pettanr.git] / app / models / resource_picture.rb
index 4a9f734..c6975ef 100644 (file)
@@ -3,6 +3,7 @@ class ResourcePicture < Peta::Content
   load_manifest
   belongs_to :artist
   belongs_to :license
+  belongs_to :system_picture
   belongs_to :picture
   belongs_to :original_picture
   
@@ -13,6 +14,7 @@ class ResourcePicture < Peta::Content
   validates :md5, :presence => true, :length => {:minimum => 32, :maximum => 32}
   validates :artist_id, :presence => true, :numericality => true, :existence => {:both => false}
   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}
@@ -29,8 +31,9 @@ class ResourcePicture < Peta::Content
   end
   
   def visible? operators
-    return false unless super
-    true
+    # no super
+    # content model call to owner checker
+    self.user_visible? operators
   end
   
   def filename
@@ -46,7 +49,7 @@ class ResourcePicture < Peta::Content
   end
   
   def url subdir = nil
-    '/resource_pictures/' + (subdir.to_s.empty? ? '' : subdir.to_s + '/' ) + filename
+    '/resource_pictures/' + filename + (subdir.to_s.empty? ? '' : '?subdir=' + subdir.to_s)
   end
   
   def to_gif?
@@ -67,6 +70,10 @@ class ResourcePicture < Peta::Content
     {:src => self.url('full'), :width => self.width, :height => self.height}
   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
@@ -99,6 +106,7 @@ class ResourcePicture < Peta::Content
     pc = Picture.new
     pc.supply_default
     pc.overwrite self
+    pc.boosts 'post'
     r = pc.store imager
     return pc if r
     self.errors.add :base, Picture.model_name.human + I18n.t('errors.not_create')