summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorguntasgrewal <guntasgrewal@gmail.com>2014-04-26 20:35:55 -0400
committerguntasgrewal <guntasgrewal@gmail.com>2014-04-26 20:35:55 -0400
commit1d24cb050f198e9c8bec8dd014de203d889ab56a (patch)
tree9f10e7a5be75d7ffb4cb829d3738a144b5250b9b /app/models
parent2d0fe1a4197e70cb99f4285a8b32a645914d8beb (diff)
parentdfbbe46fdcca392b3dec703cf347d1b1d57ca94f (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/models')
-rw-r--r--app/models/bracket.rb7
-rw-r--r--app/models/tournament.rb1
-rw-r--r--app/models/user.rb4
3 files changed, 12 insertions, 0 deletions
diff --git a/app/models/bracket.rb b/app/models/bracket.rb
index e8d9c5a..acd33ca 100644
--- a/app/models/bracket.rb
+++ b/app/models/bracket.rb
@@ -1,4 +1,11 @@
class Bracket < ActiveRecord::Base
belongs_to :user
belongs_to :tournament
+ has_many :bracket_matches
+
+ def create_matches
+ tournament.stages.first.matches.each do |m|
+ bracket_matches.create(match: m)
+ end
+ end
end
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 861be6c..7460a7d 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -1,6 +1,7 @@
class Tournament < ActiveRecord::Base
belongs_to :game
has_many :stages, class_name: "TournamentStage"
+ has_many :brackets
has_many :settings_raw, class_name: "TournamentSetting"
has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments"
has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments"
diff --git a/app/models/user.rb b/app/models/user.rb
index d87f988..b2c7862 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -74,6 +74,10 @@ class User < ActiveRecord::Base
:edit_permissions => (2**19),
:edit_server => (2**20),
+
+ :create_bracket => (2**21),
+ :edit_bracket => (2**22),
+ :delete_bracket => (2**23)
}
end