indentlabs/notebook

View on GitHub
app/views/thredded/users/_badge.html.erb

Summary

Maintainability
Test Coverage
<%
  badge_style  = 'padding: 3px 5px; font-size: 70%; font-weight: normal;'
  badge_text   = user.forums_badge_text

  if user.favorite_page_type?
    favorite_link = link_to main_app.send("#{user.favorite_page_type.downcase.pluralize}_user_path", { id: user.id }) do
      content_tag(:i, class: "material-icons tiny #{content_class_from_name(user.favorite_page_type).try(:text_color)}", style: 'position: relative; top: 4px') do
        "#{content_class_from_name(user.favorite_page_type).try(:icon)}"
      end
    end

    badge_text = favorite_link + badge_text
  end
%>

<% if user.respond_to?(:selected_billing_plan_id) %>
  <% if user.id == 5 %>
    <span style="<%= badge_style %>; background: #2196F3; color: white"><%= badge_text.presence || 'Admin' %></span>
  <% elsif user.selected_billing_plan_id == 2 %>
    <span style="<%= badge_style %>; background: #dedeff"><%= badge_text.presence || 'Beta Tester' %></span>
  <% elsif user.selected_billing_plan_id == 3 %>
    <span style="<%= badge_style %>; background: #ffdede"><%= badge_text.presence || 'Early Adopter' %></span>
  <% elsif user.on_premium_plan? %>
    <span style="<%= badge_style %>; background: #ffffaa"><%= badge_text.presence || 'Premium Supporter' %></span>
  <% else %>
    <%= favorite_link %>
  <% end %>
<% end %>