~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/migrations/versions/013_migrate_featured.py

  • Committer: Tarmac
  • Author(s): Benji York
  • Date: 2013-08-14 14:31:48 UTC
  • mfrom: (334.2.17 featured-breakout)
  • Revision ID: tarmac-20130814143148-rt7q7run1zkfappk
[r=abentley][bug=][author=benji] Move charm featured status out into it's own collection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2013 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
import logging
 
5
 
 
6
from charmworld.models import (
 
7
    options_to_storage,
 
8
    FeaturedSource,
 
9
)
 
10
 
 
11
 
 
12
def upgrade(db, index_client):
 
13
    featured_data = index_client.api_search(filters={'is_featured': [True]})
 
14
    featured = FeaturedSource(db.featured)
 
15
    for charm_data in featured_data:
 
16
        if charm_data.get('is_featured'):
 
17
            featured.set_featured(charm_data, 'charm')