From 1c818c090c68b540cf048efe64c2d6a3d321e9b6 Mon Sep 17 00:00:00 2001 From: Daniel Reiter Date: Fri, 15 Jun 2012 13:06:09 -0500 Subject: [PATCH 1/6] added unfinished solution message --- app/views/questions/show.html.erb | 5 +++++ app/views/solutions/_single_solution.html.erb | 3 +++ 2 files changed, 8 insertions(+) diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 105eb87..b0e116b 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -17,6 +17,11 @@
<% if @question.errors.none? %> + <% @question.solution.each do |solution| %> + <% if solution.is_visible == false && present_user == solution.creator %> +
This question has unfinished solutions
+ <% break %> + <% end %> <%= render :partial => "show", :locals => {:question => @question} %> <% else %> diff --git a/app/views/solutions/_single_solution.html.erb b/app/views/solutions/_single_solution.html.erb index 524f298..665420a 100644 --- a/app/views/solutions/_single_solution.html.erb +++ b/app/views/solutions/_single_solution.html.erb @@ -78,6 +78,9 @@
<% if !solution.explanation.blank? %> + <% if !solution.is_visible %> +
This solution is not ready to be viewed.
+ <% end %>
High-Level Explanation
<%= simple_format solution.explanation %> From c9f61eefccd905ea44715367c33009f584a72600 Mon Sep 17 00:00:00 2001 From: Daniel Reiter Date: Fri, 15 Jun 2012 13:11:25 -0500 Subject: [PATCH 2/6] added a missing end --- app/views/questions/show.html.erb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index b0e116b..9a8f790 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -17,10 +17,11 @@
<% if @question.errors.none? %> - <% @question.solution.each do |solution| %> - <% if solution.is_visible == false && present_user == solution.creator %> -
This question has unfinished solutions
- <% break %> + <% @question.solutions.each do |solution| %> + <% if solution.is_visible == false && present_user == solution.creator %> +
This question has unfinished solutions
+ <% break %> + <% end %> <% end %> <%= render :partial => "show", :locals => {:question => @question} %> From ea7e0a46d8074b31935ba940b3ff1a16e0fdb8b1 Mon Sep 17 00:00:00 2001 From: Daniel Reiter Date: Mon, 9 Jul 2012 10:12:42 -0500 Subject: [PATCH 3/6] fixed some code indentation --- app/views/questions/show.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 9a8f790..4a6bdfa 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -18,11 +18,11 @@ <% if @question.errors.none? %> <% @question.solutions.each do |solution| %> - <% if solution.is_visible == false && present_user == solution.creator %> -
This question has unfinished solutions
- <% break %> + <% if solution.is_visible == false && present_user == solution.creator %> +
This question has unfinished solutions
+ <% break %> + <% end %> <% end %> - <% end %> <%= render :partial => "show", :locals => {:question => @question} %> <% else %> From 8afd09a56dd3768691b140a47755ab4d1abb2c0e Mon Sep 17 00:00:00 2001 From: Daniel Reiter Date: Tue, 17 Jul 2012 14:22:27 -0500 Subject: [PATCH 4/6] removed loop --- app/controllers/questions_controller.rb | 1 + app/views/questions/show.html.erb | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 4cea99d..a8b2215 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -22,6 +22,7 @@ def index def show @question = Question.from_param(params[:id]) + @unfinished_solutions = !@question.solutions.where{(is_visible == false) & (creator_id == my{present_user})}.first.nil? raise SecurityTransgression unless present_user.can_read?(@question) start_time = Time.now if logger.info? diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 4a6bdfa..d68e385 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -17,11 +17,8 @@
<% if @question.errors.none? %> - <% @question.solutions.each do |solution| %> - <% if solution.is_visible == false && present_user == solution.creator %> -
This question has unfinished solutions
- <% break %> - <% end %> + <% if @unfinished_solutions %> +
This question has unfinished solutions
<% end %> <%= render :partial => "show", :locals => {:question => @question} %> From 169a8276e7cf967cf734a76bf2d2e61613c287cd Mon Sep 17 00:00:00 2001 From: Daniel Reiter Date: Tue, 17 Jul 2012 15:27:39 -0500 Subject: [PATCH 5/6] fixed user not logged in id problem --- app/controllers/questions_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index a8b2215..8695101 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -22,7 +22,8 @@ def index def show @question = Question.from_param(params[:id]) - @unfinished_solutions = !@question.solutions.where{(is_visible == false) & (creator_id == my{present_user})}.first.nil? + #debugger + @unfinished_solutions = !@question.solutions.where{(is_visible == false) & (creator_id == my{present_user.id})}.first.nil? raise SecurityTransgression unless present_user.can_read?(@question) start_time = Time.now if logger.info? From 3edd5b536ee191c29110b3c9f31401018fffa274 Mon Sep 17 00:00:00 2001 From: Daniel Reiter Date: Tue, 17 Jul 2012 15:46:00 -0500 Subject: [PATCH 6/6] removed debugger line --- app/controllers/questions_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 8695101..1d10e20 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -22,7 +22,6 @@ def index def show @question = Question.from_param(params[:id]) - #debugger @unfinished_solutions = !@question.solutions.where{(is_visible == false) & (creator_id == my{present_user.id})}.first.nil? raise SecurityTransgression unless present_user.can_read?(@question)