Skip to content

Commit

Permalink
Merge 09a2901 into d7a92b2
Browse files Browse the repository at this point in the history
  • Loading branch information
xnagpa committed Nov 27, 2019
2 parents d7a92b2 + 09a2901 commit 1f7bec4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pages/app/models/refinery/page.rb
Expand Up @@ -56,14 +56,24 @@ def should_generate_new_friendly_id?
end

validates :title, presence: true
validates :custom_slug, uniqueness: true, allow_blank: true
validate :custom_slug_siblings

before_destroy :deletable?
after_save :reposition_parts!

after_save :update_all_descendants
after_move :update_all_descendants

def custom_slug_siblings
return if !::ActiveRecord::Base.connection.column_exists?(:refinery_page_translations,
:custom_slug)
return if custom_slug.blank?
same_slug_count = siblings.where(custom_slug: custom_slug).count
errors.add(:custom_slug,
::I18n.t('refinery.admin.pages.form_advanced_options.custom_slug_error')
) unless same_slug_count.zero?
end

class << self
# Live pages are 'allowed' to be shown in the frontend of your website.
# By default, this is all pages that are not set as 'draft'.
Expand Down
1 change: 1 addition & 0 deletions pages/config/locales/en.yml
Expand Up @@ -58,6 +58,7 @@ en:
parent_page: Parent page
menu_title: Menu title
custom_slug: Custom slug
custom_slug_error: should be unique in scope of parent
show_in_menu_title: Show in menu
show_in_menu_description: Display this page in the site menu
show_in_menu_help: Uncheck this box if you want to remove a page from your site menu. This can be handy if you have a page you want to link people to directly but don&apos;t want to show the page in the menu.
Expand Down
1 change: 1 addition & 0 deletions pages/config/locales/ru.yml
Expand Up @@ -58,6 +58,7 @@ ru:
parent_page: Родительская страница
menu_title: Заголовок в меню
custom_slug: Пользовательский slug
custom_slug_error: не может повторяться на одном уровне
show_in_menu_title: Показывать в меню
show_in_menu_description: Отображать эту страницу в меню сайта
show_in_menu_help: "Снимите отметку, если вы хотите убрать страницу из меню вашего сайта."
Expand Down

0 comments on commit 1f7bec4

Please sign in to comment.