From 393326f24f1fb1a8a60e4272cd9837d7aa9c1330 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 19 Nov 2015 13:46:58 +0000 Subject: [PATCH] Showing next bout number and mat on school show page --- app/models/match.rb | 8 ++++++++ app/models/wrestler.rb | 24 ++++++++++++++++++++++++ app/views/schools/show.html.erb | 2 ++ 3 files changed, 34 insertions(+) diff --git a/app/models/match.rb b/app/models/match.rb index 6e00039..203fe39 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -20,6 +20,14 @@ class Match < ActiveRecord::Base end end + def mat_assigned + if self.mat + "Mat #{self.mat.name}" + else + "" + end + end + def advance_wrestlers if self.w1? && self.w2? @w1 = wrestler1 diff --git a/app/models/wrestler.rb b/app/models/wrestler.rb index 8188f93..cc4c602 100644 --- a/app/models/wrestler.rb +++ b/app/models/wrestler.rb @@ -34,6 +34,30 @@ class Wrestler < ActiveRecord::Base end points end + + def nextMatch + unfinishedMatches.first + end + + def nextMatchBoutNumber + if nextMatch + nextMatch.bout_number + else + "" + end + end + + def nextMatchMatName + if nextMatch + nextMatch.mat_assigned + else + "" + end + end + + def unfinishedMatches + allMatches.select{|m| m.finished != 1}.sort_by{|m| m.bout_number} + end def resultByBout(bout) @match = allMatches.select{|m| m.bout_number == bout and m.finished == 1} diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb index 6adc1da..8e75732 100644 --- a/app/views/schools/show.html.erb +++ b/app/views/schools/show.html.erb @@ -41,6 +41,7 @@ Seed Criteria Team Points Scored Extra? + Next Bout/Mat Actions @@ -60,6 +61,7 @@ <% if wrestler.extra? == true %> Yes <% end %> + <%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %> <%= link_to 'Show', wrestler , :class=>"btn btn-default" %> <% if tournament_permissions(@school.tournament) %>