From 46a481f93070d7f87d8aa5d916237f198947cc65 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 9 Apr 2015 13:04:54 -0300 Subject: [PATCH] Customize pairwise content views when it belongs to a group --- lib/pairwise_plugin/helpers/viewer_helper.rb | 26 ++++++++++++++++++-------- lib/pairwise_plugin/pairwise_content.rb | 4 ++++ views/content_viewer/_prompt_body.html.erb | 10 +++++++++- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/pairwise_plugin/helpers/viewer_helper.rb b/lib/pairwise_plugin/helpers/viewer_helper.rb index 970e0e5..06c826a 100644 --- a/lib/pairwise_plugin/helpers/viewer_helper.rb +++ b/lib/pairwise_plugin/helpers/viewer_helper.rb @@ -81,14 +81,24 @@ module PairwisePlugin::Helpers::ViewerHelper end def pairwise_embeded_code(pairwise_content) - embeded_url = url_for({:controller => "pairwise_plugin_profile", - :profile => pairwise_content.profile.identifier, - :action => "prompt", - :id => pairwise_content.id, - :question_id => pairwise_content.question.id, - :embeded => 1, - :source => "SOURCE_NAME", - :only_path => false}) + embeded_url = nil + if pairwise_content.in_group? + embeded_url = url_for({:controller => "pairwise_plugin_profile", + :profile => pairwise_content.profile.identifier, + :action => "group", + :id => pairwise_content.parent.id, + :embeded => 1, + :only_path => false}) + else + embeded_url = url_for({:controller => "pairwise_plugin_profile", + :profile => pairwise_content.profile.identifier, + :action => "prompt", + :id => pairwise_content.id, + :question_id => pairwise_content.question.id, + :embeded => 1, + :source => "SOURCE_NAME", + :only_path => false}) + end embeded_code = "" label = "
" diff --git a/lib/pairwise_plugin/pairwise_content.rb b/lib/pairwise_plugin/pairwise_content.rb index 919fc56..7447aae 100644 --- a/lib/pairwise_plugin/pairwise_content.rb +++ b/lib/pairwise_plugin/pairwise_content.rb @@ -324,6 +324,10 @@ class PairwisePlugin::PairwiseContent < Article 20 end + def in_group? + parent.kind_of?(PairwisePlugin::PairwiseGroup) + end + private def set_next_prompt(prompt) diff --git a/views/content_viewer/_prompt_body.html.erb b/views/content_viewer/_prompt_body.html.erb index 2b7f350..d7396d6 100644 --- a/views/content_viewer/_prompt_body.html.erb +++ b/views/content_viewer/_prompt_body.html.erb @@ -2,7 +2,15 @@
<%= render :partial => 'content_viewer/menu', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :active_tab => :prompt} %>
-
<%= pairwise_content.title %>
+ <% if pairwise_content.in_group? %> +
<%= pairwise_content.parent.title %>
+
+ <%= pairwise_content.parent.body %> +
+
<%= pairwise_content.title %>
+ <% else %> +
<%= pairwise_content.title %>
+ <% end %>
<%= pairwise_content.body %>
<%= render :partial => 'content_viewer/pairwise_prompts', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => question, :source => (defined?(source) ? source : '') } %> <% if embeded %> -- libgit2 0.21.2