{:src => self.url, :width => tw, :height => th}
end
+ def unpublished?
+ self.pictures.empty?
+ end
+
+ def stopped?
+ self.pictures.any? and self.resource_picture == nil
+ end
+
+ def unlicensed?
+ self.pictures.any? and self.resource_picture and self.updated_at > self.pictures.first.head.updated_at
+ end
+
+ def published?
+ self.pictures.any? and self.resource_picture and self.updated_at < self.pictures.first.head.updated_at
+ end
+
def self.default_page_size
25
end
def store(imager)
unless imager
- self.errors.add :base, 'illegal picture data'
+ self.errors.add :base, I18n.t('errors.invalid_image')
return false
end
res = false
self.attributes = {:ext => imager.ext, :width => imager.width, :height => imager.height, :filesize => imager.filesize, :md5 => imager.md5}
OriginalPicture.transaction do
if res = self.save
- if res = PictureIO.original_picture_io.put(imager.binary, self.filename)
- res = true
- else
- self.errors.add :base, 'original picture io does not work'
+ begin
+ res = PictureIO.original_picture_io.put(imager.binary, self.filename)
+ rescue PictureIO::Error
+ res = false
+ self.errors.add :base, I18n.t('picture_io.error')
raise ActiveRecord::Rollback
end
end