← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/cleanup-2 into lp:launchpad

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/cleanup-2 into lp:launchpad with lp:~abentley/launchpad/cleanup as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~abentley/launchpad/cleanup-2/+merge/85731

= Summary =
Rename "bugtasks" to "items" so that ListingNavigator is fully general.

== Proposed fix ==
See above

== Pre-implementation notes ==
None

== Implementation details ==
None

== Tests ==
xvfb-run bin/test -t test_bugtask -t test_buglisting.html -t test_listing_navigator.html

== Demo and Q/A ==
Ensure you are a member of custom-buglisting-demo and make sure dynamic bug listings work, e.g. on https://bugs.qastaging.launchpad.net/nova/


= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/javascript/tests/test_listing_navigator.html
  lib/lp/bugs/templates/bugtask-macros-tableview.pt
  lib/lp/bugs/javascript/tests/test_buglisting.js
  lib/lp/app/javascript/listing_navigator.js
  lib/lp/bugs/javascript/buglisting.js
  lib/lp/bugs/browser/tests/test_bugtask.py
  lib/lp/bugs/browser/bugtask.py
  lib/lp/bugs/templates/buglisting.mustache
  lib/lp/bugs/javascript/tests/test_buglisting.html
  lib/lp/app/javascript/tests/test_listing_navigator.js
-- 
https://code.launchpad.net/~abentley/launchpad/cleanup-2/+merge/85731
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/cleanup-2 into lp:launchpad.
=== modified file 'lib/lp/app/javascript/listing_navigator.js'
--- lib/lp/app/javascript/listing_navigator.js	2011-12-14 19:27:30 +0000
+++ lib/lp/app/javascript/listing_navigator.js	2011-12-14 19:27:30 +0000
@@ -164,7 +164,7 @@
         var batch_info = Mustache.to_html(this.get('batch_info_template'), {
             start: current_batch.start + 1,
             end: current_batch.start +
-                current_batch.mustache_model.bugtasks.length,
+                current_batch.mustache_model.items.length,
             total: current_batch.total
         });
         var content = Mustache.to_html(

=== modified file 'lib/lp/app/javascript/tests/test_listing_navigator.js'
--- lib/lp/app/javascript/tests/test_listing_navigator.js	2011-12-14 19:27:30 +0000
+++ lib/lp/app/javascript/tests/test_listing_navigator.js	2011-12-14 19:27:30 +0000
@@ -65,7 +65,7 @@
     get_render_navigator: function() {
         var lp_cache = {
             mustache_model: {
-                bugtasks: [{foo: 'bar', show_foo: true}]
+                items: [{foo: 'bar', show_foo: true}]
             },
             next: null,
             prev: null,
@@ -74,8 +74,8 @@
             field_visibility: {show_foo: true},
             field_visibility_defaults: {show_foo: false}
         };
-        var template = "{{#bugtasks}}{{#show_foo}}{{foo}}{{/show_foo}}" +
-            "{{/bugtasks}}";
+        var template = "{{#items}}{{#show_foo}}{{foo}}{{/show_foo}}" +
+            "{{/items}}";
         var navigator =  new TestListingNavigator({
             cache: lp_cache,
             template: template,
@@ -213,7 +213,7 @@
             view_name: '+items',
             mustache_model: {
                 foo: 'bar',
-                bugtasks: []
+                items: []
             },
             next: null,
             prev: null,
@@ -240,7 +240,7 @@
                 item: [
                 {name: 'first'},
                 {name: 'second'}],
-                bugtasks: []
+                items: []
             },
             order_by: 'intensity',
             start: 0,
@@ -335,7 +335,7 @@
                     {name: 'first'},
                     {name: 'second'}
                 ],
-                bugtasks: ['a', 'b', 'c']
+                items: ['a', 'b', 'c']
             }};
         var query = navigator.get_batch_query(batch);
         navigator.update_from_new_model(query, true, batch);
@@ -736,7 +736,7 @@
                     {name: 'first'},
                     {name: 'second'}
                 ],
-                bugtasks: ['a', 'b', 'c']
+                items: ['a', 'b', 'c']
             }});
         Y.Assert.isNull(io_provider.last_request);
         navigator.set('pre_fetch', true);
@@ -774,7 +774,7 @@
         var navigator = get_navigator();
         navigator.update({});
         navigator.get('io_provider').last_request.successJSON({
-            mustache_model: {bugtasks: []},
+            mustache_model: {items: []},
             next: null,
             prev: null
         });
@@ -788,7 +788,7 @@
         navigator.indicator.setBusy();
         navigator.update({fetch_only: true});
         navigator.get('io_provider').last_request.successJSON({
-            mustache_model: {bugtasks: []},
+            mustache_model: {items: []},
             next: null,
             prev: null
         });

=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py	2011-12-14 03:19:49 +0000
+++ lib/lp/bugs/browser/bugtask.py	2011-12-14 19:27:30 +0000
@@ -2358,10 +2358,10 @@
 
     @property
     def model(self):
-        bugtasks = [bugtask.model for bugtask in self.getBugListingItems()]
-        for bugtask in bugtasks:
-            bugtask.update(self.field_visibility)
-        return {'bugtasks': bugtasks}
+        items = [bugtask.model for bugtask in self.getBugListingItems()]
+        for item in items:
+            item.update(self.field_visibility)
+        return {'items': items}
 
 
 class NominatedBugReviewAction(EnumeratedType):

=== modified file 'lib/lp/bugs/browser/tests/test_bugtask.py'
--- lib/lp/bugs/browser/tests/test_bugtask.py	2011-12-13 15:32:36 +0000
+++ lib/lp/bugs/browser/tests/test_bugtask.py	2011-12-14 19:27:30 +0000
@@ -1906,16 +1906,16 @@
         with dynamic_listings():
             view = self.makeView(item.bugtask)
         cache = IJSONRequestCache(view.request)
-        bugtasks = cache.objects['mustache_model']['bugtasks']
-        self.assertEqual(1, len(bugtasks))
+        items = cache.objects['mustache_model']['items']
+        self.assertEqual(1, len(items))
         combined = dict(item.model)
         combined.update(view.search().field_visibility)
-        self.assertEqual(combined, bugtasks[0])
+        self.assertEqual(combined, items[0])
 
     def test_no_next_prev_for_single_batch(self):
         """The IJSONRequestCache should contain data about ajacent batches.
 
-        mustache_model should contain bugtasks, the BugTaskListingItem.model
+        mustache_model should contain items, the BugTaskListingItem.model
         for each BugTask.
         """
         owner, item = make_bug_task_listing_item(self.factory)
@@ -1929,7 +1929,7 @@
     def test_next_for_multiple_batch(self):
         """The IJSONRequestCache should contain data about the next batch.
 
-        mustache_model should contain bugtasks, the BugTaskListingItem.model
+        mustache_model should contain items, the BugTaskListingItem.model
         for each BugTask.
         """
         task = self.factory.makeBugTask()
@@ -1942,7 +1942,7 @@
     def test_prev_for_multiple_batch(self):
         """The IJSONRequestCache should contain data about the next batch.
 
-        mustache_model should contain bugtasks, the BugTaskListingItem.model
+        mustache_model should contain items, the BugTaskListingItem.model
         for each BugTask.
         """
         task = self.factory.makeBugTask()
@@ -2134,7 +2134,7 @@
         request = LaunchpadTestRequest()
         navigator = BugListingBatchNavigator([], request, [], 1)
         cache = IJSONRequestCache(request)
-        bugtask = {
+        item = {
             'age': 'age1',
             'assignee': 'assignee1',
             'bugtarget': 'bugtarget1',
@@ -2151,9 +2151,9 @@
             'tags': 'tags1',
             'title': 'title1',
         }
-        bugtask.update(navigator.field_visibility)
+        item.update(navigator.field_visibility)
         cache.objects['mustache_model'] = {
-            'bugtasks': [bugtask],
+            'items': [item],
         }
         mustache_model = cache.objects['mustache_model']
         return navigator, mustache_model
@@ -2162,14 +2162,14 @@
         """Hiding a bug number makes it disappear from the page."""
         navigator, mustache_model = self.getNavigator()
         self.assertIn('3.14159', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_id'] = False
+        mustache_model['items'][0]['show_id'] = False
         self.assertNotIn('3.14159', navigator.mustache)
 
     def test_hiding_status(self):
         """Hiding status makes it disappear from the page."""
         navigator, mustache_model = self.getNavigator()
         self.assertIn('status1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_status'] = False
+        mustache_model['items'][0]['show_status'] = False
         self.assertNotIn('status1', navigator.mustache)
 
     def test_hiding_importance(self):
@@ -2177,7 +2177,7 @@
         navigator, mustache_model = self.getNavigator()
         self.assertIn('importance1', navigator.mustache)
         self.assertIn('importance_class1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_importance'] = False
+        mustache_model['items'][0]['show_importance'] = False
         self.assertNotIn('importance1', navigator.mustache)
         self.assertNotIn('importance_class1', navigator.mustache)
 
@@ -2186,7 +2186,7 @@
         navigator, mustache_model = self.getNavigator()
         self.assertIn('bugtarget1', navigator.mustache)
         self.assertIn('bugtarget_css1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_targetname'] = False
+        mustache_model['items'][0]['show_targetname'] = False
         self.assertNotIn('bugtarget1', navigator.mustache)
         self.assertNotIn('bugtarget_css1', navigator.mustache)
 
@@ -2195,7 +2195,7 @@
         navigator, mustache_model = self.getNavigator()
         self.assertIn('bug_heat_html1', navigator.mustache)
         self.assertIn('bug-heat-icons', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_heat'] = False
+        mustache_model['items'][0]['show_heat'] = False
         self.assertNotIn('bug_heat_html1', navigator.mustache)
         self.assertNotIn('bug-heat-icons', navigator.mustache)
 
@@ -2203,7 +2203,7 @@
         """Showing milestone name shows the text."""
         navigator, mustache_model = self.getNavigator()
         self.assertNotIn('milestone_name1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_milestone_name'] = True
+        mustache_model['items'][0]['show_milestone_name'] = True
         self.assertIn('milestone_name1', navigator.mustache)
 
     def test_hiding_assignee(self):
@@ -2211,7 +2211,7 @@
         navigator, mustache_model = self.getNavigator()
         self.assertIn('show_assignee', navigator.field_visibility)
         self.assertNotIn('Assignee: assignee1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_assignee'] = True
+        mustache_model['items'][0]['show_assignee'] = True
         self.assertIn('Assignee: assignee1', navigator.mustache)
 
     def test_hiding_age(self):
@@ -2219,7 +2219,7 @@
         navigator, mustache_model = self.getNavigator()
         self.assertIn('show_datecreated', navigator.field_visibility)
         self.assertNotIn('age1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_datecreated'] = True
+        mustache_model['items'][0]['show_datecreated'] = True
         self.assertIn('age1', navigator.mustache)
 
     def test_hiding_tags(self):
@@ -2227,7 +2227,7 @@
         navigator, mustache_model = self.getNavigator()
         self.assertIn('show_tag', navigator.field_visibility)
         self.assertNotIn('tags1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_tag'] = True
+        mustache_model['items'][0]['show_tag'] = True
         self.assertIn('tags1', navigator.mustache)
 
     def test_hiding_reporter(self):
@@ -2235,7 +2235,7 @@
         navigator, mustache_model = self.getNavigator()
         self.assertIn('show_reporter', navigator.field_visibility)
         self.assertNotIn('Reporter: reporter1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_reporter'] = True
+        mustache_model['items'][0]['show_reporter'] = True
         self.assertIn('Reporter: reporter1', navigator.mustache)
 
     def test_hiding_last_updated(self):
@@ -2243,7 +2243,7 @@
         navigator, mustache_model = self.getNavigator()
         self.assertIn('show_date_last_updated', navigator.field_visibility)
         self.assertNotIn('Last updated updated1', navigator.mustache)
-        mustache_model['bugtasks'][0]['show_date_last_updated'] = True
+        mustache_model['items'][0]['show_date_last_updated'] = True
         self.assertIn('Last updated updated1', navigator.mustache)
 
 

=== modified file 'lib/lp/bugs/javascript/buglisting.js'
--- lib/lp/bugs/javascript/buglisting.js	2011-12-14 19:27:30 +0000
+++ lib/lp/bugs/javascript/buglisting.js	2011-12-14 19:27:30 +0000
@@ -160,8 +160,8 @@
     handle_new_batch: function(batch) {
         var key, i;
         Y.each(batch.field_visibility, function(value, key) {
-            for (i = 0; i < batch.mustache_model.bugtasks.length; i++) {
-                delete batch.mustache_model.bugtasks[i][key];
+            for (i = 0; i < batch.mustache_model.items.length; i++) {
+                delete batch.mustache_model.items[i][key];
             }
         });
         return this.constructor.superclass.handle_new_batch.call(this, batch);

=== modified file 'lib/lp/bugs/javascript/tests/test_buglisting.js'
--- lib/lp/bugs/javascript/tests/test_buglisting.js	2011-12-14 19:27:30 +0000
+++ lib/lp/bugs/javascript/tests/test_buglisting.js	2011-12-14 19:27:30 +0000
@@ -37,20 +37,20 @@
             current_url: '',
             cache: {
                 field_visibility: {show_item: true},
-                mustache_model: {bugtasks: [{show_item: true} ] },
+                mustache_model: {items: [{show_item: true} ] },
                 next: null,
                 prev: null
             },
             target: this.target
         });
-        bugtask = navigator.get_current_batch().mustache_model.bugtasks[0];
+        bugtask = navigator.get_current_batch().mustache_model.items[0];
         Y.Assert.isFalse(bugtask.hasOwnProperty('show_item'));
     },
     test_cleans_visibility_from_new_batch: function() {
         // When new batch is handled, field visibility is stripped.
         var bugtask;
         var model = {
-            mustache_model: {bugtasks: []},
+            mustache_model: {items: []},
             memo: 1,
             next: null,
             prev: null,
@@ -65,7 +65,7 @@
         });
         var batch = {
             mustache_model: {
-                bugtasks: [{show_item: true}]},
+                items: [{show_item: true}]},
             memo: 2,
             next: null,
             prev: null,
@@ -73,7 +73,7 @@
         };
         var query = navigator.get_batch_query(batch);
         navigator.update_from_new_model(query, false, batch);
-        bugtask = navigator.get_current_batch().mustache_model.bugtasks[0];
+        bugtask = navigator.get_current_batch().mustache_model.items[0];
         Y.Assert.isFalse(bugtask.hasOwnProperty('show_item'));
     }
 }));
@@ -157,7 +157,7 @@
         });
         navigator.get('batches')['some-batch-key'] = {
             mustache_model: {
-                bugtasks: []
+                items: []
             },
             next: null,
             prev: null
@@ -175,7 +175,7 @@
         var navigator = get_navigator('', {target: this.target});
         var batch = {
             mustache_model: {
-                bugtasks: [],
+                items: [],
                 foo: 'bar'
             },
             next: null,

=== modified file 'lib/lp/bugs/templates/buglisting.mustache'
--- lib/lp/bugs/templates/buglisting.mustache	2011-12-08 13:23:00 +0000
+++ lib/lp/bugs/templates/buglisting.mustache	2011-12-14 19:27:30 +0000
@@ -1,5 +1,5 @@
 <div class="listing">
-{{#bugtasks}}
+{{#items}}
   <div class="buglisting-row">
 
     <div class="buglisting-col1">
@@ -80,5 +80,5 @@
     </div>
 
   </div>
-{{/bugtasks}}
+{{/items}}
 </div>