revert 39237 since this breaks some tests.
svn path=/plone.app.discussion/trunk/; revision=39330
This commit is contained in:
parent
a2a8956d09
commit
632e167806
@ -65,10 +65,8 @@ class View(BrowserView):
|
|||||||
comment.text = reply.text
|
comment.text = reply.text
|
||||||
comment.creator = reply.Creator()
|
comment.creator = reply.Creator()
|
||||||
|
|
||||||
comment.creation_date = datetime.fromtimestamp(
|
comment.creation_date = datetime.fromtimestamp(reply.creation_date)
|
||||||
reply.creation_date)
|
comment.modification_date = datetime.fromtimestamp(reply.modification_date)
|
||||||
comment.modification_date = datetime.fromtimestamp(
|
|
||||||
reply.modification_date)
|
|
||||||
|
|
||||||
comment.reply_to = in_reply_to
|
comment.reply_to = in_reply_to
|
||||||
|
|
||||||
@ -85,10 +83,7 @@ class View(BrowserView):
|
|||||||
|
|
||||||
# migrate all talkbacks of the reply
|
# migrate all talkbacks of the reply
|
||||||
talkback = getattr( reply, 'talkback', None )
|
talkback = getattr( reply, 'talkback', None )
|
||||||
no_replies_left = migrate_replies(context,
|
no_replies_left = migrate_replies(context, new_in_reply_to, talkback.getReplies(), depth=depth+1)
|
||||||
new_in_reply_to,
|
|
||||||
talkback.getReplies(),
|
|
||||||
depth=depth+1)
|
|
||||||
if no_replies_left:
|
if no_replies_left:
|
||||||
# remove reply and talkback
|
# remove reply and talkback
|
||||||
talkback.deleteReply(reply.id)
|
talkback.deleteReply(reply.id)
|
||||||
@ -97,23 +92,17 @@ class View(BrowserView):
|
|||||||
log("%sremove %s" % (indent, reply.id))
|
log("%sremove %s" % (indent, reply.id))
|
||||||
self.total_comments_deleted += 1
|
self.total_comments_deleted += 1
|
||||||
|
|
||||||
# Return True when all comments on a certain level have been
|
# Return True when all comments on a certain level have been migrated.
|
||||||
# migrated.
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Find content
|
# Find content
|
||||||
brains = catalog.searchResults(
|
brains = catalog.searchResults(
|
||||||
object_provides='Products.CMFCore.interfaces._content.\
|
object_provides='Products.CMFCore.interfaces._content.IContentish')
|
||||||
IContentish')
|
|
||||||
log("Found %s content objects." % len(brains))
|
log("Found %s content objects." % len(brains))
|
||||||
|
|
||||||
count_discussion_items = len(
|
count_discussion_items = len(catalog.searchResults(Type='Discussion Item'))
|
||||||
catalog.searchResults(Type='Discussion Item'))
|
count_comments_pad = len(catalog.searchResults(object_provides=IComment.__identifier__))
|
||||||
count_comments_pad = len(
|
count_comments_old = len(catalog.searchResults(object_provides=IDiscussionResponse.__identifier__))
|
||||||
catalog.searchResults(object_provides=IComment.__identifier__))
|
|
||||||
count_comments_old = len(
|
|
||||||
catalog.searchResults(object_provides=IDiscussionResponse.\
|
|
||||||
__identifier__))
|
|
||||||
|
|
||||||
log("Found %s Discussion Item objects." % count_discussion_items)
|
log("Found %s Discussion Item objects." % count_discussion_items)
|
||||||
log("Found %s old discussion items." % count_comments_old)
|
log("Found %s old discussion items." % count_comments_old)
|
||||||
@ -139,16 +128,14 @@ class View(BrowserView):
|
|||||||
if replies:
|
if replies:
|
||||||
conversation = IConversation(obj)
|
conversation = IConversation(obj)
|
||||||
log("\n")
|
log("\n")
|
||||||
log("Migrate '%s' (%s)" % (obj.Title(),
|
log("Migrate '%s' (%s)" % (obj.Title(), obj.absolute_url(relative=1)))
|
||||||
obj.absolute_url(relative=1)))
|
|
||||||
migrate_replies(context, 0, replies)
|
migrate_replies(context, 0, replies)
|
||||||
obj = aq_parent(talkback)
|
obj = aq_parent(talkback)
|
||||||
obj.talkback = None
|
obj.talkback = None
|
||||||
|
|
||||||
if self.total_comments_deleted != self.total_comments_migrated:
|
if self.total_comments_deleted != self.total_comments_migrated:
|
||||||
log("Something went wrong during migration. The number of \
|
log("Something went wrong during migration. The number of migrated comments (%s)\
|
||||||
migrated comments (%s) differs from the number of deleted \
|
differs from the number of deleted comments (%s)."
|
||||||
comments (%s)."
|
|
||||||
% (self.total_comments_migrated, self.total_comments_deleted))
|
% (self.total_comments_migrated, self.total_comments_deleted))
|
||||||
if not test:
|
if not test:
|
||||||
transaction.abort()
|
transaction.abort()
|
||||||
@ -162,8 +149,7 @@ class View(BrowserView):
|
|||||||
% (self.total_comments_migrated, count_comments_old))
|
% (self.total_comments_migrated, count_comments_old))
|
||||||
|
|
||||||
if self.total_comments_migrated != count_comments_old:
|
if self.total_comments_migrated != count_comments_old:
|
||||||
log("%s comments could not be migrated."
|
log("%s comments could not be migrated." % (count_comments_old - self.total_comments_migrated))
|
||||||
% (count_comments_old - self.total_comments_migrated))
|
|
||||||
log("Please make sure your portal catalog is up-to-date.")
|
log("Please make sure your portal catalog is up-to-date.")
|
||||||
|
|
||||||
if dry_run and not test:
|
if dry_run and not test:
|
||||||
|
Loading…
Reference in New Issue
Block a user