diff --git a/app/assets/stylesheets/admin/styles.sass b/app/assets/stylesheets/admin/styles.sass index 8178a52174984b4940d2e979626a7654a75006b2..87493f3e224957452650506c2a787f669c4c23c6 100644 --- a/app/assets/stylesheets/admin/styles.sass +++ b/app/assets/stylesheets/admin/styles.sass @@ -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') diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 215e1ea260d8dd91290f311ba5059f43cec0a629..1afcade4ae9774d920c3bcc906a86f0bd5f4bf2a 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -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 diff --git a/app/models/concerns/with_slug.rb b/app/models/concerns/with_slug.rb index cf2785e4cb8457c0e4e23406dbe359d861b9fafa..96fe49fdba3c3746fbfd6f10f0bc2f8505ceb1ea 100644 --- a/app/models/concerns/with_slug.rb +++ b/app/models/concerns/with_slug.rb @@ -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 diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 1b28d20a7503f85c418c29f529f87e31167b0eca..84201c8979bd8ef9cf7620272086eb7400eaf476 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -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: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 8a117d0fff16274e00e1d5a8392a44dc9f5275ec..36736beac62daa2d484ab948bafaf9d60c99422b 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -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: