OSDN Git Service

t#30339:test
[pettanr/pettanr.git] / app / models / original_picture.rb
index 7bdacca..0332fbd 100644 (file)
@@ -15,6 +15,7 @@ class OriginalPicture < ActiveRecord::Base
   end
   
   def overwrite ar
+    self.uploaded_at = Time.now
     self.artist_id = ar.id
   end
   
@@ -55,19 +56,21 @@ class OriginalPicture < ActiveRecord::Base
   end
   
   def unpublished?
-    self.pictures.empty?
+    self.published_at == nil and self.stopped_at == nil
   end
   
   def stopped?
-    self.pictures.any? and self.resource_picture == nil
+    self.stopped_at != nil
   end
   
   def unlicensed?
-    self.pictures.any? and self.resource_picture and self.updated_at > self.pictures.first.head.updated_at
+    dt = self.published_at || self.stopped_at
+    return false unless dt
+    self.uploaded_at > dt
   end
   
   def published?
-    self.pictures.any? and self.resource_picture and self.updated_at < self.pictures.first.head.updated_at
+    self.published_at != nil
   end
   
   def self.default_page_size