Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
2e0ac1fa
Commit
2e0ac1fa
authored
Mar 31, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #52 from edx/clintonb/currency-data
Populating currency table
parents
b59dc0da
693627f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
course_discovery/apps/core/migrations/0005_populate_currencies.py
+34
-0
requirements/base.txt
+1
-0
No files found.
course_discovery/apps/core/migrations/0005_populate_currencies.py
0 → 100644
View file @
2e0ac1fa
# -*- 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
),
]
requirements/base.txt
View file @
2e0ac1fa
...
@@ -11,4 +11,5 @@ edx-auth-backends==0.1.3
...
@@ -11,4 +11,5 @@ edx-auth-backends==0.1.3
edx-drf-extensions==0.2.0
edx-drf-extensions==0.2.0
edx-rest-api-client==1.5.0
edx-rest-api-client==1.5.0
elasticsearch>=1.0.0,<2.0.0
elasticsearch>=1.0.0,<2.0.0
pycountry==1.20
pytz==2015.7
pytz==2015.7
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment