33 lines
1.2 KiB
Ruby
33 lines
1.2 KiB
Ruby
module UsersHelper
|
|
|
|
# Returns the Gravatar (http://gravatar.com/) for the given user.
|
|
def gravatar_for(user, options = { size: 50, hclass: "gravatar" })
|
|
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
|
|
size = options[:size]
|
|
hclass = options[:hclass]
|
|
gravatar =
|
|
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
|
|
image_tag(gravatar_url, alt: "#{user.first_name} #{user.last_name}", class: "#{hclass}")
|
|
end
|
|
|
|
# this must be a user created by the MusicSession.approved_rsvp method
|
|
def process_approved_rsvps(approved_rsvp)
|
|
|
|
instrument_list = []
|
|
|
|
# instruments are all denormalized into json arrays. fix em up into an instrument_list on the user object
|
|
instrument_ids = approved_rsvp[:instrument_ids]
|
|
instrument_descs = approved_rsvp[:instrument_descriptions]
|
|
instrument_proficiencies = approved_rsvp[:instrument_proficiencies]
|
|
rsvp_request_id = approved_rsvp[:rsvp_request_ids][0] # there should always be only one
|
|
|
|
instrument_ids.each_with_index do |instrument_id, i|
|
|
desc = instrument_descs[i]
|
|
level = instrument_proficiencies[i]
|
|
instrument_list.push({ id: instrument_id, desc: desc, level: level})
|
|
end
|
|
|
|
instrument_list
|
|
end
|
|
end
|