summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authortkimia <tkimia@purdue.edu>2014-04-29 16:41:35 -0400
committertkimia <tkimia@purdue.edu>2014-04-29 16:41:35 -0400
commit42d6e3b1cc05ef5172081682b53675e4827254d3 (patch)
tree240743892a6f0948774f1b89bf5bf58ed49f6416 /app
parent0d6f7a3bfbf4c87510a1bcf967b618f98e149d49 (diff)
elimination works SOMETIMES... other times it just can't put down a damned winner
Diffstat (limited to 'app')
-rw-r--r--app/controllers/matches_controller.rb2
-rw-r--r--app/models/match.rb9
-rw-r--r--app/models/statistic.rb2
-rw-r--r--app/views/brackets/show.html.erb1
-rw-r--r--app/views/matches/index.html.erb9
5 files changed, 16 insertions, 7 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index dbd3e68..f24b95d 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -39,7 +39,7 @@ class MatchesController < ApplicationController
end
when 2
# Started, waiting to finish
- @match.handle_sampling(@current_user, params)
+ @match.handle_sampling(current_user, params)
# The @match.status will be updated by Statistic's after_save hook
if @match.status == 3
notice = 'Match has finished'
diff --git a/app/models/match.rb b/app/models/match.rb
index 7b36777..65e2047 100644
--- a/app/models/match.rb
+++ b/app/models/match.rb
@@ -20,7 +20,9 @@ class Match < ActiveRecord::Base
def finished?
ok = true
tournament_stage.scoring.stats_needed.each do |stat|
- ok &= !statistics.where(match: self, name: stat).nil?
+ self.users.each do |user|
+ ok &= statistics.where(match: self, user: user, name: stat)
+ end
end
ok
end
@@ -46,6 +48,11 @@ class Match < ActiveRecord::Base
# Delagates PUT/PATCH HTTP params to the appropriate sampling
# methods.
def handle_sampling(user, params)
+ require 'pp'
+ puts('>'*80)
+ pp user
+ pp params
+ puts('<'*80)
method_classes.each do |klass|
klass.new(self).handle_user_interaction(user, params)
end
diff --git a/app/models/statistic.rb b/app/models/statistic.rb
index d62d413..8abf1f4 100644
--- a/app/models/statistic.rb
+++ b/app/models/statistic.rb
@@ -23,8 +23,8 @@ class Statistic < ActiveRecord::Base
self.match.winner = self.match.teams.find{|t| t.users.include? self.user}
end
if (self.match.status == 2) and (self.match.finished?)
- #self.match.tournament_stage.scoring.score(self.match)
self.match.status = 3
+ self.match.tournament_stage.scheduling.finish_match(self.match)
end
self.match.save!
end
diff --git a/app/views/brackets/show.html.erb b/app/views/brackets/show.html.erb
index 96eb0ec..1eabcaf 100644
--- a/app/views/brackets/show.html.erb
+++ b/app/views/brackets/show.html.erb
@@ -103,4 +103,5 @@
<% end %>
<%= submit_tag("Submit Prediction", disabled: true, id: "bracket-submit") %>
<% end %>
+
<%= link_to 'Back', tournaments_path %>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 784d7db..e0e69b5 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -18,12 +18,13 @@
<td><%= "Match #{match.id}" %></td>
<td><%= match.status %></td>
<td><%= (match.winner.nil? ? "-" : "Team #{match.winner.id}") %></td>
- <td><%= link_to "Show", tournament_match_path(@tournament, match) %>
- <td> <%# If user is the host, let them start the tournment %>
- <% if @tournament.hosts.include?(current_user) %>
+ <td><%= link_to "See Match", tournament_match_path(@tournament, match) %>
+ <td>
+ <%# NOTE: - fix this permission, if split up by match, this does not work %>
+ <% if @tournament.check_permission(current_user, :edit) %>
<%= form_tag(tournament_match_path(@tournament, match), method: "put") do %>
<input type="hidden" name="update_action" value="start">
- <% @startable = (match.status == 0) and (match.teams.count >= @tournament.min_teams_per_match) %>
+ <% @startable = (match.status == 1) and (match.teams.count >= @tournament.min_teams_per_match) %>
<%= submit_tag("Start Match", :disabled => ! @startable) %>
<% end %>
<% end %>