Project

General

Profile

Download (1.17 KB) Statistics
| Branch: | Tag: | Revision:
b689e231 Marc Dequènes (Duck)
class Artwork < ActiveRecord::Base
belongs_to :artwork_set
belongs_to :artwork_group
belongs_to :artwork_size
belongs_to :artwork_condition
belongs_to :artwork_placement_reason
ba788eca Marc Dequènes (Duck)
has_many :artwork_step_images, :order => "date ASC, position ASC, id DESC"
70e65017 Marc Dequènes (Duck)
has_and_belongs_to_many :artwork_supports, :order => "name ASC"
3807b362 Marc Dequènes (Duck)
has_and_belongs_to_many :artwork_materials, :order => "name ASC"
2a4e5c89 Marc Dequènes (Duck)
has_and_belongs_to_many :tags, :order => "name ASC"
b689e231 Marc Dequènes (Duck)
3807b362 Marc Dequènes (Duck)
validates_presence_of :title, :artwork_size_id, :artwork_condition_id
b689e231 Marc Dequènes (Duck)
validates_uniqueness_of :title
validates_length_of :title, :within => 1..256, :allow_blank => true
validates_length_of :placement_location, :within => 1..256, :allow_blank => true
3807b362 Marc Dequènes (Duck)
validates_associated :artwork_set, :artwork_group, :artwork_size, :artwork_condition
b689e231 Marc Dequènes (Duck)
before_save {|model| model.artwork_group = nil if model.artwork_set.nil? }

def image
return nil if self.artwork_step_images.empty?
self.artwork_step_images.last
end
bf16d414 Marc Dequènes (Duck)
def full_title
str = ""
str += self.artwork_set.name unless artwork_set.nil?
str += " :: " + self.artwork_group.name unless artwork_group.nil?
str += " :: " unless str == ""
str += self.title
end
b689e231 Marc Dequènes (Duck)
end