From d0277e1ab8ffa3740932edce58ba809e83f6ec36 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Mon, 30 Mar 2015 19:11:47 +0000 Subject: [PATCH] Preliminary bracket print page --- app/controllers/static_pages_controller.rb | 6 ++++ app/views/layouts/application.html.erb | 33 ++++++++++++------- app/views/static_pages/all_brackets.html.erb | 34 ++++++++++++++++++++ app/views/static_pages/weights.html.erb | 3 +- config/routes.rb | 1 + 5 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 app/views/static_pages/all_brackets.html.erb diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index fe35a08..121c1fc 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -41,6 +41,12 @@ class StaticPagesController < ApplicationController @wrestlers = Wrestler.where(weight_id: @weight.id) end end + + def all_brackets + if params[:tournament] + @tournament = Tournament.find(params[:tournament]) + end + end def weights if params[:tournament] diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c9e090f..5a78f13 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,20 +1,29 @@ + <% if params[:print] %> Wrestling App - <%= stylesheet_link_tag "application", media: "all", - "data-turbolinks-track" => true %> - <%= javascript_include_tag "application", "data-turbolinks-track" => true %> - <%= csrf_meta_tags %> - <%= render 'layouts/shim' %> - <%= render 'layouts/header' %> -
- - <%= yield %> - <%= render 'layouts/footer' %> - <%= debug(params) if Rails.env.development? %> -
+ <%= yield %> + <% else %> + + Wrestling App + <%= stylesheet_link_tag "application", media: "all", + "data-turbolinks-track" => true %> + <%= javascript_include_tag "application", "data-turbolinks-track" => true %> + <%= csrf_meta_tags %> + <%= render 'layouts/shim' %> + + + <%= render 'layouts/header' %> +
+ + <%= yield %> + <%= render 'layouts/footer' %> + <%= debug(params) if Rails.env.development? %> +
+ + <% end %> \ No newline at end of file diff --git a/app/views/static_pages/all_brackets.html.erb b/app/views/static_pages/all_brackets.html.erb new file mode 100644 index 0000000..8d50da0 --- /dev/null +++ b/app/views/static_pages/all_brackets.html.erb @@ -0,0 +1,34 @@ + + + +<%= link_to "Back to #{@tournament.name} weights", "/static_pages/weights?tournament=#{@tournament.id}" %> +
+
+<% @tournament.weights.sort_by{|w| w.max}.each do |w| %> +
+ <% @weight = w %> + <% @matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id} %> + <% @wrestlers = Wrestler.where(weight_id: @weight.id) %> +
<%= @weight.max %> lbs Bracket
+ + <%= render 'pool' %> +
+
+ <% if w.pool_bracket_type == "twoPoolsToFinal" %> + <%= render 'twoPoolFinalBracket' %> + <% end %> + <% if w.pool_bracket_type == "twoPoolsToSemi" %> + <%= render 'twoPoolSemiBracket' %> + <% end %> + <% if w.pool_bracket_type == "fourPoolsToQuarter" %> + <%= render 'fourPoolQuarterBracket' %> + <% end %> + <% if w.pool_bracket_type == "fourPoolsToSemi" %> + <%= render 'fourPoolSemiBracket' %> + <% end %> +
+<% end %> \ No newline at end of file diff --git a/app/views/static_pages/weights.html.erb b/app/views/static_pages/weights.html.erb index b9f56d6..9648158 100644 --- a/app/views/static_pages/weights.html.erb +++ b/app/views/static_pages/weights.html.erb @@ -4,4 +4,5 @@ <% @weights.each do |weight| %> <%= link_to "#{weight.max}" , "/static_pages/brackets?weight=#{weight.id}" %>
-<% end %> \ No newline at end of file +<% end %> +<%= link_to "All Brackets", "/static_pages/all_brackets?print=true&tournament=#{@tournament.id}" %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 74d7ad3..0ffd4ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,6 +22,7 @@ Wrestling::Application.routes.draw do # You can have the root of your site routed with "root" root 'static_pages#index' get 'static_pages/brackets' + get 'static_pages/all_brackets' get 'static_pages/weights' get 'admin/index' get 'static_pages/up_matches'