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

Merge branch 'master' of github.com:noesya/osuny

parents b9f1a496 b7559f28
No related branches found
Tags v3.1.5
No related merge requests found
......@@ -44,13 +44,13 @@ class Communication::Website::Imported::Page < ApplicationRecord
belongs_to :page,
class_name: 'Communication::Website::Page',
optional: true
alias_attribute :generated_object, :category
alias_attribute :generated_object, :page
belongs_to :featured_medium,
class_name: 'Communication::Website::Imported::Medium',
optional: true
before_validation :sync
after_save :sync_attachments
after_commit :sync_attachments, on: [:create, :update]
default_scope { order(:path) }
......@@ -84,7 +84,7 @@ class Communication::Website::Imported::Page < ApplicationRecord
# Continue only if there are remote changes
# Don't touch if there are local changes (page.updated_at > updated_at)
# Don't touch if there are no remote changes (page.updated_at == updated_at)
# return unless updated_at > page.updated_at
return unless updated_at > page.updated_at
end
puts "Update page #{page.id}"
sanitized_title = Wordpress.clean_string self.title.to_s
......@@ -97,6 +97,7 @@ class Communication::Website::Imported::Page < ApplicationRecord
end
def sync_attachments
return unless updated_at > page.updated_at
if featured_medium.present?
unless featured_medium.file.attached? && featured_medium.file.blob.persisted?
featured_medium.load_remote_file!
......
......@@ -48,7 +48,7 @@ class Communication::Website::Imported::Post < ApplicationRecord
optional: true
before_validation :sync
after_save :sync_attachments
after_commit :sync_attachments, on: [:create, :update]
default_scope { order(path: :desc) }
......@@ -82,7 +82,7 @@ class Communication::Website::Imported::Post < ApplicationRecord
# Continue only if there are remote changes
# Don't touch if there are local changes (post.updated_at > updated_at)
# Don't touch if there are no remote changes (post.updated_at == updated_at)
# return unless updated_at > post.updated_at
return unless updated_at > post.updated_at
end
puts "Update post #{post.id}"
sanitized_title = Wordpress.clean_string self.title.to_s
......@@ -98,6 +98,7 @@ class Communication::Website::Imported::Post < ApplicationRecord
end
def sync_attachments
return unless updated_at > post.updated_at
if featured_medium.present?
unless featured_medium.file.attached? && featured_medium.file.blob.persisted?
featured_medium.load_remote_file!
......
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