Skip to content
Snippets Groups Projects
Commit 8eec8ade authored by Arnaud Levy's avatar Arnaud Levy
Browse files

force

parent 1f48dd10
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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
......@@ -59,10 +59,4 @@ class Research::Journal::Article < ApplicationRecord
def to_s
"#{ title }"
end
private
def update_researchers
researchers.each(&:force_publish!)
end
end
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