Noosfero/noosfero

View on GitHub
plugins/sniffer/views/blocks/interests.html.erb

Summary

Maintainability
Test Coverage
<%= block_title block.title, block.subtitle %>

<% if block.owner.is_a?(Profile) %>
  <ul>
    <% block.interests.each do |interest| %>
      <li><%= interest.product_category.name %></li>
    <% end %>
  </ul>

  <div>
    <% if logged_in? and (current_user.person.is_admin?(environment) or profile.admins.include?(current_user.person)) %>
      <%= _('Edit %{inputs} and %{block.interests}') % {
        :inputs => link_to(_("products' inputs"), :controller => :manage_products, :action => :index),
        :interests => link_to(_('declared interests'), :controller => :sniffer_plugin_myprofile, :action => :edit),
      } %>
    <% end %>
  </div>
<% else %>
  <ul>
    <% block.interests.each do |interest| %>
      <li>
        <% profile = interest.is_a?(SnifferPlugin::Opportunity) ? interest.profile : interest.product.enterprise %>
        <%= _('%{interest} from %{profile}') % {
          :interest => interest.product_category.name,
          :profile => link_to_profile(profile.name, profile),
        } %>
      </li>
    <% end %>
  </ul>
<% end %>