noesya/osuny

View on GitHub
app/views/admin/application/favorites/_show.html.erb

Summary

Maintainability
Test Coverage
<h2 class="category"><%= User::Favorite.model_name.human(count: 2) %></h2>
<%
if current_user.favorites.none?
  if current_university.is_really_a_university?
    no_favorites_locale_key = 'user.favorites.none.in_university'
  else
    no_favorites_locale_key = 'user.favorites.none.not_in_university'
  end
%>
  <p><%= t(no_favorites_locale_key) %></p>
<% else %>
  <% websites = current_user.favorites.websites.collect(&:about) %>
  <%= render 'admin/communication/websites/list', websites: websites %>
  <% other = current_user.favorites.except_websites %>
  <% if other.any? %>
    <div class="row">
      <% current_user.favorites.except_websites.each do |favorite|
          about = favorite.about
          next unless can?(:read, about) %>
        <div class="col-md-6 col-lg-3 d-flex">
          <%= osuny_panel about.to_s_in(current_language) do %>
            <p class="small mt-n2 mb-1"><%= about.class.model_name.human %></p>
            <%= link_to t('show'),
                        [:admin, about],
                        class: 'action stretched-link' %>
          <% end %>
        </div>
      <% end %>
    </div>
  <% end %>
<% end %>