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(-) 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(-) 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(-) 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 %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 0653957..9b7f013 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -21,3 +21,11 @@ en: hello: "Hello world" + + simple_captcha: + placeholder: "Enter the image value" + label: "Enter the code in the box:" + + message: + default: "Secret Code did not match with the Image" + user: "The secret Image and code were different" diff --git a/config/routes.rb b/config/routes.rb index 571e629..01a63e9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,8 @@ Leaguer::Application.routes.draw do resource :server, only: [:show, :edit, :update] + #match 'simple_captcha/:id', :to => 'simple_captcha#show', :as => :simple_captcha + resources :teams resources :tournaments do resources :matches diff --git a/db/schema.rb b/db/schema.rb index 113f16d..30ac1af 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140403155049) do +ActiveRecord::Schema.define(version: 20140403171427) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -129,6 +129,15 @@ ActiveRecord::Schema.define(version: 20140403155049) do add_index "sessions", ["token"], name: "index_sessions_on_token", unique: true add_index "sessions", ["user_id"], name: "index_sessions_on_user_id" + create_table "simple_captcha_data", force: true do |t| + t.string "key", limit: 40 + t.string "value", limit: 6 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "simple_captcha_data", ["key"], name: "idx_key" + create_table "teams", force: true do |t| t.integer "match_id" t.datetime "created_at" -- cgit v1.2.3-2-g168b From 91623c4f865d25c33ed64632ae61b506e0bb1ab4 Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Thu, 3 Apr 2014 17:59:22 -0400 Subject: added captcha to generate --- generate.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generate.sh b/generate.sh index 728e122..0998488 100755 --- a/generate.sh +++ b/generate.sh @@ -12,6 +12,8 @@ cd "$srcdir" git rm -rf app test config/routes.rb db/migrate git checkout clean-start -- app test config/routes.rb +bundle exec rails generate simple_captcha + # The whole shebang, models, views, and controllers bundle exec rails generate scaffold server --force $NOTEST bundle exec rails generate scaffold match status:integer tournament:references name:string winner:references remote_id:string $NOTEST -- 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(-) 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 c61cbdc810cb5b00fa24cf33e34b261d36edaecc Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Thu, 3 Apr 2014 18:33:56 -0400 Subject: Added basic options in seed for game specific settings. --- db/seeds.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index 06b46a6..22f1595 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,7 +6,14 @@ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) # -Game.create(name: "League of Legends",min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true) +Game.create(name: "League of Legends",min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true) Game.create(name: "Chess", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true) +Game.create(name: "Hearthstone", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: 1, randomized_teams: false) + + +GameSetting.create(game_id: 0, name: "Map", default: "Summoners Rift,Twisted Treeline,Crystal Scar,Haunted Abyss", discription: "Select a map to play on.", type_opt: "Select", display_order: 1) +GameSetting.create(game_id: 0, name: "Pick Type", default: "Blind Pick,Draft", discription: "Select a pick type.", type_opt: "Select", display_order: 2) + +#Game_setting.create(game_id: , type: , name: , default: , discription: , type_opt: , display_order: , created_at: , updated_at: ) #User.create(id: 1, name: "Andrew", email: "amurrel@example.com", user_name: "ImFromNASA", created_at: "2014-03-07 22:48:53", updated_at: "2014-03-07 22:48:53", password_digest: "$2a$10$W0FwPRDzdQp8arolCHGt5ezXqkOiTLNsXI5GKGtu9qr3...", remember_token: "1583722b02663e024533296171cad79f29037ebc", groups: 0) -- 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 --- Gemfile | 2 +- Gemfile.lock | 2 -- app/helpers/sessions_helper.rb | 4 ++-- app/models/match.rb | 3 +++ app/views/matches/show.html.erb | 19 +++++++++++++++++++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index fadfd18..a34b0a6 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'httparty' gem 'simple_captcha2', require: 'simple_captcha' -gem 'rmagick' +#gem 'rmagick' group :development, :test do # Use sqlite3 as the database for Active Record diff --git a/Gemfile.lock b/Gemfile.lock index a2d2578..51e29e7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,7 +83,6 @@ GEM rdoc (4.1.1) json (~> 1.4) ref (1.0.5) - rmagick (2.13.2) sass (3.2.18) sass-rails (4.0.2) railties (>= 4.0.0, < 5.0) @@ -134,7 +133,6 @@ DEPENDENCIES jbuilder (~> 1.2) jquery-rails rails (= 4.0.2) - rmagick sass-rails (~> 4.0.0) sdoc simple_captcha2 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(-) 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) %>