From 500db59afa9f52b3fd7370460f5c30d4e2eddf0e Mon Sep 17 00:00:00 2001
From: Benjamin Bach tags to imports that dont have them
---
blog/management/commands/wordpress_to_wagtail.py | 8 +++++++-
blog/tests.py | 4 ++++
example_export.xml | 2 +-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/blog/management/commands/wordpress_to_wagtail.py b/blog/management/commands/wordpress_to_wagtail.py
index ec52f01..d54aa01 100755
--- a/blog/management/commands/wordpress_to_wagtail.py
+++ b/blog/management/commands/wordpress_to_wagtail.py
@@ -1,4 +1,5 @@
from base64 import b64encode
+
from datetime import datetime
try:
import html
@@ -339,9 +340,14 @@ def create_blog_pages(self, posts, blog_index, *args, **options):
description = post.get('description')
if description:
description = self.convert_html_entities(description)
- body = linebreaks(post.get('content'))
+
+ body = post.get('content')
+ if not " " in body:
+ body = linebreaks(body)
+
# get image info from content and create image objects
body = self.create_images_from_urls_in_content(body)
+
# author/user data
author = post.get('author')
user = self.create_user(author)
diff --git a/blog/tests.py b/blog/tests.py
index 9b5273a..9184f34 100644
--- a/blog/tests.py
+++ b/blog/tests.py
@@ -209,6 +209,10 @@ def test_import_xml(self):
self.assertEqual(child_category.slug, "cheat-sheets")
self.assertEqual(parent_category.slug, "marketing-2")
+ # Assert that tags were added to the post that didn't contain them
+ page = BlogPage.objects.filter(slug='asa-releases-2013-economic-analysis-of-staffing-industry-trends').get()
+ self.assertEqual(page.body, " The American Staffing Association has released its 2013 economic analysis,\"Navigating the 1% Economy.\" Written by ASA chief operating officer Steven P. Berchem, CSP, the report takes an in-depth look at recent staffing employment trends and what these suggest about the current economic environment and future labor market conditions.