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 49cd346..cd08878 100644 Binary files a/app/views/wrestlers/.show.html.erb.swp and b/app/controllers/.schools_controller.rb.swp differ 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'