mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-24 17:04:43 +00:00
Added a stats page for teams
This commit is contained in:
Binary file not shown.
@@ -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
|
||||
|
||||
@@ -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" %>
|
||||
<br>
|
||||
<br>
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @school.name %>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<strong>Team Points Deducted:</strong>
|
||||
<%= @school.totalDeductedPoints %>
|
||||
@@ -19,23 +19,23 @@
|
||||
<strong>Score:</strong>
|
||||
<%= @school.score %>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<strong>Tournament:</strong>
|
||||
<%= @school.tournament.name %>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<% if can? :manage, @school %>
|
||||
<%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
||||
<table class="table table-striped table-bordered table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -48,7 +48,7 @@
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
<% @wrestlers.sort_by{|w| w.weight.max}.each do |wrestler| %>
|
||||
<tr>
|
||||
@@ -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 %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
34
app/views/schools/stats.html.erb
Normal file
34
app/views/schools/stats.html.erb
Normal 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 %>
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user