From ce8b05ed8fa3466c727269daa47ba7df672fdca1 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Thu, 6 Mar 2014 22:31:03 -0500 Subject: Redirection works as does the close tournament button. --- app/controllers/tournaments_controller.rb | 11 +++++++++-- app/models/user.rb | 2 +- app/views/tournaments/show.html.erb | 12 ++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 3f6de26..9e6a6e6 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -11,8 +11,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 @@ -25,6 +27,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 bad7f7b..c3a9acb 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/show.html.erb b/app/views/tournaments/show.html.erb index cd111f7..a04c852 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 %> - <%= submit_tag("Join") %> + <%= current_user.name %><%= submit_tag("Join") %> <% end %> <% end %> +<% if current_user.in_group?(:host) %>

Game: <%= @tournament.game %> @@ -45,5 +46,12 @@ <%= @tournament.status %>

+<%= form_tag(tournaments_path.to_s + "/" + @tournament.id.to_s + "/edit", method: "get") do %> + + <%= submit_tag("Close Tournament Registration") %> +<% end %> + <%= link_to 'Edit', edit_tournament_path(@tournament) %> | -<%= link_to 'Back', tournaments_path %> \ No newline at end of file +<%= link_to 'Back', tournaments_path %> + +<% end %> \ No newline at end of file -- cgit v1.2.3-2-g168b