Commit 2e0ac1fa by Clinton Blackburn

Merge pull request #52 from edx/clintonb/currency-data

Populating currency table
parents b59dc0da 693627f5
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pycountry
from django.db import migrations
def add_currencies(apps, schema_editor):
""" Populates the currency table.
Data is pulled from pycountry. X currencies are not included given their limited use, and a desire
to limit the size of the options displayed in Django admin.
"""
Currency = apps.get_model('core', 'Currency')
Currency.objects.bulk_create(
[Currency(code=currency.letter, name=currency.name) for currency in pycountry.currencies if
not currency.letter.startswith('X')]
)
def remove_currencies(apps, schema_editor):
""" Deletes all rows in the currency table. """
Currency = apps.get_model('core', 'Currency')
Currency.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('core', '0004_currency'),
]
operations = [
migrations.RunPython(add_currencies, remove_currencies),
]
......@@ -11,4 +11,5 @@ edx-auth-backends==0.1.3
edx-drf-extensions==0.2.0
edx-rest-api-client==1.5.0
elasticsearch>=1.0.0,<2.0.0
pycountry==1.20
pytz==2015.7
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment