diff roundup/cgi/actions.py @ 3145:9aa9436a81e0

better edit conflict handling
author Richard Jones <richard@users.sourceforge.net>
date Sun, 13 Feb 2005 22:04:32 +0000
parents 7308c3c5a943
children 88dbe6b3d891
line wrap: on
line diff
--- a/roundup/cgi/actions.py	Sun Feb 13 21:26:41 2005 +0000
+++ b/roundup/cgi/actions.py	Sun Feb 13 22:04:32 2005 +0000
@@ -1,4 +1,4 @@
-#$Id: actions.py,v 1.43 2005-02-12 00:47:17 richard Exp $
+#$Id: actions.py,v 1.44 2005-02-13 22:04:31 richard Exp $
 
 import re, cgi, StringIO, urllib, Cookie, time, random
 
@@ -510,13 +510,23 @@
         return activity
 
     def detectCollision(self, user_activity, node_activity):
-        if user_activity:
-            return user_activity < node_activity
+        '''Check for a collision and return the list of props we edited
+        that conflict.'''
+        if user_activity < node_activity:
+            props, links = self.client.parsePropsFromForm()
+            key = (self.classname, self.nodeid)
+            # we really only collide for direct prop edit conflicts
+            return props[key].keys()
         else:
-            return 0
+            return []
 
-    def handleCollision(self):
-        self.client.template = 'collision'
+    def handleCollision(self, props):
+        message = self._('Edit Error: someone else has edited this %s (%s). '
+            'View <a target="new" href="%s%s">their changes</a> '
+            'in a new window.')%(self.classname, ', '.join(props),
+            self.classname, self.nodeid)
+        self.client.error_message.append(message)
+        return
 
     def handle(self):
         """Perform an edit of an item in the database.
@@ -525,10 +535,11 @@
 
         """
         user_activity = self.lastUserActivity()
-        if user_activity and self.detectCollision(user_activity,
-                self.lastNodeActivity()):
-            self.handleCollision()
-            return
+        if user_activity:
+            props = self.detectCollision(user_activity, self.lastNodeActivity())
+            if props:
+                self.handleCollision(props)
+                return
 
         props, links = self.client.parsePropsFromForm()
 

Roundup Issue Tracker: http://roundup-tracker.org/