diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/bracket_match.rb | 4 | ||||
-rw-r--r-- | app/models/match.rb | 4 | ||||
-rw-r--r-- | app/models/pm.rb | 4 | ||||
-rw-r--r-- | app/models/remote_username.rb | 4 | ||||
-rw-r--r-- | app/models/tournament_setting.rb | 4 | ||||
-rw-r--r-- | app/models/tournament_stage.rb | 4 |
6 files changed, 23 insertions, 1 deletions
diff --git a/app/models/bracket_match.rb b/app/models/bracket_match.rb index f9a11f0..14a8002 100644 --- a/app/models/bracket_match.rb +++ b/app/models/bracket_match.rb @@ -3,5 +3,7 @@ class BracketMatch < ActiveRecord::Base belongs_to :match belongs_to :predicted_winner, class_name: "Team" - + def owned_by?(user) + self.bracket.owned_by?(user) + end end diff --git a/app/models/match.rb b/app/models/match.rb index ed21f78..f1c32fe 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -14,6 +14,10 @@ class Match < ActiveRecord::Base # winner:references # not validated + def owned_by?(user) + self.tournament_stage.owned_by?(user) + end + ## # Returns whether or not all the statistics have been collected # such that the match may be considered finished. diff --git a/app/models/pm.rb b/app/models/pm.rb index 8b06181..3d14149 100644 --- a/app/models/pm.rb +++ b/app/models/pm.rb @@ -7,6 +7,10 @@ class Pm < ActiveRecord::Base return current_user.name end + def owned_by?(user) + self.author == user + end + =begin def mailboxer_email(email) return current_user.email diff --git a/app/models/remote_username.rb b/app/models/remote_username.rb index c863ede..23dc0a8 100644 --- a/app/models/remote_username.rb +++ b/app/models/remote_username.rb @@ -2,6 +2,10 @@ class RemoteUsername < ActiveRecord::Base belongs_to :game belongs_to :user + def owned_by?(tuser) + self.user == tuser + end + def value begin return JSON::restore(self.json_value) diff --git a/app/models/tournament_setting.rb b/app/models/tournament_setting.rb index 20d9842..48c607e 100644 --- a/app/models/tournament_setting.rb +++ b/app/models/tournament_setting.rb @@ -4,6 +4,10 @@ class TournamentSetting < ActiveRecord::Base validates(:vartype, presence: true, numericality: {only_integer: true}) validates(:type_opt, presence: true, if: :needs_type_opt?) + def owned_by?(user) + self.tournament.owned_by?(user) + end + def needs_type_opt? [ GameSetting.types[:pick_one_radio], diff --git a/app/models/tournament_stage.rb b/app/models/tournament_stage.rb index 72aa14c..efb4d5c 100644 --- a/app/models/tournament_stage.rb +++ b/app/models/tournament_stage.rb @@ -12,6 +12,10 @@ class TournamentStage < ActiveRecord::Base presence: true, inclusion: {in: Tournament.new.seeding_methods}) + def owned_by?(user) + self.tournament.owned_by?(user) + end + # A 1-indexed hash of matches def matches_ordered h = {} |