From 68fe5e4f9012f684e19ec97282f13e8b1e60db2d Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 4 Dec 2015 19:50:32 +0000 Subject: [PATCH] Updated views for wrestlers show page --- app/controllers/tournaments_controller.rb | 6 +----- app/controllers/wrestlers_controller.rb | 1 + app/models/tournament.rb | 6 +++++- app/views/tournaments/results.html.erb | 5 ----- app/views/wrestlers/show.html.erb | 10 ++++++---- config/routes.rb | 1 - 6 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 app/views/tournaments/results.html.erb diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 1dd858a..0e15f7f 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: [:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:results,:all_brackets] + before_action :set_tournament, only: [: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_filter :check_access, only: [:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:destroy,:generate_matches] before_filter :check_for_matches, only: [:up_matches,:bracket] @@ -36,10 +36,6 @@ class TournamentsController < ApplicationController end - def results - @matches = @tournament.matches - end - def bracket if params[:weight] @weight = Weight.where(:id => params[:weight]).includes(:matches,:wrestlers).first diff --git a/app/controllers/wrestlers_controller.rb b/app/controllers/wrestlers_controller.rb index 61d867b..f3f6273 100644 --- a/app/controllers/wrestlers_controller.rb +++ b/app/controllers/wrestlers_controller.rb @@ -7,6 +7,7 @@ class WrestlersController < ApplicationController # GET /wrestlers/1.json def show @school = @wrestler.school + @tournament = @wrestler.tournament end # GET /wrestlers/new diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 09c6dd7..5249631 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -13,7 +13,7 @@ class Tournament < ActiveRecord::Base ["Pool to bracket"] end - def createCustomWeights(value) + def createCustomWeights(value) weights.destroy_all if value == 'hs' Weight::HS_WEIGHT_CLASSES.each do |w| @@ -48,4 +48,8 @@ class Tournament < ActiveRecord::Base end end end + + def totalRounds + self.matches.sort_by{|m| m.bout_number}.last.round + end end diff --git a/app/views/tournaments/results.html.erb b/app/views/tournaments/results.html.erb deleted file mode 100644 index 6f4b178..0000000 --- a/app/views/tournaments/results.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %> -
-
-

Results

-

Will be displayed here.

diff --git a/app/views/wrestlers/show.html.erb b/app/views/wrestlers/show.html.erb index e658175..7908fd8 100644 --- a/app/views/wrestlers/show.html.erb +++ b/app/views/wrestlers/show.html.erb @@ -1,10 +1,11 @@

<%= notice %>

-<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}" %> | +<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %> <% if tournament_permissions(@wrestler.tournament) %> - <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler) %> | + | <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %> <% end %> - +
+

Name: <%= @wrestler.name %> @@ -27,7 +28,8 @@

- +

Matches

+
<% @wrestler.allMatches.each do |m| %>
Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %>
<% end %> diff --git a/config/routes.rb b/config/routes.rb index ff09bb4..00838c5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,7 +32,6 @@ Wrestling::Application.routes.draw do get 'tournaments/:id/weigh_in' => 'tournaments#weigh_in' get 'tournaments/:id/create_custom_weights' => 'tournaments#create_custom_weights' get 'tournaments/:id/all_brackets' => 'tournaments#all_brackets' - get 'tournaments/:id/results' => 'tournaments#results' get 'tournaments/:id/brackets' => 'tournaments#brackets' get 'tournaments/:id/brackets/:weight' => 'tournaments#bracket' get 'tournaments/:id/generate_matches' => 'tournaments#generate_matches'