From 9d2e1394bc09d4df3fce97d6151f5bfc3546fbe8 Mon Sep 17 00:00:00 2001 From: nfoy Date: Thu, 3 Apr 2014 16:48:58 -0400 Subject: Added Gravatar support for tournament's index view. --- app/views/tournaments/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index 6a86955..e174de7 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -6,7 +6,7 @@ <%# Each tournament has a div for its listing %> <% @tournaments.each do |t| %>
-
Gravatar of Host Goes Here
+
<%= image_tag 'http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(t.hosts.first.email) + '?s=100&d=mm' %>
-- cgit v1.2.3-2-g168b From 6cc7eb9e419c219d82d318ebb1bab8a853f73da5 Mon Sep 17 00:00:00 2001 From: tkimia Date: Thu, 3 Apr 2014 16:49:09 -0400 Subject: footer clears on both sides, has top-margin of 10. Tournament show screen repetitive info fixed --- app/assets/stylesheets/application.css | 5 +++++ app/views/tournaments/show.html.erb | 29 ----------------------------- 2 files changed, 5 insertions(+), 29 deletions(-) (limited to 'app') diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index b3f5d46..dd7588a 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -23,3 +23,8 @@ .navbar{ background-color: white; } + +footer { + clear: both; + margin-top: 10px; +} \ No newline at end of file diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index d246f7a..9939d02 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -40,35 +40,6 @@ <%= @tournament.max_teams_per_match %>

-

- Set rounds: - <%= @tournament.set_rounds %> -

- -

- Min players per team: - <%= @tournament.min_players_per_team %> -

- -

- Max players per team: - <%= @tournament.max_players_per_team %> -

- -

- Min teams per match: - <%= @tournament.min_teams_per_match %> -

- -

- Max teams per match: - <%= @tournament.max_teams_per_match %> -

- -

- Set rounds: - <%= @tournament.set_rounds %> -

Randomized teams: -- cgit v1.2.3-2-g168b From 051e61877b4c77a17fd4fa68dfca4d5e74a687df Mon Sep 17 00:00:00 2001 From: tkimia Date: Thu, 3 Apr 2014 17:17:12 -0400 Subject: fixed some of andrews weird stuff with starting a tournament --- app/controllers/tournaments_controller.rb | 14 +++++--------- app/models/tournament.rb | 8 ++++---- app/views/matches/index.html.erb | 4 ++-- app/views/tournaments/show.html.erb | 8 +++++--- 4 files changed, 16 insertions(+), 18 deletions(-) (limited to 'app') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 9cf3404..4bba997 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -36,12 +36,7 @@ class TournamentsController < ApplicationController # GET /tournaments/1/edit def edit - if params['close_action'] == 'close' - @tournament.status = 1 - @tournament.save - @tournament.setup(@tournament) - redirect_to "/tournaments" - end + end # POST /tournaments @@ -96,7 +91,10 @@ class TournamentsController < ApplicationController format.html {redirect_to @tournament, notice: 'You were\'t a part of this tournament.' } format.json { render json: "Permission denied", status: :forbidden } end - when "open" + when "start" + @tournament.status = 1 + @tournament.save + @tournament.setup() respond_to do |format| if @tournament.setup format.html { render action: 'show', notice: 'You have joined this tournament.' } @@ -105,8 +103,6 @@ class TournamentsController < ApplicationController format.html { render action: 'permission_denied', status: :forbidden } format.json { render json: "Permission denied", status: :forbidden } end - #when "close" - # TODO else respond_to do |format| format.html { render action: 'show', notice: "Invalid action", status: :unprocessable_entity } diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 4483535..6d92f3d 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -20,12 +20,12 @@ class Tournament < ActiveRecord::Base end def leave(user) - if players.include?(user) + if players.include?(user) && status == 0 players.delete(user) end end - def setup(tournament) + def setup() num_teams = (self.players.count/self.max_players_per_team).floor num_matches = num_teams - 1 for i in 1..num_matches @@ -33,9 +33,9 @@ class Tournament < ActiveRecord::Base end match_num = 0 team_num = 0 - self.players.each_slice(tournament.max_players_per_team) do |players| + self.players.each_slice(max_players_per_team) do |players| self.matches[match_num].teams.push(Team.create(users: players)) - if (team_num != 0 and team_num % tournament.max_teams_per_match == 0) + if (team_num != 0 and team_num % max_teams_per_match == 0) match_num += 1 team_num = 0 else diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 0f86da6..babf45e 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -1,6 +1,6 @@

<%= @tournament.name %> Matches

- + <% if @tournament.hosts.include?(current_user) %> - <%= form_tag(tournaments_path.to_s + "/" + @tournament.id.to_s + "/edit", method: "get") do %> -

+ <%= show_simple_captcha %> + <%= f.submit("Be a Leaguer", :class => "signup") %>

<% end %> -- cgit v1.2.3-2-g168b From effe4608e808a385bb912fccac26381d0bd0c95a Mon Sep 17 00:00:00 2001 From: tkimia Date: Thu, 3 Apr 2014 18:03:25 -0400 Subject: matches table is back, and a lot of things are fixed --- app/controllers/tournaments_controller.rb | 9 ++++----- app/models/tournament.rb | 6 +++--- app/views/matches/index.html.erb | 18 +++++++----------- 3 files changed, 14 insertions(+), 19 deletions(-) (limited to 'app') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 4bba997..ae384c1 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -76,7 +76,7 @@ class TournamentsController < ApplicationController when "join" respond_to do |format| if @tournament.join(current_user) - format.html { render action: 'show', notice: 'You have joined this tournament.' } + format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } format.json { head :no_content } end format.html { render action: 'permission_denied', status: :forbidden } @@ -85,7 +85,7 @@ class TournamentsController < ApplicationController when "leave" respond_to do |format| if @tournament.leave(current_user) - format.html {redirect_to tournaments_url, notice: 'You have left the tournament.' } + format.html { redirect_to tournaments_url, notice: 'You have left the tournament.' } format.json { head :no_content } end format.html {redirect_to @tournament, notice: 'You were\'t a part of this tournament.' } @@ -94,10 +94,9 @@ class TournamentsController < ApplicationController when "start" @tournament.status = 1 @tournament.save - @tournament.setup() respond_to do |format| if @tournament.setup - format.html { render action: 'show', notice: 'You have joined this tournament.' } + format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } format.json { head :no_content } end format.html { render action: 'permission_denied', status: :forbidden } @@ -105,7 +104,7 @@ class TournamentsController < ApplicationController end else respond_to do |format| - format.html { render action: 'show', notice: "Invalid action", status: :unprocessable_entity } + format.html { redirect_to @tournament, notice: "Invalid action", status: :unprocessable_entity } format.json { render json: @tournament.errors, status: :unprocessable_entity } end end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 6d92f3d..f1d533d 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -26,14 +26,14 @@ class Tournament < ActiveRecord::Base end def setup() - num_teams = (self.players.count/self.max_players_per_team).floor + num_teams = (self.players.count/self.min_players_per_team).floor num_matches = num_teams - 1 for i in 1..num_matches - self.matches.create(name: "Match #{i}") + self.matches.create(name: "Match #{i}", status: 0) end match_num = 0 team_num = 0 - self.players.each_slice(max_players_per_team) do |players| + self.players.each_slice(min_players_per_team) do |players| self.matches[match_num].teams.push(Team.create(users: players)) if (team_num != 0 and team_num % max_teams_per_match == 0) match_num += 1 diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index babf45e..d4ddb0e 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -1,28 +1,23 @@ -

<%= @tournament.name %> Matches

+

<%= @tournament.name %> - Matches

- +
- - - - - + <% @tournament.matches.each do |match| %> - - + - + <% end %> @@ -37,7 +32,8 @@ xmlns="http://www.w3.org/2000/svg"> <% (1..@matches.count).each do |i| %> - + + <% end %> -- cgit v1.2.3-2-g168b From cb1e09a7ef061cd3c1ca7cf5793d09b2aacb1536 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Fri, 4 Apr 2014 18:35:40 -0400 Subject: Cookie size 20 minutes --- app/helpers/sessions_helper.rb | 4 ++-- app/models/match.rb | 3 +++ app/views/matches/show.html.erb | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index 89e5ef3..60ddfa6 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -5,8 +5,8 @@ module SessionsHelper @session.save # FIXME: error handling @token = Session.hash_token(raw_token) - cookies.permanent[:remember_token] = raw_token - + #cookies.permanent[:remember_token] = raw_token + cookies.permanent[:remember_token] = { value: remember_token, expires: 20.minutes.from_now.utc } #set the current user to be the given user @current_user = user end diff --git a/app/models/match.rb b/app/models/match.rb index 35deb20..c596ced 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -5,4 +5,7 @@ class Match < ActiveRecord::Base belongs_to :winner, class_name: "Team" + def setup() + + end end diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index 53c3b38..4973dc3 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -12,7 +12,24 @@ Name: <%= @match.name %>

+ + <% if (@tournament.hosts.include?(current_user) and @match.winner.nil?) %> <%= form_for([@tournament, @match], method: "put") do |f| %>
    @@ -25,6 +42,8 @@ <% end %> <% end %> + + <% unless @match.winner.nil? %>

    Winner: -- cgit v1.2.3-2-g168b From d14dcf9af11a0f2eab2609efb7d9e59a9cc18bb0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 4 Apr 2014 20:39:10 -0400 Subject: re-jigger the TournamentController#update to be all one case block --- app/controllers/tournaments_controller.rb | 67 +++++++++++++++---------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'app') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index ae384c1..cc25033 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -59,8 +59,8 @@ class TournamentsController < ApplicationController # PATCH/PUT /tournaments/1 # PATCH/PUT /tournaments/1.json def update - - if params[:update_action].nil? + case params[:update_action] + when nil check_perms respond_to do |format| if @tournament.update(tournament_params) @@ -71,42 +71,39 @@ class TournamentsController < ApplicationController format.json { render json: @tournament.errors, status: :unprocessable_entity } end end - else - case params[:update_action] - when "join" - respond_to do |format| - if @tournament.join(current_user) - format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } - format.json { head :no_content } - end - format.html { render action: 'permission_denied', status: :forbidden } - format.json { render json: "Permission denied", status: :forbidden } + when "join" + respond_to do |format| + if @tournament.join(current_user) + format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } + format.json { head :no_content } end - when "leave" - respond_to do |format| - if @tournament.leave(current_user) - format.html { redirect_to tournaments_url, notice: 'You have left the tournament.' } - format.json { head :no_content } - end - format.html {redirect_to @tournament, notice: 'You were\'t a part of this tournament.' } - format.json { render json: "Permission denied", status: :forbidden } - end - when "start" - @tournament.status = 1 - @tournament.save - respond_to do |format| - if @tournament.setup - format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } - format.json { head :no_content } - end - format.html { render action: 'permission_denied', status: :forbidden } - format.json { render json: "Permission denied", status: :forbidden } + format.html { render action: 'permission_denied', status: :forbidden } + format.json { render json: "Permission denied", status: :forbidden } + end + when "leave" + respond_to do |format| + if @tournament.leave(current_user) + format.html { redirect_to tournaments_url, notice: 'You have left the tournament.' } + format.json { head :no_content } end - else - respond_to do |format| - format.html { redirect_to @tournament, notice: "Invalid action", status: :unprocessable_entity } - format.json { render json: @tournament.errors, status: :unprocessable_entity } + format.html {redirect_to @tournament, notice: 'You were\'t a part of this tournament.' } + format.json { render json: "Permission denied", status: :forbidden } + end + when "start" + @tournament.status = 1 + @tournament.save + respond_to do |format| + if @tournament.setup + format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } + format.json { head :no_content } end + format.html { render action: 'permission_denied', status: :forbidden } + format.json { render json: "Permission denied", status: :forbidden } + end + else + respond_to do |format| + format.html { redirect_to @tournament, notice: "Invalid action", status: :unprocessable_entity } + format.json { render json: @tournament.errors, status: :unprocessable_entity } end end end -- cgit v1.2.3-2-g168b

StatusTournament Name WinnerRemote
<%= match.tournament.id %> <%= match.status %><%= match.tournament %><%= match.id%> <%= match.name %><%= match.winner %><%= link_to "Show", tournament_match_path(@tournament, match) %>