Merge pull request #3674 from consul/remove_duplicate_translation_classes
Remove duplicate translation classes
This commit is contained in:
@@ -229,16 +229,4 @@ class Budget < ApplicationRecord
|
||||
slug.nil? || drafting?
|
||||
end
|
||||
|
||||
class Translation < Globalize::ActiveRecord::Translation
|
||||
validate :name_uniqueness_by_budget
|
||||
|
||||
def name_uniqueness_by_budget
|
||||
if Budget.joins(:translations)
|
||||
.where(name: name)
|
||||
.where.not("budget_translations.budget_id": budget_id).any?
|
||||
errors.add(:name, I18n.t("errors.messages.taken"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -39,19 +39,5 @@ class Budget
|
||||
def generate_slug?
|
||||
slug.nil? || budget.drafting?
|
||||
end
|
||||
|
||||
class Translation < Globalize::ActiveRecord::Translation
|
||||
delegate :budget, to: :globalized_model
|
||||
|
||||
validate :name_uniqueness_by_budget
|
||||
|
||||
def name_uniqueness_by_budget
|
||||
if budget.groups.joins(:translations)
|
||||
.where(name: name)
|
||||
.where.not("budget_group_translations.budget_group_id": budget_group_id).any?
|
||||
errors.add(:name, I18n.t("errors.messages.taken"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,20 +59,5 @@ class Budget
|
||||
def generate_slug?
|
||||
slug.nil? || budget.drafting?
|
||||
end
|
||||
|
||||
class Translation < Globalize::ActiveRecord::Translation
|
||||
delegate :budget, to: :globalized_model
|
||||
|
||||
validate :name_uniqueness_by_budget
|
||||
|
||||
def name_uniqueness_by_budget
|
||||
if budget.headings
|
||||
.joins(:translations)
|
||||
.where(name: name)
|
||||
.where.not("budget_heading_translations.budget_heading_id": budget_heading_id).any?
|
||||
errors.add(:name, I18n.t("errors.messages.taken"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,17 @@ class Budget
|
||||
translates :summary, touch: true
|
||||
translates :description, touch: true
|
||||
include Globalizable
|
||||
|
||||
class Translation
|
||||
before_validation :sanitize_description
|
||||
|
||||
private
|
||||
|
||||
def sanitize_description
|
||||
self.description = WYSIWYGSanitizer.new.sanitize(description)
|
||||
end
|
||||
end
|
||||
|
||||
include Sanitizable
|
||||
|
||||
belongs_to :budget
|
||||
@@ -99,15 +110,5 @@ class Budget
|
||||
def in_phase_or_later?(phase)
|
||||
PHASE_KINDS.index(kind) >= PHASE_KINDS.index(phase)
|
||||
end
|
||||
|
||||
class Translation < Globalize::ActiveRecord::Translation
|
||||
before_validation :sanitize_description
|
||||
|
||||
private
|
||||
|
||||
def sanitize_description
|
||||
self.description = WYSIWYGSanitizer.new.sanitize(description)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user