Move remote translations controller methods to the model

Now that all the code related to this model is in the same place,
changing it will be easier.
This commit is contained in:
Javi Martín
2023-01-29 16:47:52 +01:00
parent d09a47a023
commit 26cc75a891
2 changed files with 12 additions and 19 deletions

View File

@@ -41,6 +41,12 @@ class RemoteTranslation < ApplicationRecord
resource.class.translates? && resource.translations.where(locale: I18n.locale).empty?
end
def self.create_all(remote_translations_params)
remote_translations_params.each do |remote_translation_params|
create!(remote_translation_params) unless remote_translation_enqueued?(remote_translation_params)
end
end
def already_translated_resource
if remote_translatable&.translations&.where(locale: locale).present?
errors.add(:locale, :already_translated)