<% if !@posts.empty? %>
	<% @posts.each do |post| %>
		<div class="post">
			<h2 class="post-title"><a href="/posts/<%=post.id%>"><%= post.title %></a></h2>
				<p class="post-body"><%= post.content %></p>
				<p class="post-request-for-responses"><%= post.requests_for_responses %></p>
				<p class="post-additional-resources"><%= post.additional_resources %></p>
			<div class="post-engagement-links">
				<% if current_user %>
					<!-- link_to "Write Response", "/posts/:id/responses/new" -->
					<a href="/posts/<%=post.id%>/responses/new">Write Response</a>
				<% elsif current_user == post.writer %>
					<a href="/posts/<%post.id%>/edit">Edit Post</a>
				<% end %>
			</div>
		</div>	
	<% end %>
<% else %>
	<p>There are currently no published posts for this topic.</p>
<%end%>


<% if !@posts.empty? %>
	<% @posts.each do |post| %>
		<div class="post">
			<h2 class="post-title"><a href="/posts/<%=post.id%>"><%= post.title %></a></h2>
				<p class="post-body"><%= post.content %></p>
				<p class="post-request-for-responses"><%= post.requests_for_responses %></p>
				<p class="post-additional-resources"><%= post.additional_resources %></p>
				<div class="post_responses">
					<% if post.responses %>
					  <% post.responses.each do |response| %>
							<% if response.approved || current_user == post.writer %>
								<div class="response">
									<h6><a href="/posts/<%=post.id%>/responses/<%=response.id%>"><%= response.title %></a></h6>
									<p><%= response.content %></p>
									<p class="response_author"><%=response.writer.username %></p>
									<p class="response_date"><%=response.created_at %></p>
								</div>
							<% end %>
						<% end %>
					<% end %>
				</div>	
			<div class="post-engagement-links">
				<% if current_user && current_user != post.writer %>
					<!-- link_to "Write Response", "/posts/:id/responses/new" -->
					<a href="/posts/<%=post.id%>/responses/new">Write Response</a>
				<% elsif current_user == post.writer %>
					<a href="/posts/<%post.id%>/edit">Edit Post</a>
				<% end %>
			</div>
		</div>
	<% end %>	
<% else %>
	<p>There are currently no published posts for this topic.</p>
<% end %>


Add only approved responses to view for non-logged in users
Add only approved responses to view for non-logged in users
