continue to backport old code
This commit is contained in:
4
app/models/learned_wow_pet_ability.rb
Normal file
4
app/models/learned_wow_pet_ability.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class LearnedWowPetAbility < ApplicationRecord
|
||||
belongs_to :wow_pet
|
||||
belongs_to :wow_pet_ability
|
||||
end
|
||||
@@ -8,6 +8,10 @@ class User < ApplicationRecord
|
||||
devise :rememberable, :omniauthable, omniauth_providers: [:bnet]
|
||||
|
||||
has_many :wow_characters, dependent: :destroy
|
||||
has_many :user_obtain_wow_mounts, dependent: :destroy
|
||||
has_many :wow_mounts, through: :user_obtain_wow_mounts
|
||||
has_many :user_obtain_wow_pets, dependent: :destroy
|
||||
has_many :wow_pets, through: :user_obtain_wow_pets
|
||||
|
||||
validates :battletag, presence: true, uniqueness: true
|
||||
|
||||
@@ -28,8 +32,8 @@ class User < ApplicationRecord
|
||||
|
||||
def self.new_with_session(params, session)
|
||||
super.tap do |user|
|
||||
if (data = session['devise.bnet_data']) && session['devise.bnet_data']['extra']['raw_info']
|
||||
user.email = data['email'] if user.email.blank?
|
||||
if (data = session['devise.bnet_data']) && session['devise.bnet_data']['extra']['raw_info'] && user.email.blank?
|
||||
user.email = data['email']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
4
app/models/user_obtain_wow_mount.rb
Normal file
4
app/models/user_obtain_wow_mount.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class UserObtainWowMount < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :wow_mount
|
||||
end
|
||||
4
app/models/user_obtain_wow_pet.rb
Normal file
4
app/models/user_obtain_wow_pet.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class UserObtainWowPet < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :wow_pet
|
||||
end
|
||||
@@ -11,4 +11,35 @@ class WowCharacter < ApplicationRecord
|
||||
|
||||
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
|
||||
|
||||
10
app/models/wow_mount.rb
Normal file
10
app/models/wow_mount.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class WowMount < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name, :description, :translated_faction, :translated_source
|
||||
|
||||
has_many :user_obtain_mounts, dependent: :destroy
|
||||
has_many :users, through: :user_obtain_mounts
|
||||
|
||||
validates :name, presence: true
|
||||
validates :mount_id, presence: true, uniqueness: true
|
||||
end
|
||||
10
app/models/wow_pet.rb
Normal file
10
app/models/wow_pet.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class WowPet < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name, :translated_battle_pet_type, :description, :translated_source_type
|
||||
|
||||
has_many :learned_wow_pet_abilities, dependent: :destroy
|
||||
has_many :wow_pet_abilities, through: :learned_wow_pet_abilities
|
||||
|
||||
validates :name, presence: true
|
||||
validates :pet_id, presence: true, uniqueness: true
|
||||
end
|
||||
10
app/models/wow_pet_ability.rb
Normal file
10
app/models/wow_pet_ability.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class WowPetAbility < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name, :translated_battle_pet_type
|
||||
|
||||
has_many :learned_pet_abilities, dependent: :destroy
|
||||
has_many :wow_pets, through: :learned_pet_abilities
|
||||
|
||||
validates :name, presence: true
|
||||
validates :ability_id, presence: true, uniqueness: true
|
||||
end
|
||||
Reference in New Issue
Block a user