diff options
42 files changed, 62 insertions, 130 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 6fc3ad6..27765df 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -106,6 +106,6 @@ class TournamentsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def tournament_params - params.require(:tournament).permit(:game, :game_id, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :status) + params.require(:tournament).permit(:game, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams) end end diff --git a/app/models/team_match_pair.rb b/app/models/team_match_pair.rb deleted file mode 100644 index 85f8eaa..0000000 --- a/app/models/team_match_pair.rb +++ /dev/null @@ -1,4 +0,0 @@ -class TeamMatchPair < ActiveRecord::Base - belongs_to :team - belongs_to :match -end diff --git a/app/models/tournament_user_pair.rb b/app/models/tournament_user_pair.rb deleted file mode 100644 index eb4e9c5..0000000 --- a/app/models/tournament_user_pair.rb +++ /dev/null @@ -1,4 +0,0 @@ -class TournamentUserPair < ActiveRecord::Base - belongs_to :tournament - belongs_to :user -end diff --git a/app/models/user_team_pair.rb b/app/models/user_team_pair.rb deleted file mode 100644 index c55dc2e..0000000 --- a/app/models/user_team_pair.rb +++ /dev/null @@ -1,4 +0,0 @@ -class UserTeamPair < ActiveRecord::Base - belongs_to :user - belongs_to :team -end diff --git a/app/models/user_tournament_pair.rb b/app/models/user_tournament_pair.rb deleted file mode 100644 index b2676e5..0000000 --- a/app/models/user_tournament_pair.rb +++ /dev/null @@ -1,4 +0,0 @@ -class UserTournamentPair < ActiveRecord::Base - belongs_to :user - belongs_to :tournament -end diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index c2c0ba7..d098cbb 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -16,6 +16,10 @@ <%= f.text_field :game_id %> </div> <div class="field"> + <%= f.label :status %><br> + <%= f.number_field :status %> + </div> + <div class="field"> <%= f.label :min_players_per_team %><br> <%= f.number_field :min_players_per_team %> </div> @@ -39,10 +43,6 @@ <%= f.label :randomized_teams %><br> <%= f.check_box :randomized_teams %> </div> - <div class="field"> - <%= f.label :status %><br> - <%= f.number_field :status %> - </div> <div class="actions"> <%= f.submit %> </div> diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index 80d68a3..452d939 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -5,13 +5,13 @@ <thead> <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>Randomized teams</th> - <th>Status</th> <th></th> <th></th> <th></th> @@ -22,13 +22,13 @@ <% @tournaments.each do |tournament| %> <tr> <td><%= tournament.game %></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><%= tournament.randomized_teams %></td> - <td><%= tournament.status %></td> <td><%= link_to 'Show', tournament %></td> <td><%= link_to 'Edit', edit_tournament_path(tournament) %></td> <td><%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' } %></td> diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder index df8eee4..e95c6a7 100644 --- a/app/views/tournaments/index.json.jbuilder +++ b/app/views/tournaments/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@tournaments) do |tournament| - json.extract! tournament, :id, :game_id, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :status + json.extract! tournament, :id, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams json.url tournament_url(tournament, format: :json) end diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 91c1961..0cda6c1 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -11,6 +11,11 @@ </p> <p> + <strong>Status:</strong> + <%= @tournament.status %> +</p> + +<p> <strong>Min players per team:</strong> <%= @tournament.min_players_per_team %> </p> @@ -40,10 +45,5 @@ <%= @tournament.randomized_teams %> </p> -<p> - <strong>Status:</strong> - <%= @tournament.status %> -</p> - <%= link_to 'Edit', edit_tournament_path(@tournament) %> | <%= link_to 'Back', tournaments_path %> diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder index 7bedd4b..de2fbe0 100644 --- a/app/views/tournaments/show.json.jbuilder +++ b/app/views/tournaments/show.json.jbuilder @@ -1 +1 @@ -json.extract! @tournament, :id, :game_id, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :status, :created_at, :updated_at +json.extract! @tournament, :id, :game_id, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :created_at, :updated_at diff --git a/config/routes.rb b/config/routes.rb index 6e11f31..178b7ad 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,14 @@ Leaguer::Application.routes.draw do resources :games + resources :tournaments + + resources :pms + + resources :alerts + + resources :teams + resources :matches resources :tournaments diff --git a/db/migrate/20140307004031_create_user_team_pairs.rb b/db/migrate/20140307004031_create_user_team_pairs.rb deleted file mode 100644 index 2c492ac..0000000 --- a/db/migrate/20140307004031_create_user_team_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateUserTeamPairs < ActiveRecord::Migration - def change - create_table :user_team_pairs do |t| - t.references :user, index: true - t.references :team, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140307004036_create_user_tournament_pairs.rb b/db/migrate/20140307004036_create_user_tournament_pairs.rb deleted file mode 100644 index 9885b20..0000000 --- a/db/migrate/20140307004036_create_user_tournament_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateUserTournamentPairs < ActiveRecord::Migration - def change - create_table :user_tournament_pairs do |t| - t.references :user, index: true - t.references :tournament, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140307004041_create_team_match_pairs.rb b/db/migrate/20140307004041_create_team_match_pairs.rb deleted file mode 100644 index 8fac07e..0000000 --- a/db/migrate/20140307004041_create_team_match_pairs.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateTeamMatchPairs < ActiveRecord::Migration - def change - create_table :team_match_pairs do |t| - t.references :team, index: true - t.references :match, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140307003926_create_servers.rb b/db/migrate/20140307022637_create_servers.rb index f33241a..f33241a 100644 --- a/db/migrate/20140307003926_create_servers.rb +++ b/db/migrate/20140307022637_create_servers.rb diff --git a/db/migrate/20140307003931_create_matches.rb b/db/migrate/20140307022643_create_matches.rb index 325863d..325863d 100644 --- a/db/migrate/20140307003931_create_matches.rb +++ b/db/migrate/20140307022643_create_matches.rb diff --git a/db/migrate/20140307003703_create_teams.rb b/db/migrate/20140307022648_create_teams.rb index fdf9a68..fdf9a68 100644 --- a/db/migrate/20140307003703_create_teams.rb +++ b/db/migrate/20140307022648_create_teams.rb diff --git a/db/migrate/20140307003709_create_alerts.rb b/db/migrate/20140307022653_create_alerts.rb index 68a8e10..68a8e10 100644 --- a/db/migrate/20140307003709_create_alerts.rb +++ b/db/migrate/20140307022653_create_alerts.rb diff --git a/db/migrate/20140307003714_create_pms.rb b/db/migrate/20140307022658_create_pms.rb index 93bb5c6..93bb5c6 100644 --- a/db/migrate/20140307003714_create_pms.rb +++ b/db/migrate/20140307022658_create_pms.rb diff --git a/db/migrate/20140307003719_create_tournaments.rb b/db/migrate/20140307022704_create_tournaments.rb index 545e603..545e603 100644 --- a/db/migrate/20140307003719_create_tournaments.rb +++ b/db/migrate/20140307022704_create_tournaments.rb diff --git a/db/migrate/20140307003956_create_games.rb b/db/migrate/20140307022709_create_games.rb index 5e4f56f..5e4f56f 100644 --- a/db/migrate/20140307003956_create_games.rb +++ b/db/migrate/20140307022709_create_games.rb diff --git a/db/migrate/20140307004001_create_users.rb b/db/migrate/20140307022714_create_users.rb index 8032870..8032870 100644 --- a/db/migrate/20140307004001_create_users.rb +++ b/db/migrate/20140307022714_create_users.rb diff --git a/db/migrate/20140307004006_create_sessions.rb b/db/migrate/20140307022719_create_sessions.rb index fe25bf2..fe25bf2 100644 --- a/db/migrate/20140307004006_create_sessions.rb +++ b/db/migrate/20140307022719_create_sessions.rb diff --git a/db/migrate/20140307004011_create_server_settings.rb b/db/migrate/20140307022725_create_server_settings.rb index dfdd91b..dfdd91b 100644 --- a/db/migrate/20140307004011_create_server_settings.rb +++ b/db/migrate/20140307022725_create_server_settings.rb diff --git a/db/migrate/20140307004016_create_tournament_options.rb b/db/migrate/20140307022729_create_tournament_options.rb index 53b601c..53b601c 100644 --- a/db/migrate/20140307004016_create_tournament_options.rb +++ b/db/migrate/20140307022729_create_tournament_options.rb diff --git a/db/migrate/20140307004021_create_game_options.rb b/db/migrate/20140307022734_create_game_options.rb index 2f62ef7..2f62ef7 100644 --- a/db/migrate/20140307004021_create_game_options.rb +++ b/db/migrate/20140307022734_create_game_options.rb diff --git a/db/migrate/20140307004027_create_scores.rb b/db/migrate/20140307022740_create_scores.rb index 4ca0b0b..4ca0b0b 100644 --- a/db/migrate/20140307004027_create_scores.rb +++ b/db/migrate/20140307022740_create_scores.rb diff --git a/db/migrate/20140307022745_create_tournament_players_join_table.rb b/db/migrate/20140307022745_create_tournament_players_join_table.rb new file mode 100644 index 0000000..9ff8a7a --- /dev/null +++ b/db/migrate/20140307022745_create_tournament_players_join_table.rb @@ -0,0 +1,8 @@ +class CreateTournamentPlayersJoinTable < ActiveRecord::Migration + def change + create_join_table :users, :tournaments do |t| + # t.index [:user_id, :tournament_id] + # t.index [:tournament_id, :user_id] + end + end +end diff --git a/db/migrate/20140307022749_create_tournament_hosts_join_table.rb b/db/migrate/20140307022749_create_tournament_hosts_join_table.rb new file mode 100644 index 0000000..0eff550 --- /dev/null +++ b/db/migrate/20140307022749_create_tournament_hosts_join_table.rb @@ -0,0 +1,8 @@ +class CreateTournamentHostsJoinTable < ActiveRecord::Migration + def change + create_join_table :users, :tournaments do |t| + # t.index [:user_id, :tournament_id] + # t.index [:tournament_id, :user_id] + end + end +end diff --git a/db/migrate/20140307022754_create_user_team_join_table.rb b/db/migrate/20140307022754_create_user_team_join_table.rb new file mode 100644 index 0000000..7b4d17f --- /dev/null +++ b/db/migrate/20140307022754_create_user_team_join_table.rb @@ -0,0 +1,8 @@ +class CreateUserTeamJoinTable < ActiveRecord::Migration + def change + create_join_table :users, :matches do |t| + # t.index [:user_id, :match_id] + # t.index [:match_id, :user_id] + end + end +end diff --git a/db/migrate/20140307022759_create_match_team_join_table.rb b/db/migrate/20140307022759_create_match_team_join_table.rb new file mode 100644 index 0000000..c2ed1b7 --- /dev/null +++ b/db/migrate/20140307022759_create_match_team_join_table.rb @@ -0,0 +1,8 @@ +class CreateMatchTeamJoinTable < ActiveRecord::Migration + def change + create_join_table :matches, :teams do |t| + # t.index [:match_id, :team_id] + # t.index [:team_id, :match_id] + end + end +end diff --git a/db/migrate/20140307004100_add_hidden_attrs_to_user.rb b/db/migrate/20140307022818_add_hidden_attrs_to_user.rb index 2f1b0b2..2f1b0b2 100644 --- a/db/migrate/20140307004100_add_hidden_attrs_to_user.rb +++ b/db/migrate/20140307022818_add_hidden_attrs_to_user.rb diff --git a/generate.sh b/generate.sh index db9e84b..22c6f4a 100755 --- a/generate.sh +++ b/generate.sh @@ -39,10 +39,12 @@ bundle exec rails generate model server_settings $NOTEST bundle exec rails generate model tournament_option tournament:references vartype:integer name:string value:text $NOTEST bundle exec rails generate model game_option vartype:integer name:string default:text $NOTEST bundle exec rails generate model score user:references match:references value:integer $NOTEST -# Bridge Models -bundle exec rails generate model user_team_pair user:references team:references $NOTEST -bundle exec rails generate model user_tournament_pair user:references tournament:references -bundle exec rails generate model team_match_pair team:references match:references $NOTEST + +# Join tables +bundle exec rails generate migration CreateTournamentPlayersJoinTable users tournaments +bundle exec rails generate migration CreateTournamentHostsJoinTable users tournaments +bundle exec rails generate migration CreateUserTeamJoinTable users matches +bundle exec rails generate migration CreateMatchTeamJoinTable matches teams # Just controllers bundle exec rails generate controller search $NOTEST diff --git a/test/fixtures/team_match_pairs.yml b/test/fixtures/team_match_pairs.yml deleted file mode 100644 index 5f9cf2f..0000000 --- a/test/fixtures/team_match_pairs.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - team_id: - match_id: - -two: - team_id: - match_id: diff --git a/test/fixtures/tournament_user_pairs.yml b/test/fixtures/tournament_user_pairs.yml deleted file mode 100644 index dbc4a88..0000000 --- a/test/fixtures/tournament_user_pairs.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - tournament_id: - user_id: - -two: - tournament_id: - user_id: diff --git a/test/fixtures/tournaments.yml b/test/fixtures/tournaments.yml index c58a1ed..27c92f9 100644 --- a/test/fixtures/tournaments.yml +++ b/test/fixtures/tournaments.yml @@ -2,20 +2,20 @@ one: game_id: + status: 1 min_players_per_team: 1 max_players_per_team: 1 min_teams_per_match: 1 max_teams_per_match: 1 set_rounds: 1 randomized_teams: false - status: 1 two: game_id: + status: 1 min_players_per_team: 1 max_players_per_team: 1 min_teams_per_match: 1 max_teams_per_match: 1 set_rounds: 1 randomized_teams: false - status: 1 diff --git a/test/fixtures/user_team_pairs.yml b/test/fixtures/user_team_pairs.yml deleted file mode 100644 index a76036f..0000000 --- a/test/fixtures/user_team_pairs.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - user_id: - team_id: - -two: - user_id: - team_id: diff --git a/test/fixtures/user_tournament_pairs.yml b/test/fixtures/user_tournament_pairs.yml deleted file mode 100644 index 974ee71..0000000 --- a/test/fixtures/user_tournament_pairs.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - user_id: - tournament_id: - -two: - user_id: - tournament_id: diff --git a/test/models/team_match_pair_test.rb b/test/models/team_match_pair_test.rb deleted file mode 100644 index c250b3c..0000000 --- a/test/models/team_match_pair_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class TeamMatchPairTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/tournament_user_pair_test.rb b/test/models/tournament_user_pair_test.rb deleted file mode 100644 index c8d1789..0000000 --- a/test/models/tournament_user_pair_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class TournamentUserPairTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/user_team_pair_test.rb b/test/models/user_team_pair_test.rb deleted file mode 100644 index 55f5c58..0000000 --- a/test/models/user_team_pair_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class UserTeamPairTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/user_tournament_pair_test.rb b/test/models/user_tournament_pair_test.rb deleted file mode 100644 index 6167ff6..0000000 --- a/test/models/user_tournament_pair_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class UserTournamentPairTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end |