Commits

Nicola Ferruzzi committed 57c3c5e

Properly sets Topic and Post created date, this must be done carefully because signals may override them the first time an object is saved

Comments (0)

Files changed (1)

djangobb/djangobb_forum/management/commands/djangobb_importsmf.py

         return d
             
     def _dictFromTopic(self, topic):
+        posts = [self._dictFromPost(p) for p in topic.first_msg.thread]
         d = {'ID':topic.ID_TOPIC,
              'ID_BOARD':topic.ID_BOARD,
              'isLocked':bool(topic.locked),
              'isSticky':bool(topic.isSticky),
              'subject':unescape(topic.first_msg.subject),
-             'posts':[self._dictFromPost(p) for p in topic.first_msg.thread],
+             'posts':posts,
+             'date_created':posts[0]['date_created'],
             }
         return d
 
              'ID_MEMBER':post.ID_MEMBER, 
              'poster': {'name':post.posterName, 'email':post.posterEmail, 'ip':post.posterIP},
              'body':post.body,
-             'time':post.posterTime,
+             'date_created':post.posterTime,
             }
         return d
         
                           user=self.users[fu[0]],
                           sticky=t['isSticky'],
                           closed=t['isLocked'],
+                          created = datetime.fromtimestamp(t['date_created'])
                           )
                 to.save()
                 for m in t['posts']:
                         pass
                     else:
                         if m['ID_MEMBER'] in self.users:
-                            po = Post(topic=to, user=self.users[m['ID_MEMBER']], body=unescape(m['body']))
+                            po = Post(topic=to,
+                                      user=self.users[m['ID_MEMBER']],
+                                      body=unescape(m['body']),
+                                      )
                             po.save()
+                            po.created = datetime.fromtimestamp(m['date_created'])
+                            po.save()
+                to.updated = datetime.fromtimestamp(t['date_created'])
                 to.last_post = po
                 to.save()