Class: Conschedule::Schedule

Inherits:
ApplicationRecord show all
Defined in:
app/models/conschedule/schedule.rb

Instance Method Summary collapse

Instance Method Details

#cancelled?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/conschedule/schedule.rb', line 42

def cancelled?
  status == "cancelled"  
end

#display_action?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
# File 'app/models/conschedule/schedule.rb', line 46

def display_action?
  if status == "cancelled"
    return false 
  else
    slot_start_time = self.slot_date_time("app","start")
    current_time = Time.now.in_time_zone(app_time_zone)
    return current_time > slot_start_time ? false : true
  end  
end

#full_nameObject



13
14
15
# File 'app/models/conschedule/schedule.rb', line 13

def full_name
  [first_name,last_name].compact.join(" ")
end

#send_cancel_emailObject



24
25
26
27
28
29
30
31
# File 'app/models/conschedule/schedule.rb', line 24

def send_cancel_email
  if status_changed?
    SchedulesMailer.send_cancel_email_user(self).deliver
  end
  if Conschedule.send_cancel_mail && validate_to_address
    SchedulesMailer.send_cancel_email_owner(self).deliver  
  end	
end

#send_confirmation_emailObject



17
18
19
20
21
22
# File 'app/models/conschedule/schedule.rb', line 17

def send_confirmation_email
  SchedulesMailer.send_confirmation_email_user(self).deliver
  if Conschedule.send_confirmation_mail && validate_to_address
    SchedulesMailer.send_confirmation_email_owner(self).deliver    
  end  
end

#slot_date_time(version, period) ⇒ Object



56
57
58
59
# File 'app/models/conschedule/schedule.rb', line 56

def slot_date_time(version,period)
  tz = version == "app" ? app_time_zone : user_time_zone
  period == "start" ? slot_start_time.in_time_zone(tz) : slot_end_time.in_time_zone(tz)
end

#status_changed?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/conschedule/schedule.rb', line 33

def status_changed?
  changed_attributes.has_key?("status") && changed_attributes["status"] == "active"	
end

#validate_to_addressObject



37
38
39
40
# File 'app/models/conschedule/schedule.rb', line 37

def validate_to_address
  return false if Conschedule.to_address.downcase =~ /please-change-me/
  return true
end