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

import WP authors

parent ff4333cc
No related branches found
No related tags found
No related merge requests found
......@@ -54,10 +54,10 @@ class Communication::Website::Imported::Author < ApplicationRecord
def sync
if author.nil?
self.author = Communication::Website::Author.new university: university,
website: website.website # Real website, not imported website
self.author = Administration::Member.new university: university
self.author.last_name = "Doe" # No title yet
self.author.first_name = "John" # No title yet
self.is_author = true
self.author.save
end
puts "Update author #{author.id}"
......
......@@ -60,16 +60,16 @@ class Communication::Website::Imported::Website < ApplicationRecord
def sync_authors
begin
skip_publish_callback(Communication::Website::Author)
skip_publish_callback(Administration::Member)
wordpress.authors.each do |data|
author = authors.where(university: university, identifier: data['id']).first_or_initialize
author.data = data
author.save
end
# Batch update all changes (1 query only, good for github API limits)
website.publish_authors!
website.publish_members!
ensure
set_publish_callback(Communication::Website::Author)
set_publish_callback(Administration::Member)
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