bodhi/controllers.py | 13 ++++++++++++- bodhi/tests/test_controllers.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-)
New commits: commit 2f21b5bf5cd74d050c38f7fccedf2d4df3c9e305 Author: Luke Macken lmacken@redhat.com Date: Thu Jan 28 06:31:28 2010 -0500
Update newly added bugs when editing an update (#386)
diff --git a/bodhi/controllers.py b/bodhi/controllers.py index 33c7734..ae224cb 100644 --- a/bodhi/controllers.py +++ b/bodhi/controllers.py @@ -29,9 +29,10 @@ from sqlobject.sqlbuilder import AND, OR
from turbogears import (controllers, expose, validate, redirect, identity, paginate, flash, error_handler, validators, config) +from turbogears import url as tg_url from turbogears.widgets import DataGrid
-from fedora.tg.util import request_format, tg_url +from fedora.tg.util import request_format from fedora.tg.controllers import login as fc_login from fedora.tg.controllers import logout as fc_logout
@@ -826,6 +827,7 @@ class Root(controllers.RootController):
# Add/remove the necessary Bugzillas try: + original_bugs = [bug.bz_id for bug in update.bugs] update.update_bugs(bugs) except xmlrpclib.Fault, f: log.exception(f) @@ -848,6 +850,15 @@ class Root(controllers.RootController): #mail.send(update.get_maintainers(), 'edited', update) mail.send(update.submitter, 'edited', update) note.insert(0, "Update successfully edited") + + # Update any newly added bugs + for bug in bugs: + if bug not in original_bugs: + log.debug("Updating newly added bug: %s" % bug) + Bugzilla.byBz_id(bug).add_comment(update, + "%s has been submitted as an update for %s.\n%s" % + (update.title, release.long_name, + config.get('base_address') + tg_url(update.get_url()))) else: # Notify security team of newly submitted security updates if update.type == 'security': diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py index 75c82a1..6f6e9c0 100644 --- a/bodhi/tests/test_controllers.py +++ b/bodhi/tests/test_controllers.py @@ -1822,3 +1822,32 @@ class TestControllers(testutil.DBTest): json = simplejson.loads(cherrypy.response.body[0]) assert json['num_items'] == 100, json['num_items'] assert len(json['updates']) == 100, len(json['updates']) + + def test_add_bugs_to_update(self): + session = login() + f7 = create_release() + params = { + 'builds' : 'TurboGears-1.0.2.2-2.fc7 python-sqlobject-0.8.2-1.fc7', + 'type_' : 'bugfix', + 'bugs' : '1', + 'cves' : '', + 'notes' : '' + } + self.save_update(params, session) + + # Add another build, for a different release + params = { + 'builds' : 'TurboGears-1.0.2.2-2.fc7 python-sqlobject-0.8.2-1.fc7', + 'release' : 'Fedora 7', + 'type_' : 'bugfix', + 'bugs' : '1 2', + 'cves' : '', + 'notes' : '', + 'edited' : 'TurboGears-1.0.2.2-2.fc7,python-sqlobject-0.8.2-1.fc7', + } + + testutil.capture_log(['bodhi.controllers', 'bodhi.util', 'bodhi.model']) + self.save_update(params, session) + logs = testutil.get_log() + assert 'Updating newly added bug: 2' in logs + assert len(PackageUpdate.byTitle(params['edited']).bugs) == 2