bodhi/controllers.py | 9 +++++++++
bodhi/model.py | 4 ++--
bodhi/tests/test_controllers.py | 18 ++++++++++++++++++
3 files changed, 29 insertions(+), 2 deletions(-)
New commits:
commit 86ec2fb28d15c2fc76866924a84f1380221948d6
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Oct 26 19:02:03 2011 -0400
Implement a new URL scheme: /updates/<ID>/<build nvrs>
This improves our previous URL structure in that no matter how an update is
edited, the URL will still take us to that specific update, while at the same
time keeping the builds on the end so people know what packages they update is
for.
Based on the the discussion on the Fedora devel list:
https://lists.fedoraproject.org/pipermail/devel/2011-October/158770.html
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index c9bd3a9..f5c0030 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -1158,6 +1158,7 @@ class Root(controllers.RootController):
/Package.name
/PackageUpdate.title
+ /PackageUpdate.updateid/*
/PackageBuild.nvr
/Release.name
/Release.name/PackageUpdate.update_id
@@ -1173,6 +1174,14 @@ class Root(controllers.RootController):
query = []
form = identity.current.anonymous and self.comment_captcha_form \
or self.comment_form
+
+ # /PackageUpdate.updateid/*
+ if args:
+ update = PackageUpdate.select(PackageUpdate.q.updateid)
+ if update.count():
+ return dict(tg_template='bodhi.templates.show',
+ update=update[0], comment_form=form)
+
# /Package.name
if len(args) == 1:
try:
diff --git a/bodhi/model.py b/bodhi/model.py
index f5594b9..6e435d5 100644
--- a/bodhi/model.py
+++ b/bodhi/model.py
@@ -668,9 +668,9 @@ class PackageUpdate(SQLObject):
def get_url(self, show_builds=False):
""" Return the relative URL to this update """
path = ['/']
- if self.updateid and not show_builds:
- #path.append(self.release.name)
+ if self.updateid:
path.append(self.updateid)
+ path.append(self.title)
else:
path.append(self.title)
return join(*path)
diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py
index cf2b241..111842b 100644
--- a/bodhi/tests/test_controllers.py
+++ b/bodhi/tests/test_controllers.py
@@ -2865,3 +2865,21 @@ class TestControllers(testutil.DBTest):
self.save_update(params, session)
logs = testutil.get_log()
assert 'Error: You must supply details for this update' in logs
+
+ def test_new_updateid_url(self):
+ session = login()
+ create_release()
+ params = {
+ 'builds' : 'TurboGears-1.0.2.2-2.fc7',
+ 'release' : 'Fedora 7',
+ 'type_' : 'enhancement',
+ 'bugs' : '1234',
+ 'notes' : 'notes go here',
+ }
+ self.save_update(params, session)
+ up = PackageUpdate.byTitle(params['builds'])
+ up.assign_id()
+ testutil.create_request('/updates/' + up.updateid)
+ assert 'notes go here' in cherrypy.response.body[0]
+ testutil.create_request('/updates/%s/%s' % (up.updateid, up.title))
+ assert 'notes go here' in cherrypy.response.body[0]