Improve code in items, pages, links
This commit is contained in:
1 parent
cf4a6c0b35
commit
0b71714d44
7 files changed
+37
-63
No files matched your search
+2
-7
@@ -5,15 +5,13 @@ class Item
|
||||
|
||||
field :name, :index => true
|
||||
field :full_name, :index => true
|
||||
field :parent_id, :index => true
|
||||
field :parent_name
|
||||
field :position, :type => Integer
|
||||
field :is_published, :type => Boolean, :default => true, :index => true
|
||||
field :is_published, :type => Boolean, :default => false, :index => true
|
||||
|
||||
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
|
||||
validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
|
||||
validates_uniqueness_of :name, :scope => :parent_id
|
||||
validates_presence_of :name, :full_name, :position, :is_published
|
||||
validates_presence_of :name, :full_name, :position
|
||||
|
||||
belongs_to :parent, :class_name => "Item"
|
||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
@@ -47,9 +45,6 @@ class Item
|
||||
self.position = (max_page)? max_page + 1 : 1
|
||||
end
|
||||
|
||||
# Set the parent value
|
||||
self.parent_name = Item.first(:conditions => {:id => self.parent_id} ).name rescue nil
|
||||
|
||||
# Build the full_name from the ancestors array
|
||||
full_node = self.ancestors.map{ |a| a.name }.push( self.name )
|
||||
# Remove root node if not root
|
||||
|
||||
Reference in new issue
Block a user