2016-03-25 04:26:07 +00:00
|
|
|
module ApplicationHelper
|
2015-09-19 12:17:56 +00:00
|
|
|
def get_metacodeset
|
2016-03-25 04:26:07 +00:00
|
|
|
@m = current_user.settings.metacodes
|
2016-07-26 00:14:23 +00:00
|
|
|
set = @m[0].include?('metacodeset') ? MetacodeSet.find(@m[0].sub('metacodeset-', '').to_i) : false
|
|
|
|
set
|
2015-09-19 12:17:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def user_metacodes
|
2016-03-25 04:26:07 +00:00
|
|
|
@m = current_user.settings.metacodes
|
2015-09-19 12:17:56 +00:00
|
|
|
set = get_metacodeset
|
2016-07-26 00:14:23 +00:00
|
|
|
@metacodes = if set
|
|
|
|
set.metacodes.to_a
|
|
|
|
else
|
|
|
|
Metacode.where(id: @m).to_a
|
|
|
|
end
|
|
|
|
@metacodes.sort! { |m1, m2| m2.name.downcase <=> m1.name.downcase }.rotate!(-1)
|
2015-09-19 12:17:56 +00:00
|
|
|
end
|
2016-03-25 04:26:07 +00:00
|
|
|
|
|
|
|
def determine_invite_link
|
2016-07-26 00:14:23 +00:00
|
|
|
"#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : '')
|
2016-03-25 04:26:07 +00:00
|
|
|
end
|
2012-09-23 02:39:12 +00:00
|
|
|
end
|