This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
phone_app/app/models/gallery_content.rb
2021-08-23 10:26:02 +02:00

50 lines
862 B
Ruby

# -*- encoding : utf-8 -*-
class GalleryContent < ApplicationRecord
has_many :gallery_images, -> {order :position}
has_one :portlet, :as => :content, :dependent => :destroy
STYLES = [["Petites miniatures",1], ["Diaporama",2], ["Petits carrés",3], ["Réalisations",4]]
def dup
@new = GalleryContent.new(self.attributes)
@new.id = nil
@new.save
self.gallery_images.each do |gallery_image|
new_g = gallery_image.dup
new_g.gallery_content = @new
new_g.save
end
@new
end
def tags
to_r = []
self.gallery_images.each do |gallery_image|
gallery_image.tags.to_s.split(",").each do |tag|
to_r << tag.strip
end
end
to_r = to_r.sort.uniq
return to_r
end
def self.picto
""
end
end