fix a couple of tiny bugs about: export, import and aloha

This commit is contained in:
did 2011-07-13 11:14:44 +02:00
parent 86259e94b7
commit 770ae3a543
5 changed files with 15 additions and 7 deletions

View File

@ -69,7 +69,7 @@ class ContentInstance
protected
def set_slug
self._slug = self.highlighted_field_value.clone if self._slug.blank? && self.highlighted_field_value.present?
self._slug = self.highlighted_field_value.dup if self._slug.blank? && self.highlighted_field_value.present?
self._slug.permalink! if self._slug.present?
end

View File

@ -63,7 +63,7 @@ module Locomotive
end
def create_target_folder
FileUtils.rmdir(@target_folder)
FileUtils.rm_rf(@target_folder)
FileUtils.mkdir_p(@target_folder)
%w(app/content_types app/views/snippets app/views/pages config data public).each do |f|
FileUtils.mkdir_p(File.join(@target_folder, f))
@ -105,13 +105,15 @@ module Locomotive
def copy_content_types
@site.content_types.each do |content_type|
attributes = self.extract_attributes(content_type, %w(name description slug order_by order_direction highlighted_field_name group_by_field_name api_enabled))
attributes = self.extract_attributes(content_type, %w(name description slug order_by order_direction group_by_field_name api_enabled))
attributes['highlighted_field_name'] = content_type.highlighted_field._alias
# custom_fields
fields = []
content_type.content_custom_fields.each do |field|
fields << {
field._alias => self.extract_attributes(field, %w(label kind hint target))
field._alias => self.extract_attributes(field, %w(label kind hint target required))
}
end
@ -166,6 +168,10 @@ module Locomotive
unless page.redirect?
attributes.delete('redirect_url')
if page.templatized?
attributes['content_type'] = page.content_type.slug
end
# add editable elements
page.editable_elements.each do |element|
next if element.disabled? || (element.from_parent && element.default_content == element.content)
@ -279,7 +285,7 @@ module Locomotive
content.send(field.safe_alias.to_sym)
end)
hash[field._alias] = value
hash[field._alias] = value unless value.blank?
end
data << { content.highlighted_field_value => hash }

View File

@ -130,6 +130,8 @@ module Locomotive
content.send("#{name}=", value)
end
content.send(:set_slug)
content.save(:validate => false)
contents_with_associations << [content, associations] unless associations.empty?

View File

@ -70,7 +70,7 @@ module Locomotive
end
def render_default_content(context)
render_all(@nodelist, context)
render_all(@nodelist, context).join(' ')
end
end

View File

@ -31,7 +31,7 @@ describe Locomotive::Export do
it 'stores the list of highlighted values in a has_many relationship' do
@team_data.first.values.first['projects'].size.should == 2
@team_data.first.values.first['projects'].should == ['Project #1', 'Project #2']
@team_data.last.values.first['projects'].should == []
@team_data.last.values.first['projects'].should be_nil
end
it 'stores a highlighted value in a has_one relationship' do