From da284d090e74d790bd80a8e4ed0400eb073e36b6 Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Fri, 7 Mar 2014 17:54:11 -0500 Subject: tournaments table is better --- app/controllers/tournaments_controller.rb | 4 ++-- app/models/user.rb | 2 +- app/views/tournaments/index.html.erb | 35 +++++++++++++++++++++---------- 3 files changed, 27 insertions(+), 14 deletions(-) (limited to 'app') 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 @@ Game Status - Min players per team - Max players per team - Min teams per match - Max teams per match - Set rounds + Players per team + Teams per match Randomized teams @@ -22,12 +19,28 @@ <% @tournaments.each do |tournament| %> <%= tournament.id %> - <%= tournament.status %> - <%= tournament.min_players_per_team %> - <%= tournament.max_players_per_team %> - <%= tournament.min_teams_per_match %> - <%= tournament.max_teams_per_match %> - <%= tournament.set_rounds %> + <% case tournament.status + when 0 %> + <%= form_tag(tournament_path(tournament), method: "put") do %> + + <%= submit_tag("Join") %> + <% end %> + <% when 1 %> + Ongoing + <% else %> + Closed + <%end %> + + <%= tournament.min_players_per_team %> + <% if tournament.min_players_per_team != tournament.max_players_per_team %> + to <%= tournament.max_players_per_team %> + <% end %> + + <%= tournament.min_teams_per_match %> + <% if tournament.min_teams_per_match != tournament.max_teams_per_match %> + to <%= tournament.max_teams_per_match %> + <% end %> + <%= tournament.randomized_teams %> <%= link_to 'Show', tournament %> <%= link_to 'Edit', edit_tournament_path(tournament) %> -- cgit v1.2.3-2-g168b