Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add show question

  • Loading branch information...
commit 6474b1798b3f3d0afd3e1e838af9ef2fd9272f08 1 parent f40374e
Jeff Reifman authored
27 app/controllers/prediction_groups_controller.rb
View
@@ -14,30 +14,9 @@ def show
@prediction_group = PredictionGroup.find(params[:id])
tag_cloud @prediction_group
@current_sub_tab = 'Predict'
+ @previous_prediction_group = @prediction_group.previous
+ @next_prediction_group = @prediction_group.next
end
-
- def self.next
- if PredictionGroup.count > 0
- @prediction_group = PredictionGroup.find(:first, :conditions => ["id > ?", params[:id] ], :order => "id asc")
- if @prediction_group.nil?
- @prediction_group = PredictionGroup.first
- end
- prediction_group_path(@prediction_group)
- else
- prediction_groups_index_path
- end
- end
-
- def self.previous
- if PredictionGroup.count > 0
- @prediction_group = PredictionGroup.find(:first, :conditions => ["id > ?", params[:id] ], :order => "id desc")
- if @prediction_group.nil?
- flash[:success] = t('predictions.that_was_first_prediction')
- @prediction_group = PredictionGroup.last
- end
- redirect_to prediction_group_path(@prediction_group)
- else
- redirect_to prediction_groups_index_path
- end end
+
end
9 app/controllers/prediction_questions_controller.rb
View
@@ -1,12 +1,3 @@
class PredictionQuestionsController < ApplicationController
- def show
- #todo - change question link
- #todo - handle question with no group
- @prediction_question = PredictionQuestion.find(params[:id])
- redirect_to prediction_group_path(@prediction_question.prediction_group)
- end
-
-
-
end
32 app/controllers/predictions_controller.rb
View
@@ -12,32 +12,6 @@ def index
@current_sub_tab = 'Predict'
end
- def next_prediction_group
- if PredictionGroup.count > 0
- @prediction_group = PredictionGroup.find(:first, :conditions => ["id > ?", params[:id] ], :order => "id asc")
- if @prediction_group.nil?
- flash[:success] = t('predictions.last_prediction')
- @prediction_group = PredictionGroup.first
- end
- redirect_to prediction_group_path(@prediction_group)
- else
- redirect_to prediction_groups_index_path
- end
- end
-
- def previous_prediction_group
- if PredictionGroup.count > 0
- @prediction_group = PredictionGroup.find(:first, :conditions => ["id > ?", params[:id] ], :order => "id desc")
- if @prediction_group.nil?
- flash[:success] = t('predictions.that_was_first_prediction')
- @prediction_group = PredictionGroup.last
- end
- redirect_to prediction_group_path(@prediction_group)
- else
- redirect_to prediction_groups_index_path
- end
- end
-
def scores
@current_sub_tab = 'Scores'
@page = params[:page].present? ? (params[:page].to_i < 3 ? "page_#{params[:page]}_" : "") : "page_1_"
@@ -54,6 +28,12 @@ def new
def create
end
+ def show_question
+ #todo - change question link
+ #todo - handle question with no group
+ @prediction_question = PredictionQuestion.find(params[:id])
+ end
+
def my_predictions
@paginate = true
@current_sub_tab = 'Yours'
16 app/models/prediction_group.rb
View
@@ -25,4 +25,20 @@ def to_s
"Prediction Group: #{title}"
end
+ def next
+ if PredictionGroup.count > 0
+ PredictionGroup.find(:first, :conditions => ["id > ?", self.id ], :order => "id asc")
+ else
+ nil
+ end
+ end
+
+ def previous
+ if PredictionGroup.count > 0
+ PredictionGroup.find(:first, :conditions => ["id < ?", self.id ], :order => "id desc")
+ else
+ nil
+ end
+ end
+
end
4 app/models/prediction_question.rb
View
@@ -20,8 +20,4 @@ class PredictionQuestion < ActiveRecord::Base
named_scope :newest, lambda { |*args| { :order => ["created_at desc"], :limit => (args.first || 10)} }
named_scope :top, lambda { |*args| { :order => ["guesses_count desc, created_at desc"], :limit => (args.first || 10)} }
- def url
- home_index_path
- end
-
end
10 app/views/prediction_groups/show.html.haml
View
@@ -38,11 +38,13 @@
%li
.generic.small
.itemBlock
- %h4= render :partial => 'shared/prediction_questions', :locals => { :question => question }
+ %h4= render :partial => 'shared/prediction_question', :locals => { :question => question }
%br
- %p
- = link_to t('predictions.next_topic'), next_prediction_group_predictions_path(@prediction_group), :class => "btn float_right"
- = link_to t('predictions.previous_topic'), previous_prediction_group_predictions_path(@prediction_group), :class => "btn"
+ %p
+ - unless @next_prediction_group.nil?
+ = link_to t('predictions.next_topic'), prediction_group_path(@next_prediction_group), :class => "btn float_right"
+ - unless @previous_prediction_group.nil?
+ = link_to t('predictions.previous_topic'), prediction_group_path(@previous_prediction_group), :class => "btn float_right", :class => "btn"
%br
%br
= render :partial => 'shared/comments', :locals => { :comments => @prediction_group.comments }
34 app/views/predictions/show_question.html.haml
View
@@ -0,0 +1,34 @@
+- content_for :sub_nav do
+ = render_ad(:leaderboard, @ad_layout, @ad_leaderboard)
+ = render :partial => 'shared/subnav/predictions_subnav'
+
+#col_left
+ - cache "#{@prediction_question.cache_key}_top_html" do
+ #itemDetails.panel_1
+ .topBar
+ %ul
+ %li
+ %a== #{like_link @prediction_question} #{@prediction_question.votes_tally}
+ %li= fb_share_item_button(@prediction_question)
+ %li
+ = twitter_share_item_link @prediction_question, @prediction_question.title
+ %ul
+ -# todo - did user answer already?
+ %li
+ .generic.small
+ .itemBlock
+ %h4= render :partial => 'shared/prediction_question', :locals => { :question => @prediction_question }
+ %p= t('predictions.member_of_group', :prediction_group => link_to(@prediction_question.prediction_group.title, @prediction_question.prediction_group))
+ = render_ad(:banner, @ad_layout, @ad_banner)
+ %br
+ %br
+ = render :partial => 'shared/item_footer', :locals => { :item => @prediction_question,:title => @prediction_question.title }
+
+#col_right
+ = render_ad(:small_square, @ad_layout, @ad_small_square)
+ = render :partial => 'shared/sidebar/predictions_high_scores', :locals => { :top_scorers => nil }
+ = render :partial => 'shared/sidebar/newest_prediction_groups', :locals => { :prediction_groups => @newest_prediction_groups }
+ = render :partial => 'shared/sidebar/newest_prediction_questions', :locals => { :prediction_questions => @newest_prediction_questions }
+ = render :partial => 'shared/sidebar/top_prediction_groups', :locals => { :prediction_groups => @top_prediction_groups }
+ = render :partial => 'shared/sidebar/top_prediction_questions', :locals => { :prediction_questions => @top_prediction_questions }
+ = render_ad(:skyscraper, @ad_layout, @ad_skyscraper)
0  app/views/shared/_prediction_questions.html.haml → app/views/shared/_prediction_question.html.haml
View
File renamed without changes
3  config/locales/en.yml
View
@@ -225,4 +225,5 @@ en:
new_question: "Add a Question"
newest_groups: "Newest Topics"
top_groups: "Top Topics"
- my_list_title: "Your Predictions"
+ my_list_title: "Your Predictions"
+ member_of_group: "Part of {{prediction_group}}"
4 config/routes.rb
View
@@ -81,9 +81,9 @@
map.resources :topics, :has_many => [:comments]
map.resource :session
map.resources :home, :collection => { :index => [:get, :post], :app_tab => [:get, :post], :google_ads => [:get],:helios_ads => [:get],:helios_alt2_ads => [:get],:helios_alt3_ads => [:get],:helios_alt4_ads => [:get], :about => :get, :faq => :get, :terms => :get, :contact_us => [:get, :post] }, :member => { :render_widget => [:get, :post] }
- map.resources :predictions, :collection => { :index => [:get, :post], :next_prediction_group => [:get],:previous_prediction_group => [:get], :my_predictions => [:get, :post], :scores => [:get, :post] }
+ map.resources :predictions, :collection => { :index => [:get, :post], :my_predictions => [:get, :post], :scores => [:get, :post] }
map.resources :prediction_groups, :member => { :like => [:get, :post] } , :collection => { :index => [:get, :post] }, :has_many => [:comments, :prediction_questions, :flags]
- map.resources :prediction_questions, :collection => { :show => [:get, :post] }, :has_many => [:prediction_guesses]
+ map.prediction_question '/prediction_question/:id.:format', :controller => 'predictions', :action => 'show_question'
map.root :controller => "home", :action => "index"
map.admin 'admin', :controller => :admin, :action => :index
Please sign in to comment.
Something went wrong with that request. Please try again.