feat: Added portal logo and the updated the JSON (#4996)

This commit is contained in:
Tejaswini Chile
2022-07-11 12:43:24 +05:30
committed by GitHub
parent 9d4b77533e
commit 23ac1c0334
10 changed files with 101 additions and 11 deletions

View File

@@ -61,6 +61,7 @@ class Category < ApplicationRecord
validates :account_id, presence: true
validates :slug, presence: true
validates :name, presence: true
validate :allowed_locales
validates :locale, uniqueness: { scope: %i[slug portal_id],
message: 'should be unique in the category and portal' }
accepts_nested_attributes_for :related_categories
@@ -80,4 +81,14 @@ class Category < ApplicationRecord
def ensure_account_id
self.account_id = portal&.account_id
end
def allowed_locales
return if portal.blank?
allowed_locales = portal.config['allowed_locales']
return true if allowed_locales.include?(locale)
errors.add(:locale, "#{locale} of category is not part of portal's #{allowed_locales}.")
end
end