From e2e2fbbdc6b26e00101f5d4d1b05c0d076c817c2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 26 Jan 2013 16:22:52 +0100 Subject: Add a bit of AJAX to remove the just deleted row in call_history#index --- app/models/call_history.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/call_history.rb b/app/models/call_history.rb index 4db056a..81342bd 100644 --- a/app/models/call_history.rb +++ b/app/models/call_history.rb @@ -3,6 +3,9 @@ class CallHistory < ActiveRecord::Base belongs_to :caller_account, :polymorphic => true belongs_to :callee_account, :polymorphic => true belongs_to :auth_account, :polymorphic => true + + validates :start_stamp, + :presence => true def display_number if self.entry_type == 'dialed' @@ -78,10 +81,11 @@ class CallHistory < ActiveRecord::Base end def display_call_date(date_format, date_today_format) - if self.start_stamp.strftime('%Y%m%d') == DateTime::now.strftime('%Y%m%d') + if self.start_stamp.to_date == Date.today return self.start_stamp.strftime(date_today_format) + else + return self.start_stamp.strftime(date_format) end - return self.start_stamp.strftime(date_format) end def display_duration @@ -129,6 +133,14 @@ class CallHistory < ActiveRecord::Base end + def voicemail_message? + begin + return self.call_historyable.voicemail_messages.where(:forwarded_by => self.caller_channel_uuid).any? + rescue + return nil + end + end + def voicemail_message begin return self.call_historyable.voicemail_messages.where(:forwarded_by => self.caller_channel_uuid).first -- cgit v1.2.3