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

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

parents c04cc20a 02587233
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,11 @@ module Communication::Website::WithSpecialPages
def create_default_special_page(type)
# Special pages have a before_validation (:on_create) callback to preset the original localization (title, slug, ...)
page = pages.where(type: type.to_s, university_id: university_id).first_or_initialize
page = Communication::Website::Page.new(
type: type.to_s,
communication_website_id: id,
university_id: university_id
)
# Ignore useless pages (not in this website)
return unless page.is_necessary_for_website?
page.save_and_sync
......
......@@ -8,7 +8,26 @@ namespace :app do
desc 'Fix things'
task fix: :environment do
special_page_types = [
"Communication::Website::Page::AdministrationLocation",
"Communication::Website::Page::Administrator",
"Communication::Website::Page::CommunicationAgendaArchive",
"Communication::Website::Page::CommunicationAgenda",
"Communication::Website::Page::CommunicationPortfolio",
"Communication::Website::Page::EducationDiploma",
"Communication::Website::Page::EducationProgram",
"Communication::Website::Page::ResearchPaper",
"Communication::Website::Page::ResearchPublication",
"Communication::Website::Page::ResearchVolume",
"Communication::Website::Page::Researcher",
"Communication::Website::Page::Teacher"
]
# On supprime toutes les pages spéciales potentiellement non nécessaires créées après migration
Communication::Website::Page.where(type: special_page_types).where('created_at > ?', 2.days.ago).each do |special_page|
next unless special_page.is_necessary_for_website?
special_page.destroy
end
end
namespace :websites do
......
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