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
|
2020-09-22 15:19:59 +00:00
|
|
|
field :land_area, localize: true
|
|
|
|
field :building_area, localize: true
|
2020-05-07 15:26:34 +00:00
|
|
|
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-09-08 06:12:14 +00:00
|
|
|
has_many :venue_management_bills, :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-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
|
2020-08-09 13:47:41 +00:00
|
|
|
end
|
|
|
|
def contractors
|
|
|
|
last_contract = self.venue_management_contracts.desc(:id).first
|
|
|
|
last_contract.contractors rescue []
|
|
|
|
end
|
|
|
|
def display_contractors
|
|
|
|
last_contract = self.venue_management_contracts.desc(:id).first
|
|
|
|
contractors = last_contract.contractors rescue []
|
|
|
|
contractors.map{|m| m.name}.join(" , ")
|
|
|
|
end
|
|
|
|
def display_tags
|
|
|
|
last_inviting = self.venue_management_invitings.desc(:id).first
|
|
|
|
last_inviting.tags.map{|t| t.name}.join(" , ") rescue ""
|
|
|
|
end
|
|
|
|
def display_event_during
|
|
|
|
last_contract = self.venue_management_contracts.desc(:id).first
|
|
|
|
if last_contract.nil?
|
|
|
|
"" #self.class.time_range(self.venue_management_start_date, self.venue_management_end_date)
|
|
|
|
else
|
|
|
|
self.class.time_range(last_contract.contract_start_date, last_contract.contract_end_date)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def display_signup_during
|
|
|
|
last_inviting = self.venue_management_invitings.desc(:id).first
|
|
|
|
if last_inviting.nil?
|
|
|
|
"" #self.class.time_range(self.signup_start_date, self.signup_end_date)
|
|
|
|
else
|
|
|
|
self.class.time_range(last_inviting.start_date, last_inviting.end_date)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def manager_emails
|
|
|
|
MemberProfile.where(:id.in => self.manager_ids).collect{|v| v.email}
|
2020-05-07 15:26:34 +00:00
|
|
|
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-09-14 14:55:39 +00:00
|
|
|
def newest_case_no
|
|
|
|
last_contract = self.venue_management_contracts.desc(:id).first
|
|
|
|
newest_case_no = last_contract.venue_management_inviting.case_no rescue ""
|
|
|
|
return ( newest_case_no.blank? ? I18n.t(:empty) : newest_case_no)
|
|
|
|
end
|
2020-05-07 15:26:34 +00:00
|
|
|
end
|