~reedobrien/charmworld/027test-fails

« back to all changes in this revision

Viewing changes to charmworld/views/api/__init__.py

  • Committer: Tarmac
  • Author(s): Brad Crittenden
  • Date: 2014-05-07 14:01:57 UTC
  • mfrom: (507.1.2 annotation-dos)
  • Revision ID: tarmac-20140507140157-sr36ao5d25irvupo
Include annotations in bundle search results.

The previous attempt at this problem was flawed in that API call for
getting bundles directly pulls from Mongo while search?text= and
search/interesting get results from ElasticSearch.

QA:

Load up some bundles with annotations:

bin/ingest-queued --prefix="~charmers/charms/precise/ntp"
bin/ingest-queued --prefix="~bac"

Change juju-gui to point to locally running charmworld:

diff --git a/app/config-debug.js b/app/config-debug.js
index 39daca6..f2c86b6 100644
--- a/app/config-debug.js
+++ b/app/config-debug.js
@@ -32,7 +32,10 @@ var juju_config = {
   // These are the main application config items used and passed down into all
   // SubApps.
   consoleEnabled: true,
+  //charmworldURL: 'https://manage.jujucharms.com/',
+  charmworldURL: 'http://127.0.0.1:2464/',

Run charmworld and juju-gui.  In the GUI wait for the initial results to
load.  These are the Featured charms and bundles.

Select the rails-scalable bundle.  Note the layout in the inspector.  Close
the inspector and then drag the bundle (using the name not the icon) to the
canvas.  Note that the layout is the same as the preview.

https://codereview.appspot.com/91140045/

R=jcsackett.

Approved by Juju Gui Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
195
195
        return f_requires, f_provides
196
196
 
197
197
    @classmethod
198
 
    def _format_charm(cls, charm, extra_data={}):
 
198
    def _format_charm(cls, charm, annotations=None):
199
199
        """Format the charm for API consumers."""
200
200
        mapping = {
201
201
            'summary': 'summary',
246
246
            'tested_providers': tested_providers,
247
247
            'is_subordinate': charm.subordinate
248
248
        })
249
 
        annotations = extra_data.get('annotations')
250
249
        if annotations is not None:
251
250
            output.update({'annotations': annotations})
252
251
        return output
452
451
                service, data, service_data.get('series'))
453
452
            charm = resolve_charm_from_description(db, description)
454
453
            if charm:
 
454
                annotations = mongo_services[service].get('annotations')
455
455
                formatted = cls._format_charm(
456
 
                    Charm(charm), mongo_services[service])
 
456
                    Charm(charm), annotations=annotations)
457
457
                bundle_dict['charm_metadata'][service] = formatted
458
 
 
 
458
                if 'annotations' not in data:
 
459
                    data['annotations'] = annotations
459
460
        return bundle_dict
460
461
 
461
462
    def _find_bundle(self, path):
474
475
                query = {
475
476
                    'owner': owner,
476
477
                    'basket_name': bundle_bits['basket'],
477
 
                    'name': bundle_bits['bundle']
 
478
                    'name': bundle_bits['bundle'],
478
479
                }
479
480
            else:
480
481
                query = {
481
482
                    'basket_name': bundle_bits['basket'],
482
483
                    'name': bundle_bits['bundle'],
483
 
                    'promulgated': True
 
484
                    'promulgated': True,
484
485
                }
485
486
 
486
487
            bundle = Bundle.from_query(query, self.request.db)