Fully disable model translations for Color/Species/Zone

Now that DTI 2020 has been deployed without references to the
translations tables, we can stop keeping them in sync!

Next step is to drop the tables and be done with them altogether! (I
have a backup of the public data for this too, as does this repo!)
This commit is contained in:
Emi Matchu 2024-02-03 08:13:14 -08:00
parent 612cf914e0
commit 2667ed49ba
3 changed files with 1 additions and 45 deletions

View file

@ -1,5 +1,4 @@
class Color < ApplicationRecord class Color < ApplicationRecord
translates # TODO: Remove once we're all done with translations!
has_many :pet_types has_many :pet_types
scope :alphabetical, -> { order(:name) } scope :alphabetical, -> { order(:name) }
@ -10,16 +9,6 @@ class Color < ApplicationRecord
validates :name, presence: true validates :name, presence: true
# Temporary writer to keep the English translation record updated, while
# primarily using the attribute on the model itself.
#
# Once this app and DTI 2020 are both comfortably off the translation system,
# we can remove this!
def name=(new_name)
globalize.write(:en, :name, new_name)
write_attribute(:name, new_name)
end
def as_json(options={}) def as_json(options={})
{id: id, name: name, human_name: human_name} {id: id, name: name, human_name: human_name}
end end

View file

@ -1,5 +1,4 @@
class Species < ApplicationRecord class Species < ApplicationRecord
translates # TODO: Remove once we're all done with translations!
has_many :pet_types has_many :pet_types
has_many :alt_styles has_many :alt_styles
@ -10,16 +9,6 @@ class Species < ApplicationRecord
joins(:pet_types).where(pt[:body_id].eq(body_id)).limit(1) joins(:pet_types).where(pt[:body_id].eq(body_id)).limit(1)
} }
# Temporary writer to keep the English translation record updated, while
# primarily using the attribute on the model itself.
#
# Once this app and DTI 2020 are both comfortably off the translation system,
# we can remove this!
def name=(new_name)
globalize.write(:en, :name, new_name)
write_attribute(:name, new_name)
end
def as_json(options={}) def as_json(options={})
super({only: [:id, :name], methods: [:human_name]}.merge(options)) super({only: [:id, :name], methods: [:human_name]}.merge(options))
end end

View file

@ -1,6 +1,4 @@
class Zone < ActiveRecord::Base class Zone < ActiveRecord::Base
translates # TODO: Remove once we're all done with translations!
# When selecting zones that an asset occupies, we allow the zone to set # When selecting zones that an asset occupies, we allow the zone to set
# whether or not the zone is "sometimes" occupied. This is false by default. # whether or not the zone is "sometimes" occupied. This is false by default.
attr_writer :sometimes attr_writer :sometimes
@ -11,26 +9,6 @@ class Zone < ActiveRecord::Base
} }
scope :for_items, -> { where(arel_table[:type_id].gt(1)) } scope :for_items, -> { where(arel_table[:type_id].gt(1)) }
# Temporary writer to keep the English translation record updated, while
# primarily using the attribute on the model itself.
#
# Once this app and DTI 2020 are both comfortably off the translation system,
# we can remove this!
def label=(new_label)
globalize.write(:en, :label, new_label)
write_attribute(:label, new_label)
end
# Temporary writer to keep the English translation record updated, while
# primarily using the attribute on the model itself.
#
# Once this app and DTI 2020 are both comfortably off the translation system,
# we can remove this!
def plain_label=(new_plain_label)
globalize.write(:en, :plain_label, new_plain_label)
write_attribute(:plain_label, new_plain_label)
end
def as_json(options={}) def as_json(options={})
super({only: [:id, :depth, :label]}.merge(options)) super({only: [:id, :depth, :label]}.merge(options))
end end