app/models/page.rb in locomotive_cms-0.0.2.9 vs app/models/page.rb in locomotive_cms-0.0.3.1

- old
+ new

@@ -31,10 +31,11 @@ ## named scopes ## named_scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb named_scope :index, :where => { :slug => 'index', :depth => 0, :published => true } named_scope :not_found, :where => { :slug => '404', :depth => 0, :published => true } + named_scope :published, :where => { :published => true } ## behaviours ## liquify_template :joined_parts ## methods ## @@ -45,10 +46,14 @@ def not_found? self.slug == '404' && self.depth.to_i == 0 end + def index_or_not_found? + self.index? || self.not_found? + end + def fullpath(force = false) if read_attribute(:fullpath).present? && !force return read_attribute(:fullpath) end @@ -77,11 +82,13 @@ def do_not_remove_index_and_404_pages return if (self.site rescue nil).nil? if self.index? || self.not_found? - raise I18n.t('errors.messages.protected_page') + self.errors[:base] << I18n.t('errors.messages.protected_page') end + + self.errors.empty? end def normalize_slug self.slug = self.title.clone if self.slug.blank? && self.title.present? self.slug.slugify!(:without_extension => true) if self.slug.present? \ No newline at end of file