File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed
config/locales/communication Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ class Communication::Website::Permalink < ApplicationRecord
3838
3939 validates :path , presence : true
4040 validates :path , uniqueness : { scope : :website_id } , unless : :is_current
41+ # TODO: validate :root_path_is_reserved_for_home
4142
4243 before_validation :set_university , on : :create
4344 # We should not sync the about object whenever we do something with the permalink, as they can be changed during a sync.
@@ -187,4 +188,9 @@ def regenerate_website_hosting_config
187188 return unless website . persisted?
188189 website . regenerate_hosting_config!
189190 end
191+
192+ def root_path_is_reserved_for_home
193+ return unless path == "/"
194+ errors . add ( :path , :reserved_for_home ) unless about . about . is_a? ( Communication ::Website ::Page ::Home )
195+ end
190196end
Original file line number Diff line number Diff line change @@ -67,13 +67,9 @@ def localize_in!(language)
6767 def slug_with_ancestors_slugs
6868 about . ancestors_and_self . map { |ancestor |
6969 l10n = ancestor . localization_for ( language )
70- if l10n . nil? || l10n . try ( :draft? )
71- # If l10n is nil or draft, no slug
72- nil
73- else
74- # otherwise (published or no publication state) we return the slug
75- l10n . slug
76- end
70+ # If l10n is nil, no slug
71+ # otherwise (published or not) we return the slug
72+ l10n . try ( :slug )
7773 } . compact_blank . join ( '/' )
7874 end
7975
Original file line number Diff line number Diff line change 361361 path :
362362 blank : must be correct, as defined by RFC2396
363363 not_unique : already used by another alias
364+ reserved_for_home : is reserved for the home page
364365 models :
365366 communication/block :
366367 one : Content block
Original file line number Diff line number Diff line change 360360 path :
361361 blank : doit être un chemin correct, comme défini par la RFC2396
362362 not_unique : déjà utilisé par un autre alias
363+ reserved_for_home : est réservé pour la page d'accueil
363364 models :
364365 communication/block :
365366 one : Bloc de contenu
You can’t perform that action at this time.
0 commit comments