From 07b51103bf31226f2c02d5c586f5dae2150f4012 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Tue, 8 Jan 2019 16:03:33 +0000 Subject: [PATCH] Create bout sheets and make all printable pages go to a new window --- app/controllers/tournaments_controller.rb | 13 ++- app/views/layouts/_lsidebar.html.erb | 8 +- app/views/layouts/application.html.erb | 1 + app/views/tournaments/bout_sheets.html.erb | 111 +++++++++++++++++++++ app/views/tournaments/brackets.html.erb | 2 +- app/views/tournaments/weigh_in.html.erb | 2 +- config/routes.rb | 1 + 7 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 app/views/tournaments/bout_sheets.html.erb diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 422b09d..8d18bac 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -1,5 +1,5 @@ class TournamentsController < ApplicationController - before_action :set_tournament, only: [:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets] + before_action :set_tournament, only: [:bout_sheets,:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets] before_action :check_access_manage, only: [:swap,:weigh_in_sheet,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches] before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate] before_action :check_tournament_errors, only: [:generate_matches] @@ -186,6 +186,17 @@ class TournamentsController < ApplicationController @mats = @tournament.mats.includes(:matches) end + def bout_sheets + if params[:round] + round = params[:round] + if round != "All" + @matches = @tournament.matches.where("round = ?",round).sort_by{|match| match.bout_number} + else + @matches = @tournament.matches.sort_by{|match| match.bout_number} + end + end + end + def index if params[:search] @tournaments = Tournament.search(params[:search]).order("created_at DESC") diff --git a/app/views/layouts/_lsidebar.html.erb b/app/views/layouts/_lsidebar.html.erb index 4c04823..2ae9f1b 100644 --- a/app/views/layouts/_lsidebar.html.erb +++ b/app/views/layouts/_lsidebar.html.erb @@ -20,7 +20,13 @@
Pages

<%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %>
<%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %> -
<%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" %> +
<%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" , target: :_blank %> +
Bout Sheets:
<%= link_to "Deduct Team Points" , "/tournaments/#{@tournament.id}/teampointadjust" %> <% if can? :destroy, @tournament %>
<%= link_to "Tournament Delegation" , "/tournaments/#{@tournament.id}/delegate" %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5a99d53..a0300ea 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,6 +2,7 @@ <% if params[:print] %> + <%= csrf_meta_tags %> WrestlingDev <%= render 'layouts/cdn' %> <%= render 'layouts/shim' %> diff --git a/app/views/tournaments/bout_sheets.html.erb b/app/views/tournaments/bout_sheets.html.erb new file mode 100644 index 0000000..df50098 --- /dev/null +++ b/app/views/tournaments/bout_sheets.html.erb @@ -0,0 +1,111 @@ + +<% @matches.each do |match| %> +<% if match.w1 && match.w2 %> + <% w1 = Wrestler.find(match.w1) %> + <% w2 = Wrestler.find(match.w2) %> +<% end %> + +

Bout Number: <%= match.bout_number %>

+

Weight Class: <%= match.weight.max %>

+

Round: <%= match.round %>

+

Key: Takedown: T2, Escape: E1, Reversal: R2, Nearfall: N2 or N3, Stalling: S, Caution: C, Penalty Point: P1

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Circle Winner +

<%= match.w1_name %>

+

<%= if w1 then w1.school.name end %>

+
+

<%= match.w2_name %>

+

<%= if w2 then w2.school.name end %>

+
red / green (circle one)red / green (circle one)
Period 1

















Choicetop / bottom / neutral / defer (circle one)top / bottom / neutral / defer (circle one)
Period 2

















Choicetop / bottom / neutral / defer (circle one)top / bottom / neutral / defer (circle one)
Period 3

















Overtime 1

Choicetop / bottom / neutral / defer (circle one)top / bottom / neutral / defer (circle one)
Overtime 2



Choicetop / bottom / neutral / defer (circle one)top / bottom / neutral / defer (circle one)
Overtime 3



Choicetop / bottom / neutral / defer (circle one)top / bottom / neutral / defer (circle one)
Overtime 4



Final Score (or pin time, default, disqualified, etc)



+<% end %> \ No newline at end of file diff --git a/app/views/tournaments/brackets.html.erb b/app/views/tournaments/brackets.html.erb index 7e1c47d..03cdbfb 100644 --- a/app/views/tournaments/brackets.html.erb +++ b/app/views/tournaments/brackets.html.erb @@ -6,5 +6,5 @@
<% end %> <% if can? :manage, @tournament %> - <%= link_to "All Brackets (Printable)", "/tournaments/#{@tournament.id}/all_brackets?print=true" %> + <%= link_to "All Brackets (Printable)", "/tournaments/#{@tournament.id}/all_brackets?print=true", target: :_blank %> <% end %> diff --git a/app/views/tournaments/weigh_in.html.erb b/app/views/tournaments/weigh_in.html.erb index ee7dc73..e6705ef 100644 --- a/app/views/tournaments/weigh_in.html.erb +++ b/app/views/tournaments/weigh_in.html.erb @@ -18,6 +18,6 @@ <% end %>

- <%= link_to "Printable Weigh In Sheet" , "/tournaments/#{@tournament.id}/weigh_in_sheet?print=true" %> + <%= link_to "Printable Weigh In Sheet" , "/tournaments/#{@tournament.id}/weigh_in_sheet?print=true", target: :_blank %> diff --git a/config/routes.rb b/config/routes.rb index 1f8748b..be8b91d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,6 +37,7 @@ Wrestling::Application.routes.draw do get 'tournaments/:id/generate_matches' => 'tournaments#generate_matches' get 'tournaments/:id/team_scores' => 'tournaments#team_scores' get 'tournaments/:id/up_matches' => 'tournaments#up_matches', :as => :up_matches + get 'tournaments/:id/bout_sheets' => 'tournaments#bout_sheets' get 'tournaments/:id/no_matches' => 'tournaments#no_matches' get 'tournaments/:id/matches' => 'tournaments#matches' get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate