venue_management/app/models/venue_management_main.rb

98 lines
4.0 KiB
Ruby
Raw Normal View History

2020-05-07 15:26:34 +00:00
class VenueManagementMain
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Impression
# encoding: utf-8
include OrbitCategory::Categorizable
include Slug
2020-07-27 16:34:33 +00:00
2020-05-07 15:26:34 +00:00
field :title, as: :slug_title, type: String, localize: true
field :speaker, localize: true
field :content, localize: true
field :land_number, localize: true
field :area, localize: true
field :land_zoning, localize: true
field :act_place, localize: true
field :manager_ids, type: Array,default: []
field :contractor_ids, type: Array,default: []
field :coordinator_ids, type: Array,default: []
field :venue_management_start_date, :type => Date, :default => Time.now
field :venue_management_end_date, :type => Date, :default => Time.now
field :signup_start_date, :type => Date, :default => Time.now
field :signup_end_date, :type => Date, :default => Time.now
field :contribute_start_date, :type => Date
field :contribute_end_date, :type => Date
2020-07-27 16:34:33 +00:00
2020-05-07 15:26:34 +00:00
field :contribute_file_count, type: String
field :registration_status , :type => Array #C: 投稿者 G:一般
field :create_user_id
field :update_user_id
belongs_to :venue_management_item
2020-07-27 16:34:33 +00:00
has_many :venue_management_invitings, :autosave => true, :dependent => :destroy
2020-07-30 14:28:57 +00:00
has_many :venue_management_memorabilias, :autosave => true, :dependent => :destroy
2020-07-30 17:30:14 +00:00
has_many :venue_management_contracts, :autosave => true, :dependent => :destroy
2020-05-07 15:26:34 +00:00
has_many :venue_management_item_contents, :autosave => true, :dependent => :destroy
has_many :venue_management_signups, :autosave => true, :dependent => :destroy
has_many :venue_management_submission_fields, :autosave => true, :dependent => :destroy
has_many :venue_management_signup_fields, :autosave => true, :dependent => :destroy
has_many :venue_management_reviews, :autosave => true, :dependent => :destroy
has_many :venue_management_signup_field_sets, autosave: true, dependent: :destroy
has_many :venue_management_submission_field_sets, autosave: true, dependent: :destroy
has_many :venue_management_email_sets, autosave: true, dependent: :destroy
has_many :venue_management_signup_field_customs, :autosave => true, :dependent => :destroy
2020-08-02 13:33:41 +00:00
accepts_nested_attributes_for :venue_management_memorabilias, :allow_destroy => true
2020-05-07 15:26:34 +00:00
accepts_nested_attributes_for :venue_management_item_contents, :allow_destroy => true
accepts_nested_attributes_for :venue_management_signups, :allow_destroy => true
accepts_nested_attributes_for :venue_management_submission_fields, :allow_destroy => true
accepts_nested_attributes_for :venue_management_signup_fields, :allow_destroy => true
accepts_nested_attributes_for :venue_management_reviews, :allow_destroy => true
accepts_nested_attributes_for :venue_management_signup_field_sets, :allow_destroy => true
accepts_nested_attributes_for :venue_management_submission_field_sets, :allow_destroy => true
accepts_nested_attributes_for :venue_management_email_sets, :allow_destroy => true
accepts_nested_attributes_for :venue_management_signup_field_customs, :allow_destroy => true
2020-08-02 13:33:41 +00:00
include VenueLinkFile
2020-08-04 09:04:04 +00:00
def manager_emails
MemberProfile.where(:id.in => self.manager_ids).collect{|v| v.email}
end
2020-05-07 15:26:34 +00:00
def self.time_range(date1 = null, date2 = null)
if !date1.blank?
r = "#{date1.strftime('%Y-%m-%d')}"
if date2
2020-07-27 16:34:33 +00:00
r += " - #{date2.strftime('%Y-%m-%d')}"
2020-05-07 15:26:34 +00:00
else
r += " - #{I18n.t(:no_deadline)}"
end
r
end
end
def get_attribute_value(attribute_field, signup_id)
VenueManagementSignupValue.find_by(venue_management_signup_field_id: attribute_field.id, venue_management_signup_id: signup_id)
end
def get_attribute_values(attribute_type=nil)
@attribute_values = attribute_type.venue_management_signup_values rescue nil
end
2020-07-27 16:34:33 +00:00
2020-05-07 15:26:34 +00:00
def get_value_from_field_id(field_id,attribute_type=nil)
values = get_attribute_values(attribute_type)
value = values.detect {|value| value.venue_management_signup_field_id == field_id} rescue nil
value ? value : nil
end
2020-08-04 09:04:04 +00:00
def case_no
''
end
2020-05-07 15:26:34 +00:00
end