From f0c4df9022c3207b13cfcca509c8b7db57417cb5 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Tue, 9 Apr 2013 22:13:13 -0400 Subject: hopefully really fixed the jive import issue --- askbot/management/commands/askbot_import_jive.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/askbot/management/commands/askbot_import_jive.py b/askbot/management/commands/askbot_import_jive.py index 7114378a..078c6209 100644 --- a/askbot/management/commands/askbot_import_jive.py +++ b/askbot/management/commands/askbot_import_jive.py @@ -3,6 +3,7 @@ from askbot.conf import settings as askbot_settings from askbot.utils.console import ProgressBar from askbot.utils.slug import slugify from bs4 import BeautifulSoup +from django.conf import settings as django_settings from django.core.management.base import BaseCommand, CommandError from django.db import transaction from django.forms import EmailField, ValidationError @@ -25,11 +26,7 @@ class Command(BaseCommand): def handle(self, *args, **kwargs): assert len(args) == 1, 'Dump file name is required' xml = open(args[0], 'r').read() - try: - import lxml - soup = BeautifulSoup(xml, 'lxml') - except ImportError: - soup = BeautifulSoup(xml) + soup = BeautifulSoup(xml, ['lxml', 'xml']) self.import_users(soup.find_all('user')) self.import_forums(soup.find_all('forum')) @@ -82,7 +79,8 @@ class Command(BaseCommand): title=title, body_text=body, timestamp=timestamp, - tags=tag_name + tags=tag_name, + language=django_settings.LANGUAGE_CODE ) #post answers if not question_soup.messagelist: @@ -93,7 +91,8 @@ class Command(BaseCommand): answer = user.post_answer( question=question, body_text=body, - timestamp=timestamp + timestamp=timestamp, + language=django_settings.LANGUAGE_CODE ) comments = answer_soup.find_all('message') for comment in comments: @@ -101,18 +100,15 @@ class Command(BaseCommand): user.post_comment( parent_post=answer, body_text=body, - timestamp=timestamp + timestamp=timestamp, + language=django_settings.LANGUAGE_CODE ) def parse_post(self, post): title = post.find('subject').text added_at = parse_date(post.find('creationdate').text) username = post.find('username').text - body_node = post.find('messagebody') - if body_node: - body = post.find('messagebody').text - else: - raise Exception('Rename tags to then clear the database and re-import') + body = post.find('body').text try: user = models.User.objects.get(username=username) except models.User.DoesNotExist: -- cgit v1.2.3-1-g7c22