From cd19b2591a52ac604632a70929448ee5e78c2568 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 28 Apr 2014 18:29:01 -0400 Subject: Misc fixes. (This commit is from Luke on Andrew's box) --- app/controllers/matches_controller.rb | 16 ++++------------ app/models/match.rb | 7 ++----- 2 files changed, 6 insertions(+), 17 deletions(-) (limited to 'app') diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index bed06ba..5745ac9 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -45,18 +45,10 @@ class MatchesController < ApplicationController when 2 # Started, waiting to finish @match.handle_sampling(params) - if @match.finished? - @match.status = 3 - respond_to do |format| - if @match.save - format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match has finished.' } - format.json { head :no_content } - else - format.html { render action: 'show' } - format.json { render json: @match.errors, status: :unprocessable_entity } - end - end - return + # The @match.status will be updated by Statistic's after_save hook + respond_to do |format| + format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match has finished.' } + format.json { head :no_content } end when 3 if (@tournament.hosts.include? current_user) and (params[:update_action] == "start") diff --git a/app/models/match.rb b/app/models/match.rb index 4c7acbf..219e662 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -5,9 +5,6 @@ class Match < ActiveRecord::Base belongs_to :winner, class_name: "Team" - def setup() - end - def finished? ok = true tournament_stage.scoring_method.stats_needed.each do |stat| @@ -59,7 +56,7 @@ class Match < ActiveRecord::Base method_class = "Sampling::#{method_name.camelcase}".constantize needed.each do |stat| data[stat] ||= {} - data[stat][method] = method_class.can_get?(user, stat) + data[stat][method_class] = method_class.can_get?(stat) end end @@ -83,7 +80,7 @@ class Match < ActiveRecord::Base if @method_classes.nil? data = Set.new figure_sampling_methods.each do |stat,method| - data.push(method) + data.add(method) end @method_classes = data end -- cgit v1.2.3