Merge lp:~bac/charmworld/bundle-icon-path into lp:~juju-jitsu/charmworld/trunk

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: 417
Merged at revision: 416
Proposed branch: lp:~bac/charmworld/bundle-icon-path
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 57 lines (+7/-11)
3 files modified
charmworld/views/bundles.py (+2/-7)
charmworld/views/charms.py (+3/-3)
charmworld/views/tests/test_bundles.py (+2/-1)
To merge this branch: bzr merge lp:~bac/charmworld/bundle-icon-path
Reviewer Review Type Date Requested Status
Juju Gui Bot continuous-integration Approve
Benji York (community) Approve
Review via email: mp+190470@code.launchpad.net

Commit message

Fix path to bundle icon. Use default icon if the bundle does not supply one.

Description of the change

In the current design, all bundles are to use the default bundle icon. However, there is a bug that does not generate the correct URL and the icon shows up as broken in charmworld, witness:

http://staging.jujucharms.com/~benji/bundle/wiki/wiki

This branch fixes that branch. It also removes the condition in icon_path so that the path to the icon is returned whether the icon exists or not, which then gets redirected to the default icon.

A test was incorrectly reinforcing the wrong URL and has been fixed.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

The branch looks good. Two small observations:

The function call on line 15 of the diff would probably all fit on one line.

"id" on line 35 (which you didn't write), should be capitalized -- unless we're getting all Freudian here.

review: Approve
Revision history for this message
Juju Gui Bot (juju-gui-bot) :
review: Approve (continuous-integration)
Revision history for this message
Juju Gui Bot (juju-gui-bot) wrote :

FAILED: Autolanding.
Unapproved changes made after approval.
http://162.213.35.27:8080/job/charmworld-autoland-lxc/33/
Executed test runs:

review: Needs Fixing (continuous-integration)
Revision history for this message
Benji York (benji) wrote :

Approved again.

review: Approve
Revision history for this message
Juju Gui Bot (juju-gui-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/views/bundles.py'
2--- charmworld/views/bundles.py 2013-09-30 16:00:47 +0000
3+++ charmworld/views/bundles.py 2013-10-10 20:29:55 +0000
4@@ -75,13 +75,8 @@
5 raise
6
7 def icon_path(self, request):
8- path = None
9- if self.get_file(request.db, ICON_FN) is not None:
10- api_prefix = request.route_path(
11- 'api_3',
12- endpoint='bundle',
13- )
14- path = '/'.join([api_prefix, self.id, ICON_FN])
15+ api_prefix = request.route_path('api_3', endpoint='bundle')
16+ path = '/'.join([api_prefix, self.id, 'file', ICON_FN])
17 return path
18
19 def readme_info(self, db):
20
21=== modified file 'charmworld/views/charms.py'
22--- charmworld/views/charms.py 2013-09-04 14:03:52 +0000
23+++ charmworld/views/charms.py 2013-10-10 20:29:55 +0000
24@@ -122,9 +122,9 @@
25 icon_path = None
26 if quote_key('icon.svg') in charm.files.keys():
27 remainder = API3._get_api_id(charm) + '/file/icon.svg'
28- # If we let the route_url do the work it'll escape the ~ in the charm
29- # id for the owner. We generate the base of Thee route via route_url,
30- # but then manually tack on the known 'good' reminder for the path to
31+ # If we let the route_url do the work it'll escape the ~ in the charm
32+ # ID for the owner. We generate the base of the route via route_url,
33+ # but then manually tack on the known 'good' remainder for the path to
34 # complete.
35 icon_path = request.route_path(
36 'api_2_single',
37
38=== modified file 'charmworld/views/tests/test_bundles.py'
39--- charmworld/views/tests/test_bundles.py 2013-09-09 13:45:45 +0000
40+++ charmworld/views/tests/test_bundles.py 2013-10-10 20:29:55 +0000
41@@ -87,7 +87,7 @@
42 request = self.getRequest()
43 bundle = BundleDetail(data)
44 bundle.get_file = lambda s, x: True
45- expected = '/'.join(['/api/3/bundle', bundle.id, 'icon.svg'])
46+ expected = '/'.join(['/api/3/bundle', bundle.id, 'file', 'icon.svg'])
47 self.assertEqual(expected, bundle.icon_path(request))
48
49 def test_readme(self):
50@@ -175,6 +175,7 @@
51 self.assertEqual(None, found)
52
53 def test_personal_bundle(self):
54+ self.enable_routes()
55 basket = 'ball'
56 rev = '4'
57 bundle, bundle_data = factory.makeBundle(

Subscribers

People subscribed via source and target branches