Просмотр исходного кода

Fixed example content creation

sh4nks 11 лет назад
Родитель
Сommit
6f30c4735c
1 измененных файлов с 10 добавлено и 6 удалено
  1. 10 6
      manage.py

+ 10 - 6
manage.py

@@ -175,12 +175,13 @@ def createall():
         user.secondary_groups.append(groups[u-1])
         user.primary_group_id = u
         db.session.add(user)
+        db.session.commit()
 
     # create 2 categories
     for i in range(1, 3):
         category_title = "Test Category %s" % i
         category = Forum(is_category=True, title=category_title,
-                            description="Test Description")
+                         description="Test Description")
         db.session.add(category)
 
         # create 2 forums in each category
@@ -192,22 +193,25 @@ def createall():
             forum = Forum(title=forum_title, description="Test Description",
                           parent_id=i)
             db.session.add(forum)
+        db.session.commit()
 
     # create 1 topic in each forum
     for k in [2, 3, 5, 6]:  # Forum ids are not sequential because categories.
         topic = Topic()
-        topic.first_post = Post()
+        first_post = Post()
 
         topic.title = "Test Title %s" % k
         topic.user_id = 1
         topic.forum_id = k
-        topic.first_post.content = "Test Content"
-        topic.first_post.user_id = 1
-        topic.first_post.topic_id = k
-
         db.session.add(topic)
         db.session.commit()
 
+        first_post.content = "Test Content"
+        first_post.user_id = 1
+        first_post.topic_id = topic.id
+        db.session.add(first_post)
+        db.session.commit()
+
         # Invalidate relevant caches
         topic.invalidate_cache()
         topic.forum.invalidate_cache()