Skip to content
Browse files

Bugfix: migrate all topics/posts - get_or_create is a bad idea ;)

  • Loading branch information...
1 parent 949ee99 commit 51685b293f6c986e8e15ade6e144f6e7570ab47e @jedie committed
Showing with 37 additions and 21 deletions.
  1. +37 −21 django_phpBB3/management/commands/phpbb2djangobb.py
View
58 django_phpBB3/management/commands/phpbb2djangobb.py
@@ -70,6 +70,10 @@ class Command(BaseCommand):
def handle(self, *args, **options):
+# self.update_topic_stats()
+# self.update_forum_stats()
+# sys.exit()
+
# disable DjangoBB signals for speedup
post_save.disconnect(djangobb_signals.post_saved, sender=Post, dispatch_uid='djangobb_post_save')
post_save.disconnect(djangobb_signals.topic_saved, sender=Topic, dispatch_uid='djangobb_topic_save')
@@ -278,21 +282,35 @@ def migrate_topic(self, user_dict, forum_dict):
else:
sticky = False
- obj, created = Topic.objects.get_or_create(
+ obj = Topic.objects.create(
forum=forum,
user=user,
name=topic.title,
- defaults={
- "created": topic.create_datetime(),
- "updated": topic.last_post_datetime(),
- "views": topic.views,
- "sticky": sticky,
- "closed": topic.locked(),
- #"subscribers":, # FIXME: ForumWatch / TopicWatch models are unsupported
- "post_count": topic.replies_real,
- "last_post": None, # will be set in migrate_posts()
- }
+ created=topic.create_datetime(),
+ updated=topic.last_post_datetime(),
+ views=topic.views,
+ sticky=sticky,
+ closed=topic.locked(),
+ #subscribers=, # FIXME: ForumWatch / TopicWatch models are unsupported
+ post_count=topic.replies_real,
+ last_post=None, # will be set in migrate_posts()
)
+
+# obj, created = Topic.objects.get_or_create(
+# forum=forum,
+# user=user,
+# name=topic.title,
+# defaults={
+# "created": topic.create_datetime(),
+# "updated": topic.last_post_datetime(),
+# "views": topic.views,
+# "sticky": sticky,
+# "closed": topic.locked(),
+# #"subscribers":, # FIXME: ForumWatch / TopicWatch models are unsupported
+# "post_count": topic.replies_real,
+# "last_post": None, # will be set in migrate_posts()
+# }
+# )
# if created:
# self.stdout.write("\tTopic '%s' created.\n" % obj)
# else:
@@ -332,18 +350,16 @@ def migrate_posts(self, user_dict, topic_dict):
updated = None
updated_by = None
- obj, created = Post.objects.get_or_create(
+ Post.objects.create(
topic=topic,
user=user,
- defaults={
- "created": phpbb_post.create_datetime(),
- "updated": updated,
- "updated_by": updated_by,
- "markup": "bbcode",
- "body": phpbb_post.text,
- #"body_html": html, # would be generated in save()
- "user_ip": phpbb_post.poster_ip,
- }
+ created=phpbb_post.create_datetime(),
+ updated=updated,
+ updated_by=updated_by,
+ markup="bbcode",
+ body=phpbb_post.text,
+ #body_html=html, # would be generated in save()
+ user_ip=phpbb_post.poster_ip,
)
duration = time.time() - start_time

0 comments on commit 51685b2

Please sign in to comment.
Something went wrong with that request. Please try again.