summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authortkimia <tkimia@purdue.edu>2014-04-03 18:03:25 -0400
committertkimia <tkimia@purdue.edu>2014-04-03 18:03:25 -0400
commiteffe4608e808a385bb912fccac26381d0bd0c95a (patch)
tree68f45ec586be9a80c4d3cd74938db65c0d73a9f1 /app
parent0c1583c0b31504dfdbbbec3e6dcc240acb059891 (diff)
matches table is back, and a lot of things are fixed
Diffstat (limited to 'app')
-rw-r--r--app/controllers/tournaments_controller.rb9
-rw-r--r--app/models/tournament.rb6
-rw-r--r--app/views/matches/index.html.erb18
3 files changed, 14 insertions, 19 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 4bba997..ae384c1 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -76,7 +76,7 @@ class TournamentsController < ApplicationController
when "join"
respond_to do |format|
if @tournament.join(current_user)
- format.html { render action: 'show', notice: 'You have joined this tournament.' }
+ format.html { redirect_to @tournament, notice: 'You have joined this tournament.' }
format.json { head :no_content }
end
format.html { render action: 'permission_denied', status: :forbidden }
@@ -85,7 +85,7 @@ class TournamentsController < ApplicationController
when "leave"
respond_to do |format|
if @tournament.leave(current_user)
- format.html {redirect_to tournaments_url, notice: 'You have left the tournament.' }
+ format.html { redirect_to tournaments_url, notice: 'You have left the tournament.' }
format.json { head :no_content }
end
format.html {redirect_to @tournament, notice: 'You were\'t a part of this tournament.' }
@@ -94,10 +94,9 @@ class TournamentsController < ApplicationController
when "start"
@tournament.status = 1
@tournament.save
- @tournament.setup()
respond_to do |format|
if @tournament.setup
- format.html { render action: 'show', notice: 'You have joined this tournament.' }
+ format.html { redirect_to @tournament, notice: 'You have joined this tournament.' }
format.json { head :no_content }
end
format.html { render action: 'permission_denied', status: :forbidden }
@@ -105,7 +104,7 @@ class TournamentsController < ApplicationController
end
else
respond_to do |format|
- format.html { render action: 'show', notice: "Invalid action", status: :unprocessable_entity }
+ format.html { redirect_to @tournament, notice: "Invalid action", status: :unprocessable_entity }
format.json { render json: @tournament.errors, status: :unprocessable_entity }
end
end
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 6d92f3d..f1d533d 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -26,14 +26,14 @@ class Tournament < ActiveRecord::Base
end
def setup()
- num_teams = (self.players.count/self.max_players_per_team).floor
+ num_teams = (self.players.count/self.min_players_per_team).floor
num_matches = num_teams - 1
for i in 1..num_matches
- self.matches.create(name: "Match #{i}")
+ self.matches.create(name: "Match #{i}", status: 0)
end
match_num = 0
team_num = 0
- self.players.each_slice(max_players_per_team) do |players|
+ self.players.each_slice(min_players_per_team) do |players|
self.matches[match_num].teams.push(Team.create(users: players))
if (team_num != 0 and team_num % max_teams_per_match == 0)
match_num += 1
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index babf45e..d4ddb0e 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -1,28 +1,23 @@
-<h1><%= @tournament.name %> Matches</h1>
+<h1><%= @tournament.name %> - Matches</h1>
-<table>
+<table class="table">
<thead>
<tr>
<th>Status</th>
- <th>Tournament</th>
<th>Name</th>
<th>Winner</th>
- <th>Remote</th>
- <th></th>
- <th></th>
<th></th>
</tr>
</thead>
- <tbody>
+ <tbody class="table-hover">
<% @tournament.matches.each do |match| %>
<tr>
- <td><%= match.tournament.id %></td>
<td><%= match.status %></td>
- <td><%= match.tournament %></td>
+ <td><%= match.id%></td>
<td><%= match.name %></td>
- <td><%= match.winner %></td>
+ <td><%= link_to "Show", tournament_match_path(@tournament, match) %>
</tr>
<% end %>
</tbody>
@@ -37,7 +32,8 @@
xmlns="http://www.w3.org/2000/svg">
<% (1..@matches.count).each do |i| %>
- <g class="svg-match" >
+ <g class="svg-match">
+ <rect rx="10"
</g>
<% end %>