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/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') 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 -- cgit v1.2.3-2-g168b From 01c3f1af652fb32c235ad1c047d652e5148dba94 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 6 Mar 2014 22:55:10 -0500 Subject: fix thing again --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/user.rb b/app/models/user.rb index fa07b60..4d6902a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,6 @@ class User < ActiveRecord::Base - has_and_belongs_to_many :tournaments_played, class_name: "Tournament", foreign_key: "tournament_id", join_table: "players_tournaments" - has_and_belongs_to_many :tournaments_hosted, class_name: "Tournament", foreign_key: "tournament_id", join_table: "hosts_tournaments" + has_and_belongs_to_many :tournaments_played, class_name: "Tournament", foreign_key: "player_id", join_table: "players_tournaments" + has_and_belongs_to_many :tournaments_hosted, class_name: "Tournament", foreign_key: "host_id", join_table: "hosts_tournaments" before_save { self.email = email.downcase } before_save { self.user_name = user_name } -- cgit v1.2.3-2-g168b From 501e305de609313809b2641522679c17834c603f Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Thu, 6 Mar 2014 23:08:42 -0500 Subject: Fixed the registration in the tourney model and fixed a lint int the controller. --- app/models/tournament.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'app/models') diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 44b22f5..fe781e1 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -25,9 +25,17 @@ class Tournament < ActiveRecord::Base for i in 0..num_matches self.matches.create(name: "Match #{i}") end - #self.players.each_slice(num_teams) do |team_players| - # Team.new(users: team_players) - #end + match_num = 0 + team_num = 0 + self.players.each_slice(@tournament.max_players) do |players| + matches[match_num].teams[team_num] = Team.new(users: players) + if (team_num == 0 and team_num % @tournament.max_teams_per_match == 0) + match_num += 1 + team_num = 0 + else + team_num += 1 + end + end end -- cgit v1.2.3-2-g168b From 39ceb0e99eecd76b2cdebeb802930a98a764417a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 6 Mar 2014 23:15:53 -0500 Subject: let anyone always create a tourney --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/user.rb b/app/models/user.rb index 4d6902a..bd1a9ac 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 ((groups & 1) != 0) + return true #((groups & 1) != 0) when :player return true when :specator -- cgit v1.2.3-2-g168b