diff options
Diffstat (limited to 'app')
24 files changed, 151 insertions, 30 deletions
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 4ecff17..5780152 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -69,6 +69,6 @@ class GamesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def game_params - params.require(:game).permit(:name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams) + params.require(:game).permit(:name, :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/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index f14c97f..ccd6781 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -69,6 +69,6 @@ class TeamsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def team_params - params[:team] + params.require(:team).permit(:match_id) end end diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 1d17205..cf618aa 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -81,6 +81,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_id, :game) + 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) end end diff --git a/app/models/game_attribute.rb b/app/models/game_attribute.rb deleted file mode 100644 index c12723b..0000000 --- a/app/models/game_attribute.rb +++ /dev/null @@ -1,3 +0,0 @@ -class GameAttribute < ActiveRecord::Base - belongs_to :game -end diff --git a/app/models/game_option.rb b/app/models/game_option.rb new file mode 100644 index 0000000..bdc5560 --- /dev/null +++ b/app/models/game_option.rb @@ -0,0 +1,2 @@ +class GameOption < ActiveRecord::Base +end diff --git a/app/models/score.rb b/app/models/score.rb new file mode 100644 index 0000000..a9b9c71 --- /dev/null +++ b/app/models/score.rb @@ -0,0 +1,4 @@ +class Score < ActiveRecord::Base + belongs_to :user + belongs_to :match +end diff --git a/app/models/team.rb b/app/models/team.rb index fa7ba9e..9e71557 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -1,2 +1,3 @@ class Team < ActiveRecord::Base + belongs_to :match end diff --git a/app/models/tournament_option.rb b/app/models/tournament_option.rb index 950b351..242a6f6 100644 --- a/app/models/tournament_option.rb +++ b/app/models/tournament_option.rb @@ -1,2 +1,3 @@ class TournamentOption < ActiveRecord::Base + belongs_to :tournament end diff --git a/app/models/tournament_user_pair.rb b/app/models/tournament_user_pair.rb new file mode 100644 index 0000000..eb4e9c5 --- /dev/null +++ b/app/models/tournament_user_pair.rb @@ -0,0 +1,4 @@ +class TournamentUserPair < ActiveRecord::Base + belongs_to :tournament + belongs_to :user +end diff --git a/app/views/games/_form.html.erb b/app/views/games/_form.html.erb index 8941c59..f68e28f 100644 --- a/app/views/games/_form.html.erb +++ b/app/views/games/_form.html.erb @@ -16,12 +16,20 @@ <%= f.text_area :name %> </div> <div class="field"> - <%= f.label :players_per_team %><br> - <%= f.number_field :players_per_team %> + <%= f.label :min_players_per_team %><br> + <%= f.number_field :min_players_per_team %> </div> <div class="field"> - <%= f.label :teams_per_match %><br> - <%= f.number_field :teams_per_match %> + <%= f.label :max_players_per_team %><br> + <%= f.number_field :max_players_per_team %> + </div> + <div class="field"> + <%= f.label :min_teams_per_match %><br> + <%= f.number_field :min_teams_per_match %> + </div> + <div class="field"> + <%= f.label :max_teams_per_match %><br> + <%= f.number_field :max_teams_per_match %> </div> <div class="field"> <%= f.label :set_rounds %><br> @@ -29,7 +37,7 @@ </div> <div class="field"> <%= f.label :randomized_teams %><br> - <%= f.number_field :randomized_teams %> + <%= f.check_box :randomized_teams %> </div> <div class="actions"> <%= f.submit %> diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb index 9893cbc..79acd1e 100644 --- a/app/views/games/index.html.erb +++ b/app/views/games/index.html.erb @@ -4,8 +4,10 @@ <thead> <tr> <th>Name</th> - <th>Players per team</th> - <th>Teams per match</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></th> @@ -18,8 +20,10 @@ <% @games.each do |game| %> <tr> <td><%= game.name %></td> - <td><%= game.players_per_team %></td> - <td><%= game.teams_per_match %></td> + <td><%= game.min_players_per_team %></td> + <td><%= game.max_players_per_team %></td> + <td><%= game.min_teams_per_match %></td> + <td><%= game.max_teams_per_match %></td> <td><%= game.set_rounds %></td> <td><%= game.randomized_teams %></td> <td><%= link_to 'Show', game %></td> diff --git a/app/views/games/index.json.jbuilder b/app/views/games/index.json.jbuilder index 7e5c1a1..f8b3e96 100644 --- a/app/views/games/index.json.jbuilder +++ b/app/views/games/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@games) do |game| - json.extract! game, :id, :name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams + json.extract! game, :id, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams json.url game_url(game, format: :json) end diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 88bf91c..39d4a97 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -4,13 +4,23 @@ </p> <p> - <strong>Players per team:</strong> - <%= @game.players_per_team %> + <strong>Min players per team:</strong> + <%= @game.min_players_per_team %> </p> <p> - <strong>Teams per match:</strong> - <%= @game.teams_per_match %> + <strong>Max players per team:</strong> + <%= @game.max_players_per_team %> +</p> + +<p> + <strong>Min teams per match:</strong> + <%= @game.min_teams_per_match %> +</p> + +<p> + <strong>Max teams per match:</strong> + <%= @game.max_teams_per_match %> </p> <p> diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder index 1a2d0c7..e689e7b 100644 --- a/app/views/games/show.json.jbuilder +++ b/app/views/games/show.json.jbuilder @@ -1 +1 @@ -json.extract! @game, :id, :name, :players_per_team, :teams_per_match, :set_rounds, :randomized_teams, :created_at, :updated_at +json.extract! @game, :id, :name, :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/app/views/teams/_form.html.erb b/app/views/teams/_form.html.erb index fd10129..cdd4299 100644 --- a/app/views/teams/_form.html.erb +++ b/app/views/teams/_form.html.erb @@ -11,6 +11,10 @@ </div> <% end %> + <div class="field"> + <%= f.label :match_id %><br> + <%= f.text_field :match_id %> + </div> <div class="actions"> <%= f.submit %> </div> diff --git a/app/views/teams/index.html.erb b/app/views/teams/index.html.erb index b077e10..6a3188d 100644 --- a/app/views/teams/index.html.erb +++ b/app/views/teams/index.html.erb @@ -3,6 +3,7 @@ <table> <thead> <tr> + <th>Match</th> <th></th> <th></th> <th></th> @@ -12,6 +13,7 @@ <tbody> <% @teams.each do |team| %> <tr> + <td><%= team.match %></td> <td><%= link_to 'Show', team %></td> <td><%= link_to 'Edit', edit_team_path(team) %></td> <td><%= link_to 'Destroy', team, method: :delete, data: { confirm: 'Are you sure?' } %></td> diff --git a/app/views/teams/index.json.jbuilder b/app/views/teams/index.json.jbuilder index b29428b..ca0ec8b 100644 --- a/app/views/teams/index.json.jbuilder +++ b/app/views/teams/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@teams) do |team| - json.extract! team, :id + json.extract! team, :id, :match_id json.url team_url(team, format: :json) end diff --git a/app/views/teams/show.html.erb b/app/views/teams/show.html.erb index ab49d65..e41692a 100644 --- a/app/views/teams/show.html.erb +++ b/app/views/teams/show.html.erb @@ -1,2 +1,9 @@ +<p id="notice"><%= notice %></p> + +<p> + <strong>Match:</strong> + <%= @team.match %> +</p> + <%= link_to 'Edit', edit_team_path(@team) %> | <%= link_to 'Back', teams_path %> diff --git a/app/views/teams/show.json.jbuilder b/app/views/teams/show.json.jbuilder index 1538019..8a85dcc 100644 --- a/app/views/teams/show.json.jbuilder +++ b/app/views/teams/show.json.jbuilder @@ -1 +1 @@ -json.extract! @team, :id, :created_at, :updated_at +json.extract! @team, :id, :match_id, :created_at, :updated_at diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 1fd63e9..c2c0ba7 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -15,6 +15,34 @@ <%= f.label :game_id %><br> <%= f.text_field :game_id %> </div> + <div class="field"> + <%= f.label :min_players_per_team %><br> + <%= f.number_field :min_players_per_team %> + </div> + <div class="field"> + <%= f.label :max_players_per_team %><br> + <%= f.number_field :max_players_per_team %> + </div> + <div class="field"> + <%= f.label :min_teams_per_match %><br> + <%= f.number_field :min_teams_per_match %> + </div> + <div class="field"> + <%= f.label :max_teams_per_match %><br> + <%= f.number_field :max_teams_per_match %> + </div> + <div class="field"> + <%= f.label :set_rounds %><br> + <%= f.number_field :set_rounds %> + </div> + <div class="field"> + <%= 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 e9147f6..80d68a3 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -4,17 +4,31 @@ <table class="table table-hover"> <thead> <tr> - <th>Tournament ID</th> - <th>Show Tournament</th> - <th>Edit Tournament</th> - <th>Delete Tournament</th> + <th>Game</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> </tr> </thead> <tbody> <% @tournaments.each do |tournament| %> <tr> - <td><%= tournament.id %></td> + <td><%= tournament.game %></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 e6f3b49..df8eee4 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 + 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.url tournament_url(tournament, format: :json) end diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 0d9dd10..4f97c7c 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -3,5 +3,40 @@ <%= @tournament.game %> </p> +<p> + <strong>Min players per team:</strong> + <%= @tournament.min_players_per_team %> +</p> + +<p> + <strong>Max players per team:</strong> + <%= @tournament.max_players_per_team %> +</p> + +<p> + <strong>Min teams per match:</strong> + <%= @tournament.min_teams_per_match %> +</p> + +<p> + <strong>Max teams per match:</strong> + <%= @tournament.max_teams_per_match %> +</p> + +<p> + <strong>Set rounds:</strong> + <%= @tournament.set_rounds %> +</p> + +<p> + <strong>Randomized teams:</strong> + <%= @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 0fe65a6..7bedd4b 100644 --- a/app/views/tournaments/show.json.jbuilder +++ b/app/views/tournaments/show.json.jbuilder @@ -1 +1 @@ -json.extract! @tournament, :id, :game_id, :created_at, :updated_at +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 |