90
90
91
91
# we need a tuple to represent the primary key of various OrderItem subclasses
92
92
OrderItemSubclassPK = namedtuple ('OrderItemSubclassPK' , ['cls' , 'pk' ])
93
+ CURRENCY = settings .PAID_COURSE_REGISTRATION_CURRENCY [0 ]
93
94
94
95
95
96
class OrderTypes (object ):
@@ -115,7 +116,7 @@ class Meta(object):
115
116
app_label = "shoppingcart"
116
117
117
118
user = models .ForeignKey (User , db_index = True , on_delete = models .CASCADE )
118
- currency = models .CharField (default = "usd" , max_length = 8 ) # lower case ISO currency codes
119
+ currency = models .CharField (default = CURRENCY , max_length = 8 ) # lower case ISO currency codes
119
120
status = models .CharField (max_length = 32 , default = 'cart' , choices = ORDER_STATUSES )
120
121
purchase_time = models .DateTimeField (null = True , blank = True )
121
122
refunded_time = models .DateTimeField (null = True , blank = True )
@@ -654,7 +655,7 @@ class Meta(object):
654
655
unit_cost = models .DecimalField (default = 0.0 , decimal_places = 2 , max_digits = 30 )
655
656
list_price = models .DecimalField (decimal_places = 2 , max_digits = 30 , null = True )
656
657
line_desc = models .CharField (default = "Misc. Item" , max_length = 1024 )
657
- currency = models .CharField (default = "usd" , max_length = 8 ) # lower case ISO currency codes
658
+ currency = models .CharField (default = CURRENCY , max_length = 8 ) # lower case ISO currency codes
658
659
fulfilled_time = models .DateTimeField (null = True , db_index = True )
659
660
refund_requested_time = models .DateTimeField (null = True , db_index = True )
660
661
service_fee = models .DecimalField (default = 0.0 , decimal_places = 2 , max_digits = 30 )
@@ -687,7 +688,7 @@ def add_to_order(cls, order, *args, **kwargs):
687
688
# this is a validation step to verify that the currency of the item we
688
689
# are adding is the same as the currency of the order we are adding it
689
690
# to
690
- currency = kwargs .get ('currency' , 'usd' )
691
+ currency = kwargs .get ('currency' , CURRENCY )
691
692
if order .currency != currency and order .orderitem_set .exists ():
692
693
raise InvalidCartItem (_ ("Trying to add a different currency into the cart" ))
693
694
@@ -1009,7 +1010,7 @@ class Meta(object):
1009
1010
)
1010
1011
)
1011
1012
currency = models .CharField (
1012
- default = "usd" ,
1013
+ default = CURRENCY ,
1013
1014
max_length = 8 ,
1014
1015
help_text = ugettext_lazy ("Lower-case ISO currency codes" )
1015
1016
)
@@ -1104,7 +1105,7 @@ class Meta(object):
1104
1105
help_text = ugettext_lazy ("The price per item sold, including discounts." )
1105
1106
)
1106
1107
currency = models .CharField (
1107
- default = "usd" ,
1108
+ default = CURRENCY ,
1108
1109
max_length = 8 ,
1109
1110
help_text = ugettext_lazy ("Lower-case ISO currency codes" )
1110
1111
)
@@ -1921,7 +1922,7 @@ def refund_cert_callback(sender, course_enrollment=None, skip_refund=False, **kw
1921
1922
1922
1923
@classmethod
1923
1924
@transaction .atomic
1924
- def add_to_order (cls , order , course_id , cost , mode , currency = 'usd' ):
1925
+ def add_to_order (cls , order , course_id , cost , mode , currency = CURRENCY ):
1925
1926
"""
1926
1927
Add a CertificateItem to an order
1927
1928
@@ -2059,7 +2060,9 @@ def verified_certificates_contributing_more_than_minimum(cls, course_id):
2059
2060
course_id = course_id ,
2060
2061
mode = 'verified' ,
2061
2062
status = 'purchased' ,
2062
- unit_cost__gt = (CourseMode .min_course_price_for_verified_for_currency (course_id , 'usd' )))).count ()
2063
+ unit_cost__gt = (
2064
+ CourseMode .min_course_price_for_verified_for_currency (course_id , CURRENCY ))
2065
+ )).count ()
2063
2066
2064
2067
def analytics_data (self ):
2065
2068
"""Simple function used to construct analytics data for the OrderItem.
@@ -2113,7 +2116,7 @@ class Meta(object):
2113
2116
2114
2117
@classmethod
2115
2118
@transaction .atomic
2116
- def add_to_order (cls , order , donation_amount , course_id = None , currency = 'usd' ):
2119
+ def add_to_order (cls , order , donation_amount , course_id = None , currency = CURRENCY ):
2117
2120
"""Add a donation to an order.
2118
2121
2119
2122
Args:
0 commit comments