1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-14 08:58:29 +00:00

Added pages for teampointsadjust and spearated wrestler and school deducted points

This commit is contained in:
2016-01-12 17:36:45 +00:00
parent 227e588658
commit c6626988db
9 changed files with 148 additions and 7 deletions

View File

@@ -1,7 +1,28 @@
class Teampointadjust < ActiveRecord::Base
belongs_to :wrestler
belongs_to :school
after_save do
self.wrestler.lastFinishedMatch.advance_wrestlers
after_save do
advance_wrestlers_and_calc_team_score
end
after_destroy do
advance_wrestlers_and_calc_team_score
end
def advance_wrestlers_and_calc_team_score
#Team score needs calculated
if self.wrestler_id != nil
#In case this affects pool order
if self.wrestler.lastFinishedMatch
self.wrestler.lastFinishedMatch.advance_wrestlers
end
self.wrestler.school.calcScore
elsif self.school_id != nil
self.school.calcScore
end
end
if Rails.env.production?
handle_asynchronously :advance_wrestlers_and_calc_team_score
end
end