From 0ba25da89a19f3ebf7b91677487b04278ddc88d5 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 18 Nov 2015 13:11:47 +0000 Subject: [PATCH] Updating views --- app/controllers/tournaments_controller.rb | 2 +- app/models/school.rb | 11 ++++++++++- app/views/mats/_match_edit_form.html.erb | 7 +++++-- app/views/tournaments/team_scores.html.erb | 2 +- app/views/wrestlers/show.html.erb | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index a9ead2f..f5afb58 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -60,7 +60,7 @@ class TournamentsController < ApplicationController def team_scores @schools = @tournament.schools - @schools.sort_by{|s| s.score}.reverse! + @schools = @schools.sort_by{|s| s.pageScore}.reverse! end diff --git a/app/models/school.rb b/app/models/school.rb index aa6a325..4cfa93b 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -5,9 +5,18 @@ class School < ActiveRecord::Base #calculate score here + def pageScore + if self.score == nil + return 0.0 + else + return self.score + end + end def calcScore - totalWrestlerPoints - totalDeductedPoints + newScore = totalWrestlerPoints - totalDeductedPoints + self.score = newScore + self.save end def totalWrestlerPoints diff --git a/app/views/mats/_match_edit_form.html.erb b/app/views/mats/_match_edit_form.html.erb index 014f5cc..82ad91f 100644 --- a/app/views/mats/_match_edit_form.html.erb +++ b/app/views/mats/_match_edit_form.html.erb @@ -17,14 +17,17 @@ <%= f.label "Win Type" %>
<%= f.select(:win_type, Match::WIN_TYPES) %> +
- <%= f.label "Winner" %> Please put in the id of the winner
+ <%= f.label "Winner" %> Please choose the winner
<%= f.collection_select :winner_id, @wrestlers, :id, :name %>
+
- <%= f.label "Score" %> Also put pin time here if applicable. If default or forfeit, leave blank
+ <%= f.label "Score" %> Also put pin time here if applicable. If default or forfeit, leave blank. Example: 7-2, 17-2, or 2:34
<%= f.text_field :score %>
+
<%= f.hidden_field :finished, :value => 1 %> <%= f.hidden_field :round, :value => @match.round %> diff --git a/app/views/tournaments/team_scores.html.erb b/app/views/tournaments/team_scores.html.erb index 34d4d4a..0bee520 100644 --- a/app/views/tournaments/team_scores.html.erb +++ b/app/views/tournaments/team_scores.html.erb @@ -15,7 +15,7 @@ <% @schools.each do |school| %> <%= school.name %> - <%= school.score %> + <%= school.pageScore %> <% end %> diff --git a/app/views/wrestlers/show.html.erb b/app/views/wrestlers/show.html.erb index 66c0e93..e658175 100644 --- a/app/views/wrestlers/show.html.erb +++ b/app/views/wrestlers/show.html.erb @@ -29,7 +29,7 @@
<% @wrestler.allMatches.each do |m| %> -
Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= m.bracketScore %>
+
Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %>
<% end %> <% @wrestler.deductedPoints.each do |w| %>
Deducted points: <%= w.points %>