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