app/models/adminpanel/gallery.rb in adminpanel-1.2.12 vs app/models/adminpanel/gallery.rb in adminpanel-2.0.0
- old
+ new
@@ -1,15 +1,15 @@
require "carrierwave"
require "carrierwave/orm/activerecord"
module Adminpanel
class Gallery < ActiveRecord::Base
- attr_accessible :file
+ include Adminpanel::Base
mount_uploader :file, Adminpanel::GalleryUploader
validates_presence_of :file
- act_as_a_gallery
+ include Adminpanel::Galleryzation
def move_to_better_position
if self.position > 1
conflicting_gallery = Gallery.find_by_position(position - 1)
self.update_attribute(:position, self.position - 1)
@@ -45,14 +45,18 @@
}
]
end
def self.display_name
- I18n.t('Gallery')
+ I18n.t('gallery.name')
end
def self.icon
- 'icon-picture'
+ 'picture-o'
+ end
+
+ def name
+ File.basename(file.path)
end
private
def rearrange_positions
unarranged_galleries = Gallery.where("position > ?", self.position)