54 lines
1.4 KiB
Ruby
54 lines
1.4 KiB
Ruby
# encoding: utf-8
|
|
class ComVnccuProgram
|
|
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
|
|
include OrbitModel::Status
|
|
include OrbitModel::Impression
|
|
include OrbitCategory::Categorizable
|
|
|
|
|
|
field :year
|
|
field :semester
|
|
field :program_name
|
|
field :open_song, :type => Boolean, :default => false
|
|
field :week
|
|
field :hour
|
|
field :description
|
|
field :host, :type => Array
|
|
|
|
field :create_user_id
|
|
field :update_user_id
|
|
|
|
has_many :com_vnccu_program_links, :autosave => true, :dependent => :destroy
|
|
has_many :com_vnccu_program_song_lists, :autosave => true, :dependent => :destroy
|
|
|
|
accepts_nested_attributes_for :com_vnccu_program_links, :allow_destroy => true
|
|
accepts_nested_attributes_for :com_vnccu_program_song_lists, :allow_destroy => true
|
|
|
|
# scope :can_display, ->{any_of({:sign_start_date.lt=>Time.now, :sign_end_date.gt=>Time.now},{:sign_start_date.lt=>Time.now, :sign_end_date=>nil}).order_by([:is_top, :desc])}
|
|
|
|
def get_hosts
|
|
@values = Array.new()
|
|
|
|
@role = Role.where(:key=>"host").first
|
|
for i in 1..5
|
|
@nickname_field = AttributeField.where(:key => i.to_s, :role_id => @role).first
|
|
@values_data = AttributeValue.where(:attribute_field_id => @nickname_field, :val.ne => "").collect{|t|t[:val]}.join('-').split('-')
|
|
|
|
@values.concat(@values_data)
|
|
end
|
|
|
|
return @values.reject(&:empty?)
|
|
|
|
end
|
|
|
|
def get_hosts_name(hosts=nil)
|
|
|
|
return hosts.join(",") if !hosts.blank?
|
|
|
|
end
|
|
|
|
end
|