<div id="<%= category[:name].gsub("'", '') %>_panel" class="row panel">
  <div class="row">
    <% category[:fields].select { |field| !field[:hidden] }.each do |serialized_field| %>
      <% if serialized_field[:label].start_with?("Private") %>
        <% next unless user_signed_in? && (
          (content.raw_model.is_a?(Universe) && content.user == current_user) ||
          (content.raw_model.respond_to?(:universe) && content.universe      && content.universe.user == current_user) ||
          (content.raw_model.respond_to?(:universe) && content.universe.nil? && content.user == current_user)
        )
        %>
      <% end %>

      <%
        value = case serialized_field[:type]
          when 'universe'
            Universe.where(id: serialized_field[:value].to_i)

          when 'name', 'text_area'
            serialized_field[:value]

          when 'link'
            serialized_field[:value]

            # Leaving this old code in just in case there's an issue with links after release; good to delete after a successful deploy + time
            # if serialized_field[:old_column_source].present? && content.raw_model.respond_to?(serialized_field[:old_column_source].to_sym)
            #   serialized_field[:value]
            # else
            #   # todo uhhhh is this just a safety guard or are there actual cases of bad data triggering here?
            #   nil
            # end

          when 'tags'
            content.page_tags

          else
            raise "unknown field type = " + serialized_field[:type].inspect
        end
      %>
      <% next if value.blank? %>

      <div class="col s12 m10 offset-m1 field-value">
        <div class="grey-text uppercase">
          <%
            prompt = I18n.translate "attributes.#{content.class_name.downcase}.#{serialized_field[:label].downcase.gsub(/\s/, '_')}",
              scope: :serendipitous_questions,
              name: content.name || "this #{content.class_name}",
              default: ''
          %>
          <span class="<%= prompt.present? ? 'tooltipped' : nil %>" data-tooltip="<%= prompt %>" data-position="right">
            <%= serialized_field[:label] %>
          </span>
        </div>

        <%= 
          render partial: "content/display/attribute_value/#{serialized_field[:type]}", 
                  locals: { value: value, content: content }
        %>
      </div>
    <% end %>
  </div>
</div>
