From 8eec8ade841fcfbaeba1b00ab57251a7a0ed5e30 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Tue, 4 Jan 2022 15:51:48 +0100
Subject: [PATCH] force

---
 .../website/categories_controller.rb          |  2 +-
 .../communication/website/pages_controller.rb |  2 +-
 .../communication/website/posts_controller.rb |  2 +-
 .../communication/websites_controller.rb      |  2 +-
 .../website/with_batch_publication.rb         | 67 -------------------
 app/models/research/journal/article.rb        |  6 --
 6 files changed, 4 insertions(+), 77 deletions(-)
 delete mode 100644 app/models/communication/website/with_batch_publication.rb

diff --git a/app/controllers/admin/communication/website/categories_controller.rb b/app/controllers/admin/communication/website/categories_controller.rb
index 8e0892e10..7e6621248 100644
--- a/app/controllers/admin/communication/website/categories_controller.rb
+++ b/app/controllers/admin/communication/website/categories_controller.rb
@@ -37,7 +37,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication
   end
 
   def publish
-    @category.force_publish!
+    @category.sync_with_git
     redirect_to admin_communication_website_category_path(@category), notice: t('admin.will_be_published_html', model: @category.to_s)
   end
 
diff --git a/app/controllers/admin/communication/website/pages_controller.rb b/app/controllers/admin/communication/website/pages_controller.rb
index cc708bb2a..0d8d8f8f3 100644
--- a/app/controllers/admin/communication/website/pages_controller.rb
+++ b/app/controllers/admin/communication/website/pages_controller.rb
@@ -33,7 +33,7 @@ class Admin::Communication::Website::PagesController < Admin::Communication::Web
   end
 
   def publish
-    @page.force_publish!
+    @page.sync_with_git
     redirect_to admin_communication_website_page_path(@page), notice: t('admin.will_be_published_html', model: @page.to_s)
   end
 
diff --git a/app/controllers/admin/communication/website/posts_controller.rb b/app/controllers/admin/communication/website/posts_controller.rb
index e680a59b7..d337f5968 100644
--- a/app/controllers/admin/communication/website/posts_controller.rb
+++ b/app/controllers/admin/communication/website/posts_controller.rb
@@ -11,7 +11,7 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web
   end
 
   def publish
-    @post.force_publish!
+    @post.sync_with_git
     redirect_to admin_communication_website_post_path(@post), notice: t('admin.will_be_published_html', model: @post.to_s)
   end
 
diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb
index 540b9821d..54af5d9df 100644
--- a/app/controllers/admin/communication/websites_controller.rb
+++ b/app/controllers/admin/communication/websites_controller.rb
@@ -34,7 +34,7 @@ class Admin::Communication::WebsitesController < Admin::Communication::Applicati
   end
 
   def publish
-    @website.force_publish!
+    @website.sync_with_git
     redirect_to admin_communication_website_path(@website), notice: t('admin.will_be_published_html', model: @website.to_s)
   end
 
diff --git a/app/models/communication/website/with_batch_publication.rb b/app/models/communication/website/with_batch_publication.rb
deleted file mode 100644
index 29149aff7..000000000
--- a/app/models/communication/website/with_batch_publication.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-module Communication::Website::WithBatchPublication
-  extend ActiveSupport::Concern
-
-  included do
-    def force_publish!
-      commit_files_in_batch github_files,
-                            "[Website] Batch update from import"
-    end
-    handle_asynchronously :force_publish!, queue: 'default'
-
-    def publish_members!
-      commit_files_in_batch github_files.where(about_type: "Administration::Member"),
-                            "[Member] Batch update from import"
-    end
-
-    def publish_categories!
-      commit_files_in_batch github_files.where(about_type: "Communication::Website::Category"),
-                            "[Category] Batch update from import"
-    end
-
-    def publish_pages!
-      commit_files_in_batch github_files.where(about_type: "Communication::Website::Page"),
-                            "[Page] Batch update from import"
-    end
-
-    def publish_posts!
-      commit_files_in_batch github_files.where(about_type: "Communication::Website::Post"),
-                            "[Post] Batch update from import"
-    end
-
-    def publish_menus!
-      commit_files_in_batch github_files.where(about_type: "Communication::Website::Menu"),
-                            "[Menu] Batch update from import"
-    end
-
-    def publish_school!
-      commit_files_in_batch github_files.where(about_type: [
-                              "Education::School",
-                              "Education::Program",
-                              "Administration::Member"
-                            ]),
-                            "[Education School/Program/Teacher] Batch update from import"
-    end
-
-    def publish_journal!
-      commit_files_in_batch github_files.where(about_type: [
-                              "Research::Journal",
-                              "Research::Journal::Article",
-                              "Research::Journal::Volume",
-                              "Administration::Member"
-                            ]),
-                            "[Research Journal/Article/Volume/Researcher] Batch update from import"
-    end
-
-    protected
-
-    def commit_files_in_batch(files, commit_message)
-      files.find_each { |file| file.add_to_batch(github) }
-      if github.commit_batch(commit_message)
-        files.find_each { |file|
-          file.update_column :github_path, file.manifest_data[:generated_path].call(file)
-        }
-      end
-    end
-  end
-
-end
diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb
index 479903a0a..cc03d5896 100644
--- a/app/models/research/journal/article.rb
+++ b/app/models/research/journal/article.rb
@@ -59,10 +59,4 @@ class Research::Journal::Article < ApplicationRecord
   def to_s
     "#{ title }"
   end
-
-  private
-
-  def update_researchers
-    researchers.each(&:force_publish!)
-  end
 end
-- 
GitLab