cfbe: API: fix editing a bug's target
authorChris Ball <cjb@laptop.org>
Mon, 6 Sep 2010 23:04:19 +0000 (19:04 -0400)
committerChris Ball <cjb@laptop.org>
Tue, 7 Sep 2010 15:00:57 +0000 (11:00 -0400)
interfaces/web/web.py

index 44bdef17893f17aca189d814f22345ea77cc557f..a99758cd174de6dc42c7cf9cf3500fb469d528ac 100644 (file)
@@ -7,6 +7,7 @@ import cherrypy
 from libbe import storage
 from libbe import bugdir
 from libbe.command.depend import get_blocked_by, get_blocks
+from libbe.command.target import add_target, remove_target
 from libbe.command.target import bug_from_target_summary, bug_target
 from libbe.command.util import bug_comment_from_user_id
 from libbe.storage.util import settings_object
@@ -180,10 +181,18 @@ class WebInterface:
             bug.summary = summary
         else:
             bug.status = status if status != 'None' else None
-            bug.target = target if target != 'None' else None
             bug.assigned = assignee if assignee != 'None' else None
             bug.severity = severity if severity != 'None' else None
             
+        if target:
+            current_target = bug_target(self.bd, bug)
+            if current_target:
+                remove_target(self.bd, bug)
+                if target != "None":
+                    add_target(self.bd, bug, target)
+            else:
+                add_target(self.bd, bug, target)
+
         bug.save()
 
         raise cherrypy.HTTPRedirect(