diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 471f8d23..dceddedf 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -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 } } diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index c8420b8e..f0061998 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -11,6 +11,7 @@ <%= render partial: 'cards/serendipitous/content_question', locals: { question: @question, content: @content } %> <% end %> +<% categories = @content.class.attribute_categories(@content.user) %>
@@ -20,7 +21,7 @@
- <% content.class.attribute_categories(current_user).each do |category| %> + <% categories.each do |category| %>
_panel" class="row panel"> <% if category.name == 'gallery' %>
@@ -28,7 +29,7 @@
<% 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 %>