Skip to content
Snippets Groups Projects
Commit 8e461d46 authored by pabois's avatar pabois
Browse files

cleanup pages

parent 51914701
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,6 @@ class Admin::Communication::Website::PagesController < Admin::Communication::Web
end
def update
byebug
if @page.update(page_params)
redirect_to admin_communication_website_page_path(@page), notice: t('admin.successfully_updated_html', model: @page.to_s)
else
......
......@@ -63,7 +63,6 @@ class Communication::Website::Page < ApplicationRecord
dependent: :nullify
validates :title, presence: true
validate :homepage_is_published?
before_validation :make_path
after_save :update_children_paths if :saved_change_to_path?
......@@ -91,10 +90,6 @@ class Communication::Website::Page < ApplicationRecord
"#{ title }"
end
def is_homepage?
path == '/'
end
protected
def make_path
......@@ -105,9 +100,5 @@ class Communication::Website::Page < ApplicationRecord
children.each(&:save)
end
def homepage_is_published?
if is_homepage? and !published
errors.add(:published, :home_not_published)
end
end
end
......@@ -5,7 +5,6 @@ module WithSlug
validates :slug,
uniqueness: { scope: :university_id }
validates :slug,
format: { with: /\A[a-z0-9\-]+\z/, message: "ne peut contenir que des lettres minuscules, des chiffres et des traits d'union." },
allow_blank: true
format: { with: /\A[a-z0-9\-]+\z/, message: I18n.t('slug_error') }
end
end
---
<% if @page.is_homepage? %>
layout: home
<% end %>
title: "<%= @page.title %>"
permalink: "<%= @page.path %>"
identifier: "<%= @page.id %>"
......
......@@ -113,19 +113,9 @@ 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:
blank: Title
page: Page
url: URL
simple_form:
hints:
communication_website_page:
slug: Leave empty for home page
......@@ -113,19 +113,9 @@ 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:
blank: Titre intermédiaire
page: Page
url: URL
simple_form:
hints:
communication_website_page:
slug: Laisser vide pour la page d'accueil du site
......@@ -119,6 +119,7 @@ en:
simple_form_password_with_hints:
test_chars: "%{min_length} characters min."
show: Show
slug_error: can only contain downcase letters, numbers, and dashes.
terms_of_service: Terms of service
terms_of_service_url: https://osuny.org/conditions-d-utilisation
time:
......
......@@ -119,6 +119,7 @@ fr:
simple_form_password_with_hints:
test_chars: "%{min_length} caractères min."
show: Voir
slug_error: ne peut contenir que des lettres minuscules, des chiffres et des traits d'union.
terms_of_service: Conditions d'utilisation
terms_of_service_url: https://osuny.org/conditions-d-utilisation
time:
......
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