From cf6a397f114dab2b751c7ac994a031657ae00f1a Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Fri, 27 May 2016 10:07:37 -0300 Subject: [PATCH] fix html safe errors and wrong filter call --- lib/pairwise/question.rb | 26 ++++++++++++-------------- lib/pairwise_plugin/helpers/viewer_helper.rb | 2 +- views/content_viewer/_prompt_body.html.erb | 8 ++++---- views/content_viewer/_result.html.erb | 2 +- views/pairwise_plugin_suggestions/index.html.erb | 2 +- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/pairwise/question.rb b/lib/pairwise/question.rb index 5f9a5bf..7b214ae 100644 --- a/lib/pairwise/question.rb +++ b/lib/pairwise/question.rb @@ -17,25 +17,23 @@ class Pairwise::Question < ActiveResource::Base end def pending_choices(filter=nil, order=nil) - find_options = { - :question_id => self.id, - :include_inactive => true, - :inactive_ignore_flagged => 1, - :filter => filter, - :order => order - } + find_options = {} + find_options[:question_id] = self.id + find_options[:include_inactive] = true + find_options[:inactive_ignore_flagged] = 1 + find_options[:filter] = filter unless filter.nil? + find_options[:order] = order Pairwise::Choice.find(:all, :params => find_options) end def reproved_choices(filter=nil, order=nil) - find_options = { - :question_id => self.id, - :include_inactive => true, - :reproved => 1, - :filter => filter, - :order => order - } + find_options = {} + find_options[:question_id] = self.id + find_options[:include_inactive] = true + find_options[:reproved] = 1 + find_options[:filter] = filter unless filter.nil? + find_options[:order] = order Pairwise::Choice.find(:all, :params => find_options) end diff --git a/lib/pairwise_plugin/helpers/viewer_helper.rb b/lib/pairwise_plugin/helpers/viewer_helper.rb index 1847b31..aafd292 100644 --- a/lib/pairwise_plugin/helpers/viewer_helper.rb +++ b/lib/pairwise_plugin/helpers/viewer_helper.rb @@ -9,7 +9,7 @@ module PairwisePlugin::Helpers::ViewerHelper link_target.merge!(:source => source) if source loading_javascript = pairwise_spinner_show_function_call(pairwise_content) + pairwise_hide_skip_call(pairwise_content) - content_tag(:div, prompt.send("#{direction}_choice_text"), :class => 'choice-text') + + content_tag(:div, prompt.send("#{direction}_choice_text").html_safe, :class => 'choice-text') + link_to_remote(_('Vote'), :loading => loading_javascript, :url => link_target, :html => {:class => 'vote-link'}) end diff --git a/views/content_viewer/_prompt_body.html.erb b/views/content_viewer/_prompt_body.html.erb index c68af46..324b598 100644 --- a/views/content_viewer/_prompt_body.html.erb +++ b/views/content_viewer/_prompt_body.html.erb @@ -5,13 +5,13 @@ <% if pairwise_content.in_group? %>
<%= pairwise_content.parent.title %>
- <%= pairwise_content.parent.body %> + <%= pairwise_content.parent.body.html_safe %>
-
<%= pairwise_content.title %>
+
<%= pairwise_content.title.html_safe %>
<% else %> -
<%= pairwise_content.title %>
+
<%= pairwise_content.title.html_safe %>
<% end %> -
<%= pairwise_content.body %>
+
<%= pairwise_content.body.html_safe %>
<%= render :partial => 'content_viewer/pairwise_prompts', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => question, :source => (defined?(source) ? source : '') } %> <% if embeded %> diff --git a/views/content_viewer/_result.html.erb b/views/content_viewer/_result.html.erb index 9ddc770..c9b541c 100644 --- a/views/content_viewer/_result.html.erb +++ b/views/content_viewer/_result.html.erb @@ -36,7 +36,7 @@ <% @page.question.get_choices.each do |choice| %> - <%= choice.data %> + <%= choice.data.html_safe %> <%= choice.wins %> <%= choice.losses %> <%= choice.score.round.to_s %> diff --git a/views/pairwise_plugin_suggestions/index.html.erb b/views/pairwise_plugin_suggestions/index.html.erb index e17c523..3eaeae1 100644 --- a/views/pairwise_plugin_suggestions/index.html.erb +++ b/views/pairwise_plugin_suggestions/index.html.erb @@ -135,7 +135,7 @@ <% @choices.each do |choice| %> - <%= choice.data %> + <%= choice.data.html_safe %> <%= show_date choice.created_at %> <%= choice.user_created ? choice.creator_identifier : profile.identifier %> -- libgit2 0.21.2