36 lines
720 B
Ruby
36 lines
720 B
Ruby
# -*- encoding : utf-8 -*-
|
|
class ImageContent < ActiveRecord::Base
|
|
belongs_to :image_file
|
|
|
|
has_one :portlet, :as => :content, :dependent => :destroy
|
|
STYLES = [["Grande","5"],["Taille moyenne","1"], ["Petite taille","2"], ["Petit carré","3"], ["Miniature","4"],["Orginale","6"]]
|
|
ALIGNS = [["centré","center"], ["gauche","left"],["droite","right"],["Aucun","none"]]
|
|
|
|
belongs_to :cible, :polymorphic => true
|
|
accepts_nested_attributes_for :cible
|
|
|
|
before_validation do
|
|
if !self.with_cible
|
|
|
|
self.cible_type = nil
|
|
self.cible_id = nil
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def url
|
|
|
|
if self.cible
|
|
cible.url
|
|
else
|
|
""
|
|
end
|
|
|
|
end
|
|
|
|
def self.picto
|
|
"picture-o"
|
|
end
|
|
end
|