From e24a7fb556496255e044260f8f681513960dc184 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Tue, 8 Feb 2022 12:10:17 +0100
Subject: [PATCH] communication posts

---
 app/models/communication/website/structure.rb              | 2 +-
 .../website/structure/{posts.rb => communication_posts.rb} | 4 ++--
 app/models/user/with_person.rb                             | 1 +
 app/services/curator.rb                                    | 2 +-
 .../website/structure/communication_posts/static.html.erb  | 7 +++++++
 .../communication/website/structure/posts/static.html.erb  | 7 -------
 6 files changed, 12 insertions(+), 11 deletions(-)
 rename app/models/communication/website/structure/{posts.rb => communication_posts.rb} (95%)
 create mode 100644 app/views/admin/communication/website/structure/communication_posts/static.html.erb
 delete mode 100644 app/views/admin/communication/website/structure/posts/static.html.erb

diff --git a/app/models/communication/website/structure.rb b/app/models/communication/website/structure.rb
index d41a1e165..41e414f97 100644
--- a/app/models/communication/website/structure.rb
+++ b/app/models/communication/website/structure.rb
@@ -77,7 +77,7 @@ class Communication::Website::Structure < ApplicationRecord
     dependencies << Communication::Website::Structure::Administrators.find(id)
     dependencies << Communication::Website::Structure::Persons.find(id)
     dependencies << Communication::Website::Structure::Authors.find(id) if website.authors.any?
-    dependencies << Communication::Website::Structure::Posts.find(id) if website.posts.published.any?
+    dependencies << Communication::Website::Structure::CommunicationPosts.find(id) if website.posts.published.any?
 
     if website.about.is_a? Education::School
       dependencies << Communication::Website::Structure::EducationPrograms.find(id)
diff --git a/app/models/communication/website/structure/posts.rb b/app/models/communication/website/structure/communication_posts.rb
similarity index 95%
rename from app/models/communication/website/structure/posts.rb
rename to app/models/communication/website/structure/communication_posts.rb
index db91cfca0..06df6b8da 100644
--- a/app/models/communication/website/structure/posts.rb
+++ b/app/models/communication/website/structure/communication_posts.rb
@@ -46,10 +46,10 @@
 #  fk_rails_...  (communication_website_id => communication_websites.id)
 #  fk_rails_...  (university_id => universities.id)
 #
-class Communication::Website::Structure::Posts < Communication::Website::Structure
+class Communication::Website::Structure::CommunicationPosts < Communication::Website::Structure
 
   def self.polymorphic_name
-    'Communication::Website::Structure::Posts'
+    'Communication::Website::Structure::CommunicationPosts'
   end
 
   def git_path(website)
diff --git a/app/models/user/with_person.rb b/app/models/user/with_person.rb
index 5ab95727d..52e74cda9 100644
--- a/app/models/user/with_person.rb
+++ b/app/models/user/with_person.rb
@@ -17,5 +17,6 @@ module User::WithPerson
     end
     person.user = self
     person.save
+    byebug
   end
 end
diff --git a/app/services/curator.rb b/app/services/curator.rb
index cfd2b501b..8b56f1a91 100644
--- a/app/services/curator.rb
+++ b/app/services/curator.rb
@@ -22,7 +22,7 @@ class Curator
       title: page.title,
       text: text,
       slug: page.title.parameterize,
-      author: @user.author,
+      author: @user.person,
       published_at: Time.now
     )
   end
diff --git a/app/views/admin/communication/website/structure/communication_posts/static.html.erb b/app/views/admin/communication/website/structure/communication_posts/static.html.erb
new file mode 100644
index 000000000..9fd1a00a8
--- /dev/null
+++ b/app/views/admin/communication/website/structure/communication_posts/static.html.erb
@@ -0,0 +1,7 @@
+---
+title: >
+  <%= @website.structure.communication_posts_title %>
+url: <%= "/#{@website.structure.communication_posts_path}/" %>
+description: >
+  <%= prepare_text_for_static @website.structure.communication_posts_description %>
+---
diff --git a/app/views/admin/communication/website/structure/posts/static.html.erb b/app/views/admin/communication/website/structure/posts/static.html.erb
deleted file mode 100644
index d80cb9474..000000000
--- a/app/views/admin/communication/website/structure/posts/static.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
----
-title: >
-  <%= @website.structure.posts_title %>
-url: <%= "/#{@website.structure.posts_path}/" %>
-description: >
-  <%= prepare_text_for_static @website.structure.posts_description %>
----
-- 
GitLab