<% category[:fields].reject { |field| field[:hidden] }.each do |serialized_field| %>
<%# Don't show private fields unless we're signed in AND the owner of the content %>
<% 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]
when 'tags'
content.page_tags
else
raise "unknown field type = " + serialized_field[:type].inspect
end
%>
<%
# Don't show fields with a blank value
next if value.blank?
%>
<%
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: ''
%>
<%= serialized_field[:label] %>
<%= "- #{prompt}" unless prompt.blank? %>
<%=
render partial: "content/display/attribute_value/#{serialized_field[:type]}",
locals: { value: value, content: content }
%>
<% end %>