1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added a stats page for teams

This commit is contained in:
2017-12-18 07:51:38 -05:00
parent 7831bfaf6b
commit d88000f06a
5 changed files with 58 additions and 19 deletions

View File

@@ -1,9 +1,13 @@
class SchoolsController < ApplicationController 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_director, only: [:new,:create,:destroy]
before_action :check_access_delegate, only: [:update,:edit] before_action :check_access_delegate, only: [:update,:edit]
def stats
@tournament = @school.tournament
end
# GET /schools/1 # GET /schools/1
# GET /schools/1.json # GET /schools/1.json
def show def show
@@ -89,7 +93,7 @@ class SchoolsController < ApplicationController
end end
authorize! :manage, @tournament authorize! :manage, @tournament
end end
def check_access_delegate def check_access_delegate
authorize! :manage, @school authorize! :manage, @school
end end

View File

@@ -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 %> <% if can? :manage, @school %>
| <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %> | <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %>
<% end %> <% end %>
| <%= link_to "#{@school.name} Stat Summary", "/schools/#{@school.id}/stats",:class=>"btn btn-primary" %>
<br> <br>
<br> <br>
<p> <p>
<strong>Name:</strong> <strong>Name:</strong>
<%= @school.name %> <%= @school.name %>
</p> </p>
<p> <p>
<strong>Team Points Deducted:</strong> <strong>Team Points Deducted:</strong>
<%= @school.totalDeductedPoints %> <%= @school.totalDeductedPoints %>
@@ -19,23 +19,23 @@
<strong>Score:</strong> <strong>Score:</strong>
<%= @school.score %> <%= @school.score %>
</p> </p>
<p> <p>
<strong>Tournament:</strong> <strong>Tournament:</strong>
<%= @school.tournament.name %> <%= @school.tournament.name %>
</p> </p>
<br> <br>
<% if can? :manage, @school %> <% if can? :manage, @school %>
<%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%> <%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%>
<% end %> <% end %>
<br> <br>
<br> <br>
<table class="table table-striped table-bordered table-condensed"> <table class="table table-striped table-bordered table-condensed">
<thead> <thead>
<tr> <tr>
@@ -48,7 +48,7 @@
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @wrestlers.sort_by{|w| w.weight.max}.each do |wrestler| %> <% @wrestlers.sort_by{|w| w.weight.max}.each do |wrestler| %>
<tr> <tr>
@@ -67,7 +67,7 @@
<% if can? :manage, wrestler.school %> <% if can? :manage, wrestler.school %>
<%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary btn-sm" %> <%= 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" %> <%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %>
<% end %> <% end %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -0,0 +1,34 @@
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
<% cache ["#{@school.id}_Stats", @school] do %>
<br>
<br>
<h2><%= @school.name %> Stats Summary</h2>
<br>
<h4>Matches</h4>
<br>
<table class="table">
<thead>
<tr>
<th>Wrester</th>
<th>Bout</th>
<th>Match Bracket Position</th>
<th>Stats</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<% @school.wrestlers.each do |wrestler| %>
<% wrestler.allMatches.each do |m| %>
<tr>
<td> <%= wrestler.name %>
<td><%= m.bout_number %></td>
<td><%= m.bracket_position %></td>
<td><%= m.list_w1_stats %><br><%= m.list_w2_stats %></td>
<td><%= wrestler.resultByBout(m.bout_number) %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -4,7 +4,7 @@ Wrestling::Application.routes.draw do
resources :matches resources :matches
devise_for :users devise_for :users
resources :tournaments resources :tournaments
resources :schools resources :schools
@@ -50,17 +50,18 @@ Wrestling::Application.routes.draw do
delete 'tournaments/:id/:teampointadjust/remove_teampointadjust' => 'tournaments#remove_teampointadjust' delete 'tournaments/:id/:teampointadjust/remove_teampointadjust' => 'tournaments#remove_teampointadjust'
get 'tournaments/:id/error' => 'tournaments#error' get 'tournaments/:id/error' => 'tournaments#error'
post "/tournaments/:id/swap" => "tournaments#swap", :as => :swap_wrestlers post "/tournaments/:id/swap" => "tournaments#swap", :as => :swap_wrestlers
post 'weights/:id/re_gen' => 'weights#re_gen', :as => :regen_weight post 'weights/:id/re_gen' => 'weights#re_gen', :as => :regen_weight
post "/wrestlers/update_pool" => "wrestlers#update_pool" post "/wrestlers/update_pool" => "wrestlers#update_pool"
get "schools/:id/stats" => "schools#stats"
#API #API
get "/api/tournaments" => "api#tournaments" get "/api/tournaments" => "api#tournaments"
get "/api/tournaments/user" => "api#currentUserTournaments" get "/api/tournaments/user" => "api#currentUserTournaments"
get "/api/tournaments/:tournament" => "api#tournament" get "/api/tournaments/:tournament" => "api#tournament"
get "/api/index" => "api#index" get "/api/index" => "api#index"
post "/api/tournaments/new" => "newTournament" post "/api/tournaments/new" => "newTournament"
# Example of regular route: # Example of regular route:
# get 'products/:id' => 'catalog#view' # get 'products/:id' => 'catalog#view'