class UserStats < Netzke::Base def body_content(user) bike = user.bike completed = user.completed_build_bikes #TODO I think it's time to switch to a template body = "" body += %Q(
) body += %Q(

Username: #{user.username}

Total Credits Earned: #{user.total_earned_credits}

Credits Available: #{user.total_credits}

Credits Spent: #{user.total_credits_spent}

Total Hours Worked: #{user.total_hours}

Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}

Current bike Shop ID: #{bike.shop_id if bike}

Current bike S/N: #{bike.serial_number if bike}

) unless completed.empty? body += %Q(

Previously built bikes (#{completed.count}):

) body += %Q() end body += %Q(
) end js_configure do |c| c.body_padding = 15 c.title = "User Stats" c.mixin :user_stats end endpoint :server_update do |params, this| # updateBodyHtml is a JS-side method we inherit from Netkze::Basepack::Panel this[:update] = [body_content(user)] end private def user User.find_by_id(session[:selected_user_id]) || controller.current_user end end