app/models/website_section.rb in knitkit-2.1.15 vs app/models/website_section.rb in knitkit-3.0.0
- old
+ new
@@ -21,11 +21,11 @@
has_many :website_section_contents, :dependent => :destroy
has_many :contents, :through => :website_section_contents
validates :title, :presence => {:message => 'Title cannot be blank'}
validates_uniqueness_of :permalink, :scope => [:website_id, :parent_id]
- validates_uniqueness_of :internal_identifier, :scope => :website_id, :case_sensitive => false
+ validates_uniqueness_of :internal_identifier, :scope => [:website_id, :parent_id], :case_sensitive => false
KNIT_KIT_ROOT = Knitkit::Engine.root.to_s
WEBSITE_SECTIONS_TEMP_LAYOUT_PATH = "#{Knitkit::Engine.root.to_s}/app/views/knitkit/website_sections"
@@types = ['Page']
@@ -36,10 +36,14 @@
@@types << type
@@types.uniq!
end
end
+ def is_blog?
+ self.is_a?(Blog) || self.attributes['type'] == 'Blog'
+ end
+
def secure
capability = self.add_capability(:view)
roles = ['admin', 'website_author', self.website.website_role_iid]
roles.each do |role|
role = SecurityRole.find_by_internal_identifier(role)
@@ -80,9 +84,13 @@
read_attribute(:type) || 'Page'
end
def is_section?
['Page', 'Blog'].include? type
+ end
+
+ def display_in_menu?
+ self.in_menu
end
def is_secured?
self.protected_with_capability?('view')
end