Merge branch 'master' into release/material-design-tweaks

Conflicts:
	app/views/content/show.html.erb
This commit is contained in:
Andrew Brown 2017-02-28 22:38:22 +00:00
commit 0ca4e04b12
2 changed files with 20 additions and 8 deletions

View File

@ -27,11 +27,22 @@ class ContentController < ApplicationController
if (current_user || User.new).can_read? @content
@question = @content.question if current_user.present? and current_user == @content.user
Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(current_user.id, 'viewed content', {
'content_type': content_type.name,
'content_owner': current_user.present? && current_user.id == @content.user_id,
'logged_in_user': current_user.present?
}) if current_user
if current_user
if @content.updated_at > 30.minutes.ago
Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(current_user.id, 'viewed content', {
'content_type': content_type.name,
'content_owner': current_user.present? && current_user.id == @content.user_id,
'logged_in_user': current_user.present?
})
else
Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(current_user.id, 'viewed recently-modified content', {
'content_type': content_type.name,
'content_owner': current_user.present? && current_user.id == @content.user_id,
'logged_in_user': current_user.present?
})
end
end
respond_to do |format|
format.html { render 'content/show', locals: { content: @content } }

View File

@ -11,6 +11,7 @@
<%= render partial: 'cards/serendipitous/content_question', locals: { question: @question, content: @content } %>
<% end %>
<% categories = @content.class.attribute_categories(@content.user) %>
<div class="row">
<div class="col s9">
<div class="card">
@ -20,7 +21,7 @@
</div>
<div class="card-content">
<% content.class.attribute_categories(current_user).each do |category| %>
<% categories.each do |category| %>
<div id="<%= category.name.gsub("'", '') %>_panel" class="row panel">
<% if category.name == 'gallery' %>
<div>
@ -28,7 +29,7 @@
</div>
<% end %>
<% category.attribute_fields.each do |attribute| %>
<% next if attribute.name.start_with?("private") && @content.user != current_user %>
<% next if attribute.name.start_with?("private") && (current_user.nil? || @content.user != current_user) %>
<%
custom_field = false
@ -37,7 +38,7 @@
value = content.send(attribute.name.to_sym)
else
custom_field = true
value = Attribute.where(user: current_user, attribute_field: attribute, entity: content).first || ""
value = Attribute.where(user: @content.user, attribute_field: attribute, entity: content).first || ""
end
%>
<% next if value.blank? && !custom_field %>