app/models/effective/page.rb in effective_pages-3.11.0 vs app/models/effective/page.rb in effective_pages-3.12.0

- old
+ new

@@ -17,23 +17,25 @@ belongs_to :menu_parent, class_name: 'Effective::Page', optional: true, touch: true, counter_cache: :menu_children_count has_many :menu_children, -> { Effective::Page.menuable }, class_name: 'Effective::Page', foreign_key: :menu_parent_id, inverse_of: :menu_parent - acts_as_role_restricted - acts_as_paginable if respond_to?(:acts_as_paginable) # Effective Resources + acts_as_role_restricted if respond_to?(:acts_as_role_restricted) + acts_as_paginable + acts_as_published acts_as_slugged acts_as_tagged has_many_rich_texts - log_changes if respond_to?(:log_changes) effective_resource do title :string meta_description :string - draft :boolean + published_start_at :datetime + published_end_at :datetime + legacy_draft :boolean # No longer used. To be removed. layout :string template :string slug :string @@ -66,13 +68,10 @@ base = base.includes(:pg_search_document) if defined?(PgSearch) base } scope :deep_menuable, -> { includes(:menu_parent, menu_children: [:menu_parent, :menu_children]) } - - scope :draft, -> { where(draft: true) } - scope :published, -> { where(draft: false) } scope :sorted, -> { order(:title) } scope :on_menu, -> { where(menu: true) } scope :except_home, -> { where.not(title: 'Home') } @@ -152,24 +151,20 @@ def sidebar rich_text_sidebar end - def published? - !draft? - end - # Returns a duplicated post object, or throws an exception def duplicate Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page| page.title = page.title + ' (Copy)' page.slug = page.slug + '-copy' rich_texts.each do |rt| page.send("rich_text_#{rt.name}=", rt.body) end - page.draft = true + page.assign_attributes(published_start_at: nil, published_end_at: nil) end end def duplicate! duplicate.tap { |page| page.save! }