diff options
-rw-r--r-- | app/controllers/tournaments_controller.rb | 11 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/views/tournaments/join.html.erb | 2 | ||||
-rw-r--r-- | app/views/tournaments/show.html.erb | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | stop.sh | 0 |
5 files changed, 27 insertions, 4 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 7c93346..5bb9bf8 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -13,8 +13,10 @@ class TournamentsController < ApplicationController # GET /tournaments/1 # GET /tournaments/1.json def show - unless @tournament.status - redirect_to tournament_matches_page(@tournament) + case @tournament.status + when 0 + when 1..2 + redirect_to "/tournaments/" + @tournament.id.to_s + "/matches" #tournament_matches_page(@tournament) end end @@ -27,6 +29,11 @@ class TournamentsController < ApplicationController # GET /tournaments/1/edit def edit + if params['close_action'] == 'close' + @tournament.status = 1 + @tournament.save + redirect_to "/tournaments" + end end # POST /tournaments diff --git a/app/models/user.rb b/app/models/user.rb index ff212e4..fa07b60 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,7 +18,7 @@ class User < ActiveRecord::Base when :admin return ((groups & 2) != 0) when :host - return true #((groups & 1) != 0) + return ((groups & 1) != 0) when :player return true when :specator diff --git a/app/views/tournaments/join.html.erb b/app/views/tournaments/join.html.erb new file mode 100644 index 0000000..1d38d68 --- /dev/null +++ b/app/views/tournaments/join.html.erb @@ -0,0 +1,2 @@ + <%= @user.name %> + diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 0cda6c1..c3a40e7 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,10 +1,11 @@ <% if @tournament.joinable_by?(current_user) %> <%= form_tag(tournament_path(@tournament), method: "put") do %> <input type="hidden" name="update_action" value="join"> - <%= submit_tag("Join") %> + <%= current_user.name %><%= submit_tag("Join") %> <% end %> <% end %> +<% if current_user.in_group?(:host) %> <p> <strong>Game:</strong> <%= @tournament.game %> @@ -45,5 +46,18 @@ <%= @tournament.randomized_teams %> </p> +<p> + <strong>Status:</strong> + <%= @tournament.status %> +</p> + +<%= form_tag(tournaments_path.to_s + "/" + @tournament.id.to_s + "/edit", method: "get") do %> + <input type="hidden" name="close_action" value="close"> + <%= submit_tag("Close Tournament Registration") %> +<% end %> + <%= link_to 'Edit', edit_tournament_path(@tournament) %> | <%= link_to 'Back', tournaments_path %> + +<% end %> + |