Skip to content
Snippets Groups Projects
Unverified Commit 94718505 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

Merge branch 'master' of github.com:noesya/osuny

parents 6a93e8d3 4e66057b
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,9 @@ h1
.sidebar
background: black
footer
a
padding: 0.625rem 1.625rem
.sidebar-content
background-color: black
background-image: asset-url('sun.svg')
......
......@@ -57,8 +57,9 @@ class Communication::Website::Page < ApplicationRecord
dependent: :nullify
validates :title, presence: true
validate :homepage_is_published?
before_save :make_path
before_validation :make_path
after_save :update_children_paths if :saved_change_to_path?
scope :ordered, -> { order(:position) }
......@@ -93,4 +94,10 @@ class Communication::Website::Page < ApplicationRecord
def update_children_paths
children.each(&:save)
end
def homepage_is_published?
if path == '/' and !published
errors.add(:published, :home_not_published)
end
end
end
......@@ -2,7 +2,7 @@ module WithSlug
extend ActiveSupport::Concern
included do
before_validation :generate_slug, if: Proc.new { |o| o.slug.blank? }
before_validation :generate_slug, if: Proc.new { |o| o.slug.nil? }
end
protected
......
......@@ -106,6 +106,12 @@ en:
text: Text
title: Title
website: Website
errors:
models:
communication/website/page:
attributes:
published:
home_not_published: must be checked. Homepage has to be published.
enums:
communication/website/menu/item:
kind:
......
......@@ -106,6 +106,12 @@ fr:
text: Texte
title: Titre
website: Site Web
errors:
models:
communication/website/page:
attributes:
published:
home_not_published: doit être coché. La page d'accueil doit être publiée.
enums:
communication/website/menu/item:
kind:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment