diff options
-rw-r--r-- | app/controllers/tournaments_controller.rb | 5 | ||||
-rw-r--r-- | app/views/tournaments/index.html.erb | 35 |
2 files changed, 26 insertions, 14 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index d2a2d18..7352e8d 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -21,9 +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 = 0 - @tournament.save + @tournament = Tournament.new(game: Game.find_by_id(params[:game])) end # GET /tournaments/1/edit @@ -40,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/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> |