summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTomer Kimia <tkimia@purdue.edu>2014-03-27 16:59:11 -0400
committerTomer Kimia <tkimia@purdue.edu>2014-03-27 16:59:11 -0400
commita683a208e31d5bafe7658521921f9f2c1a637418 (patch)
treeabf23ef14f584583973796b3da573c5061eb8533 /app
parentaeda550c2ad04c9496a803b1d7f1d34a4566a9fe (diff)
parentd8acc6785ee41a2628cd0d59d91916b2f087290b (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Conflicts: app/views/tournaments/show.html.erb
Diffstat (limited to 'app')
-rw-r--r--app/controllers/matches_controller.rb2
-rw-r--r--app/controllers/tournaments_controller.rb4
-rw-r--r--app/models/game_option.rb2
-rw-r--r--app/models/game_setting.rb3
-rw-r--r--app/views/matches/_form.html.erb4
-rw-r--r--app/views/matches/index.html.erb3
-rw-r--r--app/views/matches/index.json.jbuilder2
-rw-r--r--app/views/matches/show.html.erb5
-rw-r--r--app/views/matches/show.json.jbuilder2
-rw-r--r--app/views/tournaments/_form.html.erb4
-rw-r--r--app/views/tournaments/index.html.erb3
-rw-r--r--app/views/tournaments/index.json.jbuilder2
-rw-r--r--app/views/tournaments/show.html.erb24
-rw-r--r--app/views/tournaments/show.json.jbuilder2
14 files changed, 45 insertions, 17 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 1f0d964..b312e9e 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -72,6 +72,6 @@ class MatchesController < ApplicationController
end
# Never trust parameters from the scary internet, only allow the white list through.
def match_params
- params.require(:match).permit(:tournament_id, :name, :winner_id)
+ params.require(:match).permit(:status, :tournament_id, :name, :winner_id)
end
end
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 7352e8d..8d90758 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -124,6 +124,8 @@ 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, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams)
+
+ params.require(:tournament).permit(:game, :name, :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/game_option.rb b/app/models/game_option.rb
deleted file mode 100644
index bdc5560..0000000
--- a/app/models/game_option.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class GameOption < ActiveRecord::Base
-end
diff --git a/app/models/game_setting.rb b/app/models/game_setting.rb
new file mode 100644
index 0000000..e147b15
--- /dev/null
+++ b/app/models/game_setting.rb
@@ -0,0 +1,3 @@
+class GameSetting < ActiveRecord::Base
+ belongs_to :game
+end
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb
index 015aed0..3efb566 100644
--- a/app/views/matches/_form.html.erb
+++ b/app/views/matches/_form.html.erb
@@ -1,6 +1,10 @@
<%= form_for([@tournament, @tournament.matches.build]) do |f| %>
<div class="field">
+ <%= f.label :status %><br>
+ <%= f.number_field :status %>
+ </div>
+ <div class="field">
<%= f.label :tournament_id %><br>
<%= f.text_field :tournament_id %>
</div>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 60df1b5..d862d57 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -3,6 +3,7 @@
<table>
<thead>
<tr>
+ <th>Status</th>
<th>Tournament</th>
<th>Name</th>
<th>Winner</th>
@@ -16,6 +17,8 @@
<% @tournament.matches.each do |match| %>
<tr>
<td><%= match.tournament.id %></td>
+ <td><%= match.status %></td>
+ <td><%= match.tournament %></td>
<td><%= match.name %></td>
<td><%= match.winner %></td>
<td><%= link_to 'Show', tournament_match_path(@tournament, match) %></td>
diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder
index 0b2bfcd..1a63f5f 100644
--- a/app/views/matches/index.json.jbuilder
+++ b/app/views/matches/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@matches) do |match|
- json.extract! match, :id, :tournament_id, :name, :winner_id
+ json.extract! match, :id, :status, :tournament_id, :name, :winner_id
json.url match_url(match, format: :json)
end
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index b6930ea..6b962ad 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -1,4 +1,9 @@
<p>
+ <strong>Status:</strong>
+ <%= @match.status %>
+</p>
+
+<p>
<strong>Tournament:</strong>
<%= @match.tournament.id %>
</p>
diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder
index fe14010..a3ef588 100644
--- a/app/views/matches/show.json.jbuilder
+++ b/app/views/matches/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at
+json.extract! @match, :id, :status, :tournament_id, :name, :winner_id, :created_at, :updated_at
diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb
index d098cbb..38855a0 100644
--- a/app/views/tournaments/_form.html.erb
+++ b/app/views/tournaments/_form.html.erb
@@ -12,6 +12,10 @@
<% end %>
<div class="field">
+ <%= f.label :name %><br>
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
<%= f.label :game_id %><br>
<%= f.text_field :game_id %>
</div>
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
index 7fb4a1d..90c3d7a 100644
--- a/app/views/tournaments/index.html.erb
+++ b/app/views/tournaments/index.html.erb
@@ -4,6 +4,7 @@
<table class="table table-hover">
<thead>
<tr>
+ <th>Name</th>
<th>Game</th>
<th>Status</th>
<th>Players per team</th>
@@ -18,7 +19,7 @@
<tbody>
<% @tournaments.each do |tournament| %>
<tr>
- <td><%= tournament.id %></td>
+ <td><%= tournament.name %></td>
<td><% case tournament.status
when 0 %>
<%= form_tag(tournament_path(tournament), method: "put") do %>
diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder
index e95c6a7..4038f04 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, :status, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams
+ json.extract! tournament, :id, :name, :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 acff3d4..cc0f0e3 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -1,3 +1,6 @@
+<h2 id="tournament-name">
+ <%= @tournament.name %>
+</h2>
<div class="progress">
<%= tag("div", {:class => "progress-bar progress-bar-warning", :style => "width: " +(@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s + "%", "aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => (@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s, "role" => "progressbar"}) %>
@@ -6,15 +9,16 @@
</div>
<p id="players-needed"><%= pluralize(@tournament.players.count, "player has", "players have") %> signed up. <%= @tournament.min_players_per_team * @tournament.min_teams_per_match %> needed. </p>
-<div id="tournament-side-params">
- <p>
- <strong>Game:</strong>
- <%= @tournament.id %>
- </p>
+<span id="tournament-side-params">
+
<p>
<strong>Status:</strong>
- <%= @tournament.status %>
+ <% if @tournament.status == 0 %>
+ Waiting for players...
+ <% else %>
+ Started
+ <% end %>
</p>
<p>
@@ -46,15 +50,19 @@
<strong>Randomized teams:</strong>
<%= @tournament.randomized_teams %>
</p>
-</div>
+</span>
+<div >
<%# Show all players in the tournament %>
<% if @tournament.players.length > 0 %>
+<h3> Players Here: </h3>
<ul id="tournament-users">
<% @tournament.players.each do |p| %>
<li><span class="black"> <%= p.user_name %> </span> </li>
<% end %>
</ul>
+ <% else %>
+ <h3 div="players-needed">Hmmm.... nobody's here yet! You and your friends should join the tournament.</h3>
<% end %>
<%# If user can join, and user hasn't joined already, show the join tournment tag %>
@@ -79,5 +87,5 @@
<%= link_to 'Back', tournaments_path %>
<% end %>
<%end %>
-
+</div>
diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder
index de2fbe0..27fd5c0 100644
--- a/app/views/tournaments/show.json.jbuilder
+++ b/app/views/tournaments/show.json.jbuilder
@@ -1 +1 @@
-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
+json.extract! @tournament, :id, :name, :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