Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
6db1f6a6
Commit
6db1f6a6
authored
Aug 14, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new column to CourseMode table for currencies
parent
4946fbcd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
8 deletions
+48
-8
lms/djangoapps/course_modes/migrations/0002_auto__add_field_coursemode_currency.py
+36
-0
lms/djangoapps/course_modes/models.py
+6
-3
lms/djangoapps/course_modes/tests.py
+6
-5
No files found.
lms/djangoapps/course_modes/migrations/0002_auto__add_field_coursemode_currency.py
0 → 100644
View file @
6db1f6a6
# -*- coding: utf-8 -*-
import
datetime
from
south.db
import
db
from
south.v2
import
SchemaMigration
from
django.db
import
models
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
# Adding field 'CourseMode.currency'
db
.
add_column
(
'course_modes_coursemode'
,
'currency'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
default
=
'usd'
,
max_length
=
8
),
keep_default
=
False
)
def
backwards
(
self
,
orm
):
# Deleting field 'CourseMode.currency'
db
.
delete_column
(
'course_modes_coursemode'
,
'currency'
)
models
=
{
'course_modes.coursemode'
:
{
'Meta'
:
{
'object_name'
:
'CourseMode'
},
'course_id'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
,
'db_index'
:
'True'
}),
'currency'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'usd'"
,
'max_length'
:
'8'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'min_price'
:
(
'django.db.models.fields.IntegerField'
,
[],
{
'default'
:
'0'
}),
'mode_display_name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'255'
}),
'mode_slug'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'suggested_prices'
:
(
'django.db.models.fields.CommaSeparatedIntegerField'
,
[],
{
'default'
:
"''"
,
'max_length'
:
'255'
,
'blank'
:
'True'
})
}
}
complete_apps
=
[
'course_modes'
]
\ No newline at end of file
lms/djangoapps/course_modes/models.py
View file @
6db1f6a6
...
...
@@ -5,7 +5,7 @@ from django.db import models
from
collections
import
namedtuple
from
django.utils.translation
import
ugettext
as
_
Mode
=
namedtuple
(
'Mode'
,
[
'slug'
,
'name'
,
'min_price'
,
'suggested_prices'
])
Mode
=
namedtuple
(
'Mode'
,
[
'slug'
,
'name'
,
'min_price'
,
'suggested_prices'
,
'currency'
])
class
CourseMode
(
models
.
Model
):
...
...
@@ -29,7 +29,10 @@ class CourseMode(models.Model):
# the suggested prices for this mode
suggested_prices
=
models
.
CommaSeparatedIntegerField
(
max_length
=
255
,
blank
=
True
,
default
=
''
)
DEFAULT_MODE
=
Mode
(
'honor'
,
_
(
'Honor Code Certificate'
),
0
,
''
)
# the currency these prices are in, using lower case ISO currency codes
currency
=
models
.
CharField
(
default
=
"usd"
,
max_length
=
8
)
DEFAULT_MODE
=
Mode
(
'honor'
,
_
(
'Honor Code Certificate'
),
0
,
''
,
'usd'
)
@classmethod
def
modes_for_course
(
cls
,
course_id
):
...
...
@@ -39,7 +42,7 @@ class CourseMode(models.Model):
If no modes have been set in the table, returns the default mode
"""
found_course_modes
=
cls
.
objects
.
filter
(
course_id
=
course_id
)
modes
=
([
Mode
(
mode
.
mode_slug
,
mode
.
mode_display_name
,
mode
.
min_price
,
mode
.
suggested_prices
)
modes
=
([
Mode
(
mode
.
mode_slug
,
mode
.
mode_display_name
,
mode
.
min_price
,
mode
.
suggested_prices
,
mode
.
currency
)
for
mode
in
found_course_modes
])
if
not
modes
:
modes
=
[
cls
.
DEFAULT_MODE
]
...
...
lms/djangoapps/course_modes/tests.py
View file @
6db1f6a6
...
...
@@ -18,7 +18,7 @@ class CourseModeModelTest(TestCase):
self
.
course_id
=
'TestCourse'
CourseMode
.
objects
.
all
()
.
delete
()
def
create_mode
(
self
,
mode_slug
,
mode_name
,
min_price
=
0
,
suggested_prices
=
''
):
def
create_mode
(
self
,
mode_slug
,
mode_name
,
min_price
=
0
,
suggested_prices
=
''
,
currency
=
'usd'
):
"""
Create a new course mode
"""
...
...
@@ -27,7 +27,8 @@ class CourseModeModelTest(TestCase):
mode_display_name
=
mode_name
,
mode_slug
=
mode_slug
,
min_price
=
min_price
,
suggested_prices
=
suggested_prices
suggested_prices
=
suggested_prices
,
currency
=
currency
)
def
test_modes_for_course_empty
(
self
):
...
...
@@ -45,14 +46,14 @@ class CourseModeModelTest(TestCase):
self
.
create_mode
(
'verified'
,
'Verified Certificate'
)
modes
=
CourseMode
.
modes_for_course
(
self
.
course_id
)
self
.
assertEqual
([
Mode
(
u'verified'
,
u'Verified Certificate'
,
0
,
''
)],
modes
)
self
.
assertEqual
([
Mode
(
u'verified'
,
u'Verified Certificate'
,
0
,
''
,
'usd'
)],
modes
)
def
test_modes_for_course_multiple
(
self
):
"""
Finding the modes when there's multiple modes
"""
mode1
=
Mode
(
u'honor'
,
u'Honor Code Certificate'
,
0
,
''
)
mode2
=
Mode
(
u'verified'
,
u'Verified Certificate'
,
0
,
''
)
mode1
=
Mode
(
u'honor'
,
u'Honor Code Certificate'
,
0
,
''
,
'usd'
)
mode2
=
Mode
(
u'verified'
,
u'Verified Certificate'
,
0
,
''
,
'usd'
)
set_modes
=
[
mode1
,
mode2
]
for
mode
in
set_modes
:
self
.
create_mode
(
mode
.
slug
,
mode
.
name
,
mode
.
min_price
,
mode
.
suggested_prices
)
...
...
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