venue_management/app/models/venue_management_memorabili...

39 lines
1.0 KiB
Ruby
Raw Normal View History

2020-07-30 14:28:57 +00:00
class VenueManagementMemorabilia
include Mongoid::Document
include Mongoid::Timestamps
2020-11-13 07:00:10 +00:00
require 'mongoid/enum'
2020-07-30 14:28:57 +00:00
include Mongoid::Enum
field :event_date, type: Date, default: Time.now
field :details, localize: true
2020-08-02 13:33:41 +00:00
def case_no
inviting = self.venue_management_inviting
if !inviting.nil?
inviting.case_no
else
I18n.t("empty")
2020-08-02 13:33:41 +00:00
end
end
belongs_to :venue_management_inviting
2020-07-30 14:28:57 +00:00
belongs_to :venue_management_main
2020-08-02 13:33:41 +00:00
include VenueLinkFile
2021-04-05 03:08:58 +00:00
after_create do
venue_management = self.venue_management_main
if venue_management
venue_management.memorabilia = venue_management.memorabilia + 1
venue_management.save(:validate=>false)
end
end
after_destroy do
venue_management = self.venue_management_main
if venue_management
venue_management.memorabilia = venue_management.memorabilia - 1
venue_management.save(:validate=>false)
end
end
def display_details
html = self.details.to_s.split("\r\n").select{|s| !s.blank?}.first
return Nokogiri::HTML(html).css("body").text
end
2020-07-30 14:28:57 +00:00
end