add everything to manage reputations
This commit is contained in:
@@ -12,38 +12,9 @@ class WowCharacter < ApplicationRecord
|
||||
belongs_to :last_position, class_name: 'WowGeoPosition', optional: true
|
||||
belongs_to :bind_position, class_name: 'WowGeoPosition', optional: true
|
||||
has_one :wow_character_medium, dependent: :nullify
|
||||
has_many :wow_standings, dependent: :nullify
|
||||
has_many :wow_reputations, through: :wow_standings
|
||||
|
||||
validates :name, presence: true
|
||||
validates :character_id, presence: true, uniqueness: true
|
||||
|
||||
def gender_class_name
|
||||
case gender
|
||||
when 'FEMALE'
|
||||
wow_class.female_name
|
||||
when 'MALE'
|
||||
wow_class.male_name
|
||||
end
|
||||
end
|
||||
|
||||
def gender_race_name
|
||||
case gender
|
||||
when 'FEMALE'
|
||||
wow_race.female_name
|
||||
when 'MALE'
|
||||
wow_race.male_name
|
||||
end
|
||||
end
|
||||
|
||||
def title_name
|
||||
if wow_character_title
|
||||
case gender
|
||||
when 'FEMALE'
|
||||
wow_character_title.female_name.gsub('{name}', name)
|
||||
when 'MALE'
|
||||
wow_character_title.male_name.gsub('{name}', name)
|
||||
end
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
13
app/models/wow_reputation.rb
Normal file
13
app/models/wow_reputation.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class WowReputation < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name, :description, :translated_faction
|
||||
|
||||
has_many :wow_standings, dependent: :destroy
|
||||
has_many :wow_characters, through: :wow_standings
|
||||
belongs_to :wow_reputation_tier, optional: true
|
||||
has_many :sub_wow_reputations, class_name: 'WowReputation', foreign_key: 'meta_wow_reputation_id', dependent: :nullify, inverse_of: :meta_wow_reputation
|
||||
belongs_to :meta_wow_reputation, class_name: 'WowReputation', optional: true
|
||||
|
||||
validates :name, presence: true
|
||||
validates :reputation_id, presence: true, uniqueness: true
|
||||
end
|
||||
6
app/models/wow_reputation_tier.rb
Normal file
6
app/models/wow_reputation_tier.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class WowReputationTier < ApplicationRecord
|
||||
has_many :wow_reputations, dependent: :nullify
|
||||
has_many :wow_reputation_tier_levels, dependent: :destroy
|
||||
|
||||
validates :reputation_tier_id, presence: true, uniqueness: true
|
||||
end
|
||||
9
app/models/wow_reputation_tier_level.rb
Normal file
9
app/models/wow_reputation_tier_level.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class WowReputationTierLevel < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name
|
||||
|
||||
belongs_to :wow_reputation_tier
|
||||
|
||||
validates :name, presence: true
|
||||
validates :order, presence: true, uniqueness: { scope: :wow_reputation_tier }
|
||||
end
|
||||
7
app/models/wow_standing.rb
Normal file
7
app/models/wow_standing.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class WowStanding < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name
|
||||
|
||||
belongs_to :wow_character
|
||||
belongs_to :wow_reputation
|
||||
end
|
||||
Reference in New Issue
Block a user