Code

Removed generation of change note from "sendmessage" in roundupdb.py.
[roundup.git] / roundup / roundupdb.py
index c0b6201294c8e625cdf43793efbb3de71da3488d..a359c58eaee7d5bff0db3100e9818f8fa822adc2 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: roundupdb.py,v 1.25 2001-11-30 20:28:10 rochecompaan Exp $
+# $Id: roundupdb.py,v 1.26 2001-12-05 14:26:44 rochecompaan Exp $
 
 __doc__ = """
 Extending hyperdb with types specific to issue-tracking.
@@ -268,7 +268,7 @@ class IssueClass(Class):
         appended to the "messages" field of the specified issue.
         """
 
-    def sendmessage(self, nodeid, msgid, oldvalues):
+    def sendmessage(self, nodeid, msgid):
         """Send a message to the members of an issue's nosy list.
 
         The message is sent only to users on the nosy list who are not
@@ -310,19 +310,8 @@ class IssueClass(Class):
         if rlen == len(recipients):
             return
 
-        # get the change note
-        if oldvalues:
-            change_note = self.generateChangeNote(nodeid, oldvalues)
-        else:
-            change_note = ''
-
-        # add the change note to the message content
-        content = self.db.msg.get(msgid, 'content')
-        content += change_note
-
         # update the message's recipients list
         self.db.msg.set(msgid, recipients=recipients)
-        self.db.msg.setcontent('msg', msgid, content)
 
         # send an email to the people who missed out
         sendto = [self.db.user.get(i, 'address') for i in recipients]
@@ -346,14 +335,14 @@ class IssueClass(Class):
             m.append(self.email_signature(nodeid, msgid))
 
         # add author information
-        if oldvalues:
-            m.append("%s%s added the comment:"%(authname, authaddr))
-        else:
+        if len(self.get(nodeid,'messages')) == 1:
             m.append("New submission from %s%s:"%(authname, authaddr))
+        else:
+            m.append("%s%s added the comment:"%(authname, authaddr))
         m.append('')
 
         # add the content
-        m.append(content)
+        m.append(self.db.msg.get(msgid, 'content'))
 
         # put in roundup's signature
         if self.EMAIL_SIGNATURE_POSITION == 'bottom':
@@ -426,7 +415,7 @@ class IssueClass(Class):
         line = '_' * max(len(web), len(email))
         return '%s\n%s\n%s\n%s'%(line, email, web, line)
 
-    def generateChangeNote(self, nodeid, oldvalues):
+    def generateChangeNote(self, nodeid, newvalues):
         """Generate a change note that lists property changes
         """
         cn = self.classname
@@ -435,26 +424,25 @@ class IssueClass(Class):
         props = cl.getprops(protected=0)
 
         # determine what changed
-        for key in props.keys():
+        for key in newvalues.keys():
             if key in ['files','messages']: continue
-            new_value = cl.get(nodeid, key)
+            new_value = newvalues[key]
             # the old value might be non existent
             try:
-                old_value = oldvalues[key]
+                old_value = cl.get(nodeid, key)
                 if type(old_value) is type([]):
                     old_value.sort()
                     new_value.sort()
                 if old_value != new_value:
-                    changed[key] = old_value
+                    changed[key] = new_value
             except:
-                old_value = None
-                changed[key] = old_value
+                changed[key] = new_value
 
         # list the changes
         m = ['','----------']
-        for propname, oldvalue in changed.items():
+        for propname, value in changed.items():
             prop = cl.properties[propname]
-            value = cl.get(nodeid, propname, None)
+            oldvalue = cl.get(nodeid, propname, None)
             change = '%s -> %s'%(oldvalue, value)
             if isinstance(prop, hyperdb.Link):
                 link = self.db.classes[prop.classname]
@@ -472,10 +460,10 @@ class IssueClass(Class):
             elif isinstance(prop, hyperdb.Multilink):
                 change = ''
                 if value is None: value = []
+                if oldvalue is None: oldvalue = []
                 l = []
                 link = self.db.classes[prop.classname]
                 key = link.labelprop(default_to_id=1)
-                if oldvalue is None: oldvalue = []
                 # check for additions
                 for entry in value:
                     if entry in oldvalue: continue
@@ -500,6 +488,10 @@ class IssueClass(Class):
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.25  2001/11/30 20:28:10  rochecompaan
+# Property changes are now completely traceable, whether changes are
+# made through the web or by email
+#
 # Revision 1.24  2001/11/30 11:29:04  rochecompaan
 # Property changes are now listed in emails generated by Roundup
 #