[zopeorg-checkins] CVS: Products/ZopeOrg-NV/Extensions - NZOMigrate.py:1.22

Sidnei da Silva sidnei at x3ng.com.br
Thu Apr 17 17:15:28 EDT 2003


Update of /cvs-zopeorg/Products/ZopeOrg-NV/Extensions
In directory cvs.zope.org:/tmp/cvs-serv10188/Extensions

Modified Files:
	NZOMigrate.py 
Log Message:
Fixed assignement and diversion

=== Products/ZopeOrg-NV/Extensions/NZOMigrate.py 1.21 => 1.22 ===
     kw['submitter_id'] = issue.requester
     kw['modification_date'] = issue.date.ISO()
     kw['description'] = getattr(aq_base(issue), 'description', '')
+    kw['diverted'] = getattr(aq_base(issue), 'diverted', None)
     kw['title'] = getattr(aq_base(issue), 'title', '') or (kw['description'][:50] + '...')
     kw['version_info'] = ''
     kw['action_number'] = len(issue.keys()) -1
     items = issue.items()
     kw['last_issue'] = last_issue = items[-1][1]
+    items = [i[1] for i in items]
     items = items[:-1]
 
     dumper = """
@@ -103,7 +105,7 @@
     return kw, att, result
 
 def doIssueAction(issue, action, comment, user, date,
-                  assignees=None):
+                  assignees=None, diverted=None):
     """Execute an action, adding comment to the transcript."""
 
     action_number = issue.action_number = issue.action_number + 1
@@ -113,7 +115,7 @@
                   'accepted':'accept',
                   'rejected':'reject',
                   'deferred':'defer',
-                  'diverted':'comment',
+                  'diverted':'reject',
                   'pending':'request'}
 
     action = action_map.get(action.lower(), action)
@@ -157,6 +159,9 @@
 
     comment_header_str = "\n\n".join(comment_header) + "\n\n"
 
+    if diverted:
+        comment += '\nDiverted to %s' % diverted
+
     transcript.edit(issue.TRANSCRIPT_FORMAT,
                     comment_header_str
                     + comment
@@ -176,6 +181,65 @@
 
     return got
 
+def doIssueAssign(issue, assignees=None):
+    """Assign some users to the issue, adding comment to the transcript."""
+
+    action_number = issue.action_number = issue.action_number + 1
+    username = 'admin'
+
+    orig_supporters = issue.assigned_to()
+    orig_status = issue.status().split('_')[0]
+
+    comment = '(Supporters added by migration tool)'
+    action = 'assign'
+    date = DateTime()
+    
+    issue.portal_workflow.doActionFor(issue,
+                                      action,
+                                      comment=comment,
+                                      username=username,
+                                      assignees=assignees)
+
+    transcript = issue.get_transcript()
+    new_status = issue.status().split('_')[0]
+
+    comment_header = [issue._entry_header(action, username, date=date)]
+
+    if (orig_status
+        and (orig_status != 'New')
+        and (new_status != orig_status)):
+        comment_header.append(" Status: %s => %s"
+                              % (orig_status, new_status))
+
+    additions, removals = issue._supporters_diff(orig_supporters)
+    if additions or removals:
+        if additions:
+            reroster = " Supporters added: %s" % ", ".join(additions)
+            if removals:
+                reroster += "; removed: %s" % ", ".join(removals)
+        elif removals:
+            reroster = " Supporters removed: %s" % ", ".join(removals)
+        comment_header.append(reroster)
+
+    comment_header_str = "\n\n".join(comment_header) + "\n\n"
+
+    transcript.edit(issue.TRANSCRIPT_FORMAT,
+                    comment_header_str
+                    + comment
+                    + ((action_number > 1)
+                       and ("\n" + ('_' * 40) + "\n")
+                       or '')
+                    + transcript.EditableBody())
+
+    issue._notifyModified()
+    issue.reindexObject()
+    got = issue._send_update_notice(action, username,
+                                    orig_status, additions, removals,
+                                    file=None, fileid=None)
+
+    return got
+
+
 # this method came from PTK -> CMF migration script
 
 def _cleanupOwnership(ob, res, cleanup_children):
@@ -761,6 +825,8 @@
             kw['container'] = collector
             action_number = kw['action_number']
             del kw['action_number']
+            diverted = kw['diverted']
+            del kw['diverted']
             last_issue = kw['last_issue']
             del kw['last_issue']
             __traceback_info__ = kw.items()
@@ -771,11 +837,14 @@
             transcript = new_issue.get_transcript()
             transcript.edit(new_issue.TRANSCRIPT_FORMAT,
                             text)
+            doIssueAssign(new_issue, 
+                          assignees=kw['assignees'])
             doIssueAction(new_issue, action=kw['resolution'],
                           comment=getattr(last_issue, 'description'),
                           assignees=kw['assignees'],
                           user=getattr(last_issue, 'from'),
-                          date=getattr(last_issue, 'date'))
+                          date=getattr(last_issue, 'date'),
+                          diverted=diverted)
             for att in atts:
                 new_issue._add_artifact(att['id'], 'File', \
                                         att['title'], att['data'])





More information about the zopeorg-checkins mailing list