summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomer Kimia <tkimia@purdue.edu>2014-03-07 17:54:11 -0500
committerTomer Kimia <tkimia@purdue.edu>2014-03-07 17:54:11 -0500
commitda284d090e74d790bd80a8e4ed0400eb073e36b6 (patch)
tree21d058fa92ed008f30234f6813dc1d386799e293
parent7e7a0a4a0465142612acd1e0d050cb1b91f93d90 (diff)
tournaments table is better
-rw-r--r--app/controllers/tournaments_controller.rb4
-rw-r--r--app/models/user.rb2
-rw-r--r--app/views/tournaments/index.html.erb35
3 files changed, 27 insertions, 14 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 0807953..7352e8d 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -21,8 +21,7 @@ class TournamentsController < ApplicationController
# GET /tournaments/new
def new
@games = Game.all
- @tournament = Tournament.new(game: Game.find_by_id(params[:game]))
- @tournament.status = 1
+ @tournament = Tournament.new(game: Game.find_by_id(params[:game]))
end
# GET /tournaments/1/edit
@@ -39,6 +38,7 @@ class TournamentsController < ApplicationController
# POST /tournaments.json
def create
@tournament = Tournament.new(tournament_params)
+ @tournament.status = 0
respond_to do |format|
if @tournament.save
@tournament.hosts.push(current_user)
diff --git a/app/models/user.rb b/app/models/user.rb
index 70e7f25..6e439fb 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -19,7 +19,7 @@ class User < ActiveRecord::Base
when :admin
return ((groups & 2) != 0)
when :host
- return ((groups & 1) != 0)
+ return true #((groups & 1) != 0)
when :player
return true
when :specator
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
index d4ef414..7fb4a1d 100644
--- a/app/views/tournaments/index.html.erb
+++ b/app/views/tournaments/index.html.erb
@@ -6,11 +6,8 @@
<tr>
<th>Game</th>
<th>Status</th>
- <th>Min players per team</th>
- <th>Max players per team</th>
- <th>Min teams per match</th>
- <th>Max teams per match</th>
- <th>Set rounds</th>
+ <th>Players per team</th>
+ <th>Teams per match</th>
<th>Randomized teams</th>
<th></th>
<th></th>
@@ -22,12 +19,28 @@
<% @tournaments.each do |tournament| %>
<tr>
<td><%= tournament.id %></td>
- <td><%= tournament.status %></td>
- <td><%= tournament.min_players_per_team %></td>
- <td><%= tournament.max_players_per_team %></td>
- <td><%= tournament.min_teams_per_match %></td>
- <td><%= tournament.max_teams_per_match %></td>
- <td><%= tournament.set_rounds %></td>
+ <td><% case tournament.status
+ when 0 %>
+ <%= form_tag(tournament_path(tournament), method: "put") do %>
+ <input type="hidden" name="update_action" value="join">
+ <%= submit_tag("Join") %>
+ <% end %>
+ <% when 1 %>
+ Ongoing
+ <% else %>
+ Closed
+ <%end %>
+ </td>
+ <td><%= tournament.min_players_per_team %>
+ <% if tournament.min_players_per_team != tournament.max_players_per_team %>
+ to <%= tournament.max_players_per_team %>
+ <% end %>
+ </td>
+ <td><%= tournament.min_teams_per_match %>
+ <% if tournament.min_teams_per_match != tournament.max_teams_per_match %>
+ to <%= tournament.max_teams_per_match %>
+ <% end %>
+ </td>
<td><%= tournament.randomized_teams %></td>
<td><%= link_to 'Show', tournament %></td>
<td><%= link_to 'Edit', edit_tournament_path(tournament) %></td>