tracks/app/models/preference.rb
Jyri-Petteri Paloposki f395ee1266 Fix code style issues and the sender map logic to handle the empty pref case correctly.
Also fixed the rails script to use the correct directory always.
2022-02-22 22:52:28 +02:00

37 lines
824 B
Ruby

class Preference < ApplicationRecord
belongs_to :user
belongs_to :sms_context, :class_name => 'Context'
validates :sms_email, uniqueness: { case_sensitive: false }
def self.themes
{ :black => 'black', :light_blue => 'light_blue' }
end
def self.due_styles
{ :due_in_n_days => 0, :due_on => 1 }
end
def hide_completed_actions?
return show_number_completed == 0
end
def parse_date(s)
return nil if s.blank?
date = nil
if s.is_a?(Time)
date = s.to_date
elsif s.is_a?(String)
date = Date.strptime(s, date_format)
else
raise ArgumentError.new("Bad argument type:#{s.class}")
end
date.in_time_zone(time_zone).beginning_of_day
end
def format_date(date)
return date ? date.in_time_zone(time_zone).strftime("#{date_format}") : ''
end
end