2007-03-30 04:36:52 +00:00
|
|
|
class Preference < ActiveRecord::Base
|
|
|
|
|
belongs_to :user
|
2008-06-04 18:16:06 -07:00
|
|
|
belongs_to :sms_context, :class_name => 'Context'
|
2009-01-11 17:57:07 +08:00
|
|
|
|
2007-09-26 12:05:21 +00:00
|
|
|
def self.due_styles
|
|
|
|
|
{ :due_in_n_days => 0, :due_on => 1}
|
|
|
|
|
end
|
2009-01-11 17:57:07 +08:00
|
|
|
|
2007-03-30 04:36:52 +00:00
|
|
|
def hide_completed_actions?
|
|
|
|
|
return show_number_completed == 0
|
|
|
|
|
end
|
2009-01-11 17:57:07 +08:00
|
|
|
|
2007-11-04 23:06:46 +00:00
|
|
|
def parse_date(s)
|
|
|
|
|
return nil if s.blank?
|
2009-01-11 17:57:07 +08:00
|
|
|
date = nil
|
|
|
|
|
|
|
|
|
|
if s.is_a?(Time)
|
2009-03-24 23:05:23 +01:00
|
|
|
date = s.in_time_zone(time_zone).to_date
|
2009-01-11 17:57:07 +08:00
|
|
|
elsif s.is_a?(String)
|
|
|
|
|
date = Date.strptime(s, date_format)
|
|
|
|
|
else
|
|
|
|
|
raise ArgumentError.new("Bad argument type:#{s.class}")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
user.at_midnight(date)
|
2007-11-04 23:06:46 +00:00
|
|
|
end
|
2009-01-11 17:57:07 +08:00
|
|
|
end
|