2016-09-24 03:00:46 +00:00
|
|
|
# frozen_string_literal: true
|
2017-11-25 19:23:47 +00:00
|
|
|
|
2016-02-03 13:38:41 +00:00
|
|
|
class UserPreference
|
2017-03-08 18:50:39 +00:00
|
|
|
attr_accessor :metacodes, :metacode_focus, :follow_topic_on_created, :follow_topic_on_contributed,
|
|
|
|
:follow_map_on_created, :follow_map_on_contributed
|
2016-07-26 00:14:23 +00:00
|
|
|
|
2016-02-03 13:38:41 +00:00
|
|
|
def initialize
|
2018-01-21 22:21:00 +00:00
|
|
|
@metacodes = init_metacodes.compact
|
|
|
|
@metacode_focus = @metacodes[0]
|
|
|
|
initialize_follow_settings
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def init_metacodes
|
|
|
|
%w[Action Aim Idea Question Note Wildcard Subject].map do |m|
|
2016-09-21 17:22:40 +00:00
|
|
|
begin
|
2017-01-24 00:30:13 +00:00
|
|
|
metacode = Metacode.find_by(name: m)
|
2018-01-21 22:21:00 +00:00
|
|
|
metacode.id.to_s if metacode
|
2016-09-21 17:22:40 +00:00
|
|
|
rescue ActiveRecord::StatementInvalid
|
|
|
|
if m == 'Action'
|
2016-09-24 03:00:46 +00:00
|
|
|
Rails.logger.warn('TODO: remove this travis workaround in user_preference.rb')
|
2016-09-21 17:22:40 +00:00
|
|
|
end
|
|
|
|
end
|
2018-01-21 22:21:00 +00:00
|
|
|
end.compact
|
2017-03-08 18:50:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def initialize_follow_settings
|
|
|
|
@follow_topic_on_created = false
|
|
|
|
@follow_topic_on_contributed = false
|
2017-10-15 18:07:11 +00:00
|
|
|
@follow_map_on_created = true
|
2017-03-08 18:50:39 +00:00
|
|
|
@follow_map_on_contributed = false
|
2016-02-03 13:38:41 +00:00
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
end
|