Merge lp:~bac/charmworld/show-bundle-changes into lp:~juju-jitsu/charmworld/trunk

Proposed by Brad Crittenden
Status: Merged
Merged at revision: 429
Proposed branch: lp:~bac/charmworld/show-bundle-changes
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 377 lines (+63/-23)
15 files modified
charmworld/jobs/ingest.py (+4/-3)
charmworld/jobs/tests/test_ingest.py (+11/-2)
charmworld/jobs/tests/test_lp.py (+1/-1)
charmworld/migrations/versions/tests/test_migrations.py (+1/-1)
charmworld/models.py (+8/-3)
charmworld/templates/bundle.pt (+10/-0)
charmworld/templates/charm.pt (+1/-1)
charmworld/templates/recent.pt (+1/-1)
charmworld/testing/factory.py (+1/-1)
charmworld/tests/test_models.py (+11/-4)
charmworld/tests/test_search.py (+1/-1)
charmworld/views/bundles.py (+2/-0)
charmworld/views/helpers.py (+4/-4)
charmworld/views/tests/test_api.py (+5/-0)
charmworld/views/tests/test_feeds.py (+2/-1)
To merge this branch: bzr merge lp:~bac/charmworld/show-bundle-changes
Reviewer Review Type Date Requested Status
Juju-Jitsu Hackers Pending
Review via email: mp+192563@code.launchpad.net

Description of the change

Add changelog to bundle page.

https://codereview.appspot.com/16690043/

To post a comment you must log in.
Brad Crittenden (bac) wrote :
Download full text (16.0 KiB)

Reviewers: mp+192563_code.launchpad.net,

Message:
Please take a look.

Description:
Add changelog to bundle page.

https://code.launchpad.net/~bac/charmworld/show-bundle-changes/+merge/192563

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/16690043/

Affected files (+69, -23 lines):
   A [revision details]
   M charmworld/jobs/ingest.py
   M charmworld/jobs/tests/test_ingest.py
   M charmworld/jobs/tests/test_lp.py
   M charmworld/migrations/versions/tests/test_migrations.py
   M charmworld/models.py
   M charmworld/templates/bundle.pt
   M charmworld/templates/charm.pt
   M charmworld/templates/recent.pt
   M charmworld/testing/factory.py
   M charmworld/tests/test_models.py
   M charmworld/tests/test_search.py
   M charmworld/views/bundles.py
   M charmworld/views/helpers.py
   M charmworld/views/tests/test_api.py
   M charmworld/views/tests/test_feeds.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: charmworld/models.py
=== modified file 'charmworld/models.py'
--- charmworld/models.py 2013-10-23 18:52:03 +0000
+++ charmworld/models.py 2013-10-24 17:24:43 +0000
@@ -1298,6 +1298,10 @@
          'data': dict(),
          'promulgated': False,
          'branch_deleted': False,
+ 'first_change': None,
+ 'last_change': None,
+ 'changes': None,
+ 'branch_spec': None,
      }

      def __init__(self, data):
@@ -1744,7 +1748,7 @@

  def make_bundle_doc(data, owner, basket_id, bundle_name, first_change,
- last_change, changes):
+ last_change, changes, branch_spec):
      basket_name, basket_revision = basket_id.split('/')
      _id = Bundle.construct_id(owner, basket_name, bundle_name,
basket_revision)
      return {
@@ -1757,11 +1761,12 @@
          'first_change': first_change,
          'last_change': last_change,
          'changes': changes,
+ 'branch_spec': branch_spec,
      }

  def store_bundles(collection, deployer_config, owner, basket_id,
first_change,
- last_change, changes, index_client=None):
+ last_change, changes, branch_spec, index_client=None):
      """Store a basket of bundles into MongoDB and/or ElasticSearch.

      :param: collection: A db bundles collection. If None the bundles are
not
@@ -1785,7 +1790,7 @@
          data = get_flattened_deployment(deployer_config, bundle_name)
          index_data[bundle_name] = make_bundle_doc(
              data, owner, basket_id, bundle_name, first_change, last_change,
- changes)
+ changes, branch_spec)
          if collection is not None:
              collection.save(index_data[bundle_name])

Index: charmworld/jobs/ingest.py
=== modified file 'charmworld/jobs/ingest.py'
--- charmworld/jobs/ingest.py 2013-10-23 18:07:20 +0000
+++ charmworld/jobs/ingest.py 2013-10-24 17:24:43 +0000
@@ -310,10 +310,10 @@
          super(Update...

432. By Brad Crittenden on 2013-10-24

Remove broken RSS link for bundles.

Brad Crittenden (bac) wrote :
Brad Crittenden (bac) wrote :

*** Submitted:

Add changelog to bundle page.

R=benji
CC=
https://codereview.appspot.com/16690043

https://codereview.appspot.com/16690043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/jobs/ingest.py'
2--- charmworld/jobs/ingest.py 2013-10-23 18:07:20 +0000
3+++ charmworld/jobs/ingest.py 2013-10-24 19:26:47 +0000
4@@ -310,10 +310,10 @@
5 super(UpdateBundleJob, self).__init__()
6
7 def store_bundles(self, deployer_config, owner, basket_id, first_change,
8- last_change, changes):
9+ last_change, changes, branch_spec):
10 store_bundles(
11 self.db.bundles, deployer_config, owner, basket_id, first_change,
12- last_change, changes)
13+ last_change, changes, branch_spec)
14
15 @staticmethod
16 def set_basket_info(data, revno):
17@@ -347,7 +347,8 @@
18 deployer_config = self.get_deployer_config(fs, basket_data)
19 self.store_bundles(
20 deployer_config, basket_data['owner'], basket_data['name_revno'],
21- None, None, None)
22+ basket_data['first_change'], basket_data['last_change'],
23+ basket_data['changes'], basket_data['branch_spec'])
24
25
26 def _rev_info(r, branch):
27
28=== modified file 'charmworld/jobs/tests/test_ingest.py'
29--- charmworld/jobs/tests/test_ingest.py 2013-10-23 17:37:08 +0000
30+++ charmworld/jobs/tests/test_ingest.py 2013-10-24 19:26:47 +0000
31@@ -534,12 +534,16 @@
32 fs.put(deployer_config, _id=DEPLOYER_CONFIG_HASH)
33 job.store_bundles(
34 yaml.safe_load(deployer_config), basket_data['owner'],
35- basket_data['name_revno'], None, None, None)
36+ basket_data['name_revno'], None, None, None, None)
37 self.assertIsNotNone(self.db.bundles.find_one(bundle_id))
38
39 def test_job_run_stores_bundles_in_the_db(self):
40 basket_data = factory.get_payload_json(name='wordpress')
41 basket_data['name_revno'] = 'dummy'
42+ basket_data['first_change'] = None
43+ basket_data['last_change'] = None
44+ basket_data['changes'] = None
45+ basket_data['branch_spec'] = None
46 job = UpdateBundleJob()
47 job.setup(self.db)
48 with patch.object(job, 'get_deployer_config'):
49@@ -551,6 +555,10 @@
50 def test_job_run_does_not_alter_bundle_data(self):
51 basket_data = factory.get_payload_json(name='wordpress')
52 basket_data['name_revno'] = 'dummy'
53+ basket_data['first_change'] = None
54+ basket_data['last_change'] = None
55+ basket_data['changes'] = None
56+ basket_data['branch_spec'] = None
57 job = UpdateBundleJob()
58 job.setup(self.db)
59 with patch.object(job, 'get_deployer_config',
60@@ -559,7 +567,8 @@
61 with patch.object(job, 'store_bundles') as store_bundles:
62 job.run(basket_data)
63 store_bundles.assert_called_with(
64- {'foo': {}}, 'charmers', 'dummy', None, None, None)
65+ {'foo': {}}, 'charmers', 'dummy', None, None, None,
66+ None)
67
68
69 class TestUpdateCharm(MongoTestBase):
70
71=== modified file 'charmworld/jobs/tests/test_lp.py'
72--- charmworld/jobs/tests/test_lp.py 2013-10-23 21:53:17 +0000
73+++ charmworld/jobs/tests/test_lp.py 2013-10-24 19:26:47 +0000
74@@ -288,7 +288,7 @@
75 'store_data': {
76 'errors': ['entry not found'],
77 'revision': 0,
78- 'store_checked': 'lambada'
79+ 'store_checked': 'lambada',
80 },
81 'store_url': 'cs:~baz/qux/quxx-0',
82 }
83
84=== modified file 'charmworld/migrations/versions/tests/test_migrations.py'
85--- charmworld/migrations/versions/tests/test_migrations.py 2013-10-23 17:37:08 +0000
86+++ charmworld/migrations/versions/tests/test_migrations.py 2013-10-24 19:26:47 +0000
87@@ -60,7 +60,7 @@
88 owner, basket_name, bundle_name)
89 store_bundles(
90 self.db.bundles, parsed, owner, basket_id,
91- None, None, None,
92+ None, None, None, None,
93 index_client=self.index_client)
94
95 def test_bundles_are_removed_from_elastic_search(self):
96
97=== modified file 'charmworld/models.py'
98--- charmworld/models.py 2013-10-23 18:52:03 +0000
99+++ charmworld/models.py 2013-10-24 19:26:47 +0000
100@@ -1298,6 +1298,10 @@
101 'data': dict(),
102 'promulgated': False,
103 'branch_deleted': False,
104+ 'first_change': None,
105+ 'last_change': None,
106+ 'changes': None,
107+ 'branch_spec': None,
108 }
109
110 def __init__(self, data):
111@@ -1744,7 +1748,7 @@
112
113
114 def make_bundle_doc(data, owner, basket_id, bundle_name, first_change,
115- last_change, changes):
116+ last_change, changes, branch_spec):
117 basket_name, basket_revision = basket_id.split('/')
118 _id = Bundle.construct_id(owner, basket_name, bundle_name, basket_revision)
119 return {
120@@ -1757,11 +1761,12 @@
121 'first_change': first_change,
122 'last_change': last_change,
123 'changes': changes,
124+ 'branch_spec': branch_spec,
125 }
126
127
128 def store_bundles(collection, deployer_config, owner, basket_id, first_change,
129- last_change, changes, index_client=None):
130+ last_change, changes, branch_spec, index_client=None):
131 """Store a basket of bundles into MongoDB and/or ElasticSearch.
132
133 :param: collection: A db bundles collection. If None the bundles are not
134@@ -1785,7 +1790,7 @@
135 data = get_flattened_deployment(deployer_config, bundle_name)
136 index_data[bundle_name] = make_bundle_doc(
137 data, owner, basket_id, bundle_name, first_change, last_change,
138- changes)
139+ changes, branch_spec)
140 if collection is not None:
141 collection.save(index_data[bundle_name])
142
143
144=== modified file 'charmworld/templates/bundle.pt'
145--- charmworld/templates/bundle.pt 2013-10-22 22:37:03 +0000
146+++ charmworld/templates/bundle.pt 2013-10-24 19:26:47 +0000
147@@ -103,6 +103,16 @@
148 </li>
149 </ul>
150 </div>
151+ <div class="row no-border">
152+ <h3>
153+ Changes
154+ </h3>
155+ <ul class="list">
156+ <li tal:repeat="change bundle.changes"
157+ tal:content="structure: format_change(change, bundle.branch_spec)">
158+ </li>
159+ </ul>
160+ </div>
161 </metal:block>
162 </body>
163 </html>
164
165=== modified file 'charmworld/templates/charm.pt'
166--- charmworld/templates/charm.pt 2013-10-01 12:38:21 +0000
167+++ charmworld/templates/charm.pt 2013-10-24 19:26:47 +0000
168@@ -268,7 +268,7 @@
169 </h3>
170 <ul class="list">
171 <li tal:repeat="change charm.changes"
172- tal:content="structure: format_change(change, charm)">
173+ tal:content="structure: format_change(change, charm.branch_spec)">
174 </li>
175 </ul>
176 </div>
177
178=== modified file 'charmworld/templates/recent.pt'
179--- charmworld/templates/recent.pt 2013-09-05 10:55:42 +0000
180+++ charmworld/templates/recent.pt 2013-10-24 19:26:47 +0000
181@@ -27,7 +27,7 @@
182 <td>
183 <a href="${charm.short_url}">${charm.store_url}</a></td>
184 <td tal:content="charm.summary"></td>
185- <td tal:content="structure: format_change(charm.last_change, charm)"></td>
186+ <td tal:content="structure: format_change(charm.last_change, charm.branch_spec)"></td>
187 </tr>
188 </table>
189 </div>
190
191=== modified file 'charmworld/testing/factory.py'
192--- charmworld/testing/factory.py 2013-10-23 17:37:08 +0000
193+++ charmworld/testing/factory.py 2013-10-24 19:26:47 +0000
194@@ -332,7 +332,7 @@
195 relations=relations,
196 services=services)
197 bundle_doc = make_bundle_doc(
198- data, owner, basket_with_rev, name, None, None, None)
199+ data, owner, basket_with_rev, name, None, None, None, None)
200 bundle_doc.update(dict(branch_deleted=branch_deleted,
201 data=data,
202 description=description,
203
204=== modified file 'charmworld/tests/test_models.py'
205--- charmworld/tests/test_models.py 2013-10-23 18:52:03 +0000
206+++ charmworld/tests/test_models.py 2013-10-24 19:26:47 +0000
207@@ -1595,7 +1595,7 @@
208 basket_id = "%s/%d" % (basket_name, basket_rev)
209 _id = Bundle.construct_id(owner, basket_name, bundle_name, basket_rev)
210 store_bundles(
211- self.db.bundles, parsed, 'bac', basket_id, None, None, None)
212+ self.db.bundles, parsed, 'bac', basket_id, None, None, None, None)
213 self.assertEqual(
214 {
215 '_id': _id,
216@@ -1607,6 +1607,7 @@
217 'first_change': None,
218 'last_change': None,
219 'changes': None,
220+ 'branch_spec': None,
221 },
222 self.db.bundles.find_one(_id))
223
224@@ -1643,7 +1644,7 @@
225 get_flattened_deployment):
226 store_bundles(
227 self.db.bundles, parsed, 'bac', 'wordpress-basket/5', None,
228- None, None)
229+ None, None, None)
230 self.assertItemsEqual(['wordpress-stage', 'wordpress-prod'], keys)
231
232 def test_storing_a_bundle_includes_indexing_it(self):
233@@ -1663,7 +1664,7 @@
234 FauxElasticSearchClient):
235 store_bundles(
236 self.db.bundles, {}, 'owner', 'wordpress-basket/5', None,
237- None, None)
238+ None, None, None)
239
240 self.assertTrue(FauxElasticSearchClient.index_bundles_called)
241
242@@ -1703,6 +1704,9 @@
243 'owner': 'sinzui',
244 'basket_name': 'mysql',
245 'basket_revision': 1,
246+ 'changes': None,
247+ 'first_change': None,
248+ 'last_change': None,
249 'name': 'tiny',
250 'title': 'Tiny bundle',
251 'description': 'My Tiny Bundle',
252@@ -1714,6 +1718,7 @@
253 'promulgated': True,
254 'branch_deleted': True,
255 'is_featured': False,
256+ 'branch_spec': '~sinzui/fake/path',
257 }
258 bundle = Bundle(bundle_data)
259 self.assertIs(bundle_data, bundle._raw_representation)
260@@ -2010,7 +2015,8 @@
261
262 def test_bundle_doc(self):
263 doc = make_bundle_doc(
264- {'a': 'b'}, 'foo', 'bar/9', 'baz', None, None, None)
265+ {'a': 'b'}, 'foo', 'bar/9', 'baz', None, None, None,
266+ 'fake/branch/spec')
267 self.assertEqual({
268 'owner': 'foo',
269 'basket_name': 'bar',
270@@ -2021,6 +2027,7 @@
271 'first_change': None,
272 'last_change': None,
273 'changes': None,
274+ 'branch_spec': 'fake/branch/spec',
275 }, doc)
276
277
278
279=== modified file 'charmworld/tests/test_search.py'
280--- charmworld/tests/test_search.py 2013-10-23 17:37:08 +0000
281+++ charmworld/tests/test_search.py 2013-10-24 19:26:47 +0000
282@@ -168,7 +168,7 @@
283 parsed = yaml.safe_load(deployer_config)
284 store_bundles(
285 None, parsed, 'abentley', 'wordpress-basket/5', None, None, None,
286- index_client=self.index_client)
287+ None, index_client=self.index_client)
288 return _id
289
290 def test_store_bundles_bundle_name_indexed(self):
291
292=== modified file 'charmworld/views/bundles.py'
293--- charmworld/views/bundles.py 2013-10-10 20:29:41 +0000
294+++ charmworld/views/bundles.py 2013-10-24 19:26:47 +0000
295@@ -9,6 +9,7 @@
296 from charmworld.views.helpers import (
297 find_bundle,
298 found,
299+ format_change,
300 )
301
302
303@@ -101,6 +102,7 @@
304 readme, readme_ext = bundle.readme_info(request.db)
305 return dict(
306 bundle=bundle,
307+ format_change=format_change,
308 icon_path=bundle.icon_path(request),
309 is_owner=is_owner,
310 readme=readme,
311
312=== modified file 'charmworld/views/helpers.py'
313--- charmworld/views/helpers.py 2013-10-02 13:47:53 +0000
314+++ charmworld/views/helpers.py 2013-10-24 19:26:47 +0000
315@@ -14,23 +14,23 @@
316 # View helpers used throughout various views
317
318
319-def format_change(change, charm=None):
320+def format_change(change, branch_spec=None):
321 """Format a bzr commit."""
322 parts = []
323 date = change["created"]
324 # bug 1199790: We may have a branch without any commits.
325- # In this case, class Charm returns dummy data for its attributes
326+ # In this case, Charm and Bundle return dummy data for its attributes
327 # first_change and last_change.
328 if date is not None:
329 date = datetime.utcfromtimestamp(date)
330 parts.append(unicode(date.strftime("%Y/%m/%d")))
331 parts.append(name_filter(change['committer']))
332 parts.append(change["message"][:100])
333- if charm is not None:
334+ if branch_spec is not None:
335 parts.append(
336 u'(<a href="'
337 'https://bazaar.launchpad.net/%s/revision/%s">revno %s</a>)' % (
338- charm.branch_spec, change["revno"], change["revno"]))
339+ branch_spec, change["revno"], change["revno"]))
340 return u" ".join(parts)
341
342
343
344=== modified file 'charmworld/views/tests/test_api.py'
345--- charmworld/views/tests/test_api.py 2013-10-23 18:52:03 +0000
346+++ charmworld/views/tests/test_api.py 2013-10-24 19:26:47 +0000
347@@ -735,6 +735,7 @@
348 first_change=None,
349 last_change=None,
350 changes=None,
351+ branch_spec=None,
352 )
353 self.assertEqual(expected, bundle._representation)
354
355@@ -821,6 +822,10 @@
356 },
357 u'description': u'',
358 u'files': [],
359+ u'first_change': None,
360+ u'last_change': None,
361+ u'changes': None,
362+ u'branch_spec': None,
363 u'id': u'~bac/byobu/4/bat',
364 u'name': u'bat',
365 u'owner': u'bac',
366
367=== modified file 'charmworld/views/tests/test_feeds.py'
368--- charmworld/views/tests/test_feeds.py 2013-09-05 09:47:11 +0000
369+++ charmworld/views/tests/test_feeds.py 2013-10-24 19:26:47 +0000
370@@ -107,5 +107,6 @@
371 self.assertEqual(charm.short_url, anchor.attrib['href'])
372 self.assertEqual(charm.summary, cells[1].text)
373 self.assertEqual(
374- '<td>%s</td>' % format_change(charm.last_change, charm),
375+ '<td>%s</td>' % format_change(
376+ charm.last_change, charm.branch_spec),
377 tostring(cells[2]).strip())

Subscribers

People subscribed via source and target branches