From d88000f06a2178710d20c23c81c0bfa5605fb4a9 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Mon, 18 Dec 2017 07:51:38 -0500 Subject: [PATCH] Added a stats page for teams --- .../.schools_controller.rb.swp} | Bin 12288 -> 12288 bytes app/controllers/schools_controller.rb | 8 +++-- app/views/schools/show.html.erb | 26 +++++++------- app/views/schools/stats.html.erb | 34 ++++++++++++++++++ config/routes.rb | 9 ++--- 5 files changed, 58 insertions(+), 19 deletions(-) rename app/{views/wrestlers/.show.html.erb.swp => controllers/.schools_controller.rb.swp} (70%) create mode 100644 app/views/schools/stats.html.erb diff --git a/app/views/wrestlers/.show.html.erb.swp b/app/controllers/.schools_controller.rb.swp similarity index 70% rename from app/views/wrestlers/.show.html.erb.swp rename to app/controllers/.schools_controller.rb.swp index 49cd3467ac2acacdca802df4cf32414cfd026000..cd088789f6f0c16d2e45d1e3b250f69b887aa69b 100644 GIT binary patch literal 12288 zcmeI2O^6&t6vu0WA6Yd<6cs_CvI}NI#-3yoNNBQ>7#9_zE@Y#aWf^+9Yqs0;bWN(N zci1EvL@xosyP(mF2*!)xLA;6aq^JkQi+AxNLZV(`{8v|h&Ccv@0y!9|fge3n{rc6b z|9e%{%T{~Wi_bhq_c?nBKKBsv@#p)F|FvsBnSPWIp9d?td83cE3)u2TX5=+(*c7bC zWwS4sRB@Cn;lb+1pA?cYN7 zOz+;MTPG*B(fjT_Rx_|)tpZj7tAJI&Dqt0`3RnfK0#s})zu!T~58x|s9=r(_!5H{? z96rH$a0EO7T(B4H0gr%9;L>J7z5`!?_kjSCax7!H$ z5WEN81!sW|roa|(@mA;t&Ve4-2`0c5rg*r{)v|7`%KDKz+$%KDRwP>6i-Fs zby=cJXJxPG`CxUE&d~YN(&Kv zXzsuf>|_dyDc1~Shtp%C8>uN*C#*ry%!R&I{a|=TdEM2p?346)w#)=oB9+SY!W534 z(T?Cvg?e$!``PV&7%4{M2v4g}@N_A3R>z*F3I%gCJJ06y zL#D?N1$5@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9LACIMU@Q z?6BMB6X+(UL35cSJ0t{` zoXw11LfptqFiIb9BsxL z8>iFJy{nk12$zD1nr}JGU&}OO;s&5Ica}~&%w<)M)FSN?gO(&pcxIr;26?pTE3?RC XqXR)U9g7O>O2FXD3{N~^0)+exx|MRU diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 41ade29..40a6ca1 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -1,9 +1,13 @@ class SchoolsController < ApplicationController - before_action :set_school, only: [:show, :edit, :update, :destroy] + before_action :set_school, only: [:show, :edit, :update, :destroy, :stats] before_action :check_access_director, only: [:new,:create,:destroy] before_action :check_access_delegate, only: [:update,:edit] + def stats + @tournament = @school.tournament + end + # GET /schools/1 # GET /schools/1.json def show @@ -89,7 +93,7 @@ class SchoolsController < ApplicationController end authorize! :manage, @tournament end - + def check_access_delegate authorize! :manage, @school end diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb index dacc026..23118fc 100644 --- a/app/views/schools/show.html.erb +++ b/app/views/schools/show.html.erb @@ -1,16 +1,16 @@ - - <%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}",:class=>"btn btn-default" %> + + <%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}",:class=>"btn btn-default" %> <% if can? :manage, @school %> | <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %> <% end %> - + | <%= link_to "#{@school.name} Stat Summary", "/schools/#{@school.id}/stats",:class=>"btn btn-primary" %>

Name: <%= @school.name %>

- +

Team Points Deducted: <%= @school.totalDeductedPoints %> @@ -19,23 +19,23 @@ Score: <%= @school.score %>

- +

Tournament: <%= @school.tournament.name %>

- - - - - + + + + +
<% if can? :manage, @school %> <%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%> <% end %>

- + @@ -48,7 +48,7 @@ - + <% @wrestlers.sort_by{|w| w.weight.max}.each do |wrestler| %> @@ -67,7 +67,7 @@ <% if can? :manage, wrestler.school %> <%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary btn-sm" %> <%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %> - <% end %> + <% end %> <% end %> diff --git a/app/views/schools/stats.html.erb b/app/views/schools/stats.html.erb new file mode 100644 index 0000000..1faac46 --- /dev/null +++ b/app/views/schools/stats.html.erb @@ -0,0 +1,34 @@ +<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %> +<% cache ["#{@school.id}_Stats", @school] do %> +
+
+

<%= @school.name %> Stats Summary

+
+

Matches

+
+
Actions
+ + + + + + + + + + + <% @school.wrestlers.each do |wrestler| %> + <% wrestler.allMatches.each do |m| %> + + + + + + <% end %> + <% end %> + +
WresterBoutMatch Bracket PositionStatsResult
<%= wrestler.name %> + <%= m.bout_number %><%= m.bracket_position %><%= m.list_w1_stats %>
<%= m.list_w2_stats %>
<%= wrestler.resultByBout(m.bout_number) %> +
+<% end %> + diff --git a/config/routes.rb b/config/routes.rb index c13e345..0153345 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,7 @@ Wrestling::Application.routes.draw do resources :matches devise_for :users - + resources :tournaments resources :schools @@ -50,17 +50,18 @@ Wrestling::Application.routes.draw do delete 'tournaments/:id/:teampointadjust/remove_teampointadjust' => 'tournaments#remove_teampointadjust' get 'tournaments/:id/error' => 'tournaments#error' post "/tournaments/:id/swap" => "tournaments#swap", :as => :swap_wrestlers - + post 'weights/:id/re_gen' => 'weights#re_gen', :as => :regen_weight post "/wrestlers/update_pool" => "wrestlers#update_pool" - + + get "schools/:id/stats" => "schools#stats" #API get "/api/tournaments" => "api#tournaments" get "/api/tournaments/user" => "api#currentUserTournaments" get "/api/tournaments/:tournament" => "api#tournament" get "/api/index" => "api#index" post "/api/tournaments/new" => "newTournament" - + # Example of regular route: # get 'products/:id' => 'catalog#view'