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
13608048
Commit
13608048
authored
Sep 21, 2016
by
Andy Armstrong
Committed by
GitHub
Sep 21, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13530 from edx/hotfix/2016-09-21
Revert "[SOL-1953] Update Commerce Configuration"
parents
777964b9
c52ba6ac
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
5 additions
and
152 deletions
+5
-152
lms/djangoapps/commerce/migrations/0005_auto_20160831_0247.py
+0
-25
lms/djangoapps/commerce/models.py
+4
-35
lms/djangoapps/commerce/tests/test_models.py
+0
-64
lms/djangoapps/student_account/views.py
+1
-1
openedx/core/djangoapps/site_configuration/migrations/0003_siteconfiguration_receipt_page_url.py
+0
-19
openedx/core/djangoapps/site_configuration/models.py
+0
-8
No files found.
lms/djangoapps/commerce/migrations/0005_auto_20160831_0247.py
deleted
100644 → 0
View file @
777964b9
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'sites'
,
'0001_initial'
),
(
'commerce'
,
'0004_auto_20160531_0950'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'commerceconfiguration'
,
name
=
'receipt_page'
,
),
migrations
.
AddField
(
model_name
=
'commerceconfiguration'
,
name
=
'site'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
blank
=
True
,
to
=
'sites.Site'
,
null
=
True
),
),
]
lms/djangoapps/commerce/models.py
View file @
13608048
"""
Commerce-related models.
"""
from
django.contrib.sites.models
import
Site
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
config_models.models
import
ConfigurationModel
from
openedx.core.djangoapps.site_configuration.models
import
SiteConfiguration
from
logging
import
getLogger
logger
=
getLogger
(
__name__
)
# pylint: disable=invalid-name
class
CommerceConfiguration
(
ConfigurationModel
):
...
...
@@ -38,41 +33,15 @@ class CommerceConfiguration(ConfigurationModel):
'Specified in seconds. Enable caching by setting this to a value greater than 0.'
)
)
site
=
models
.
ForeignKey
(
Site
,
on_delete
=
models
.
SET_NULL
,
blank
=
True
,
null
=
True
receipt_page
=
models
.
CharField
(
max_length
=
255
,
default
=
'/commerce/checkout/receipt/?orderNum='
,
help_text
=
_
(
'Path to order receipt page.'
)
)
def
__unicode__
(
self
):
return
"Commerce configuration"
def
get_receipt_page_url
(
self
,
order_number
):
"""
Return absolute receipt page URL.
Arguments:
order_number (str): Order number
Returns:
Absolute receipt page URL, consisting of site domain and site receipt page.
"""
site
=
self
.
site
if
site
:
try
:
return
'{site_domain}{receipt_page_url}{order_number}'
.
format
(
site_domain
=
site
.
domain
,
receipt_page_url
=
site
.
configuration
.
receipt_page_url
,
# pylint: disable=no-member
order_number
=
order_number
)
except
AttributeError
:
logger
.
info
(
"Site Configuration is not enabled for site (
%
s)."
,
site
)
return
'{default_receipt_page_url}{order_number}'
.
format
(
default_receipt_page_url
=
SiteConfiguration
.
DEFAULT_RECEIPT_PAGE_URL
,
order_number
=
order_number
)
@property
def
is_cache_enabled
(
self
):
"""Whether responses from the Ecommerce API will be cached."""
...
...
lms/djangoapps/commerce/tests/test_models.py
deleted
100644 → 0
View file @
777964b9
""" Tests for commerce models. """
import
ddt
from
django.test
import
TestCase
from
commerce.models
import
CommerceConfiguration
from
microsite_configuration.tests.factories
import
SiteFactory
from
openedx.core.djangoapps.site_configuration.models
import
SiteConfiguration
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteConfigurationFactory
@ddt.ddt
class
CommerceConfigurationModelTests
(
TestCase
):
""" Tests for the CommerceConfiguration model. """
def
setUp
(
self
):
"""
Create CommerceConfiguration object
"""
super
(
CommerceConfigurationModelTests
,
self
)
.
setUp
()
self
.
site
=
SiteFactory
()
self
.
order_number
=
"TEST_ORDER_NUMBER"
def
configure_commerce
(
self
,
is_configured
,
is_default_page
):
"""
Helper for creating specific Commerce Configuration.
Arguments:
is_configured (bool): Indicates whether or not the Site has Site Configuration.
is_default_page (bool): Indicates whether or not the LMS receipt page is used
Returns:
Commerce configuration.
"""
if
not
is_default_page
:
if
is_configured
:
SiteConfigurationFactory
.
create
(
site
=
self
.
site
,
receipt_page_url
=
'receipt/page/url'
,
)
return
CommerceConfiguration
.
objects
.
create
(
enabled
=
True
,
site
=
self
.
site
if
not
is_default_page
else
None
)
@ddt.data
((
True
,
False
),
(
False
,
False
),
(
False
,
True
))
@ddt.unpack
def
test_get_receipt_page_url_site_configured
(
self
,
is_configured
,
is_default_page
):
commerce_configuration
=
self
.
configure_commerce
(
is_configured
,
is_default_page
)
receipt_page_url
=
commerce_configuration
.
get_receipt_page_url
(
self
.
order_number
)
expected_receipt_page_url
=
'{site_domain}{receipt_page_url}{order_number}'
.
format
(
site_domain
=
self
.
site
.
domain
,
receipt_page_url
=
self
.
site
.
configuration
.
receipt_page_url
,
# pylint: disable=no-member
order_number
=
self
.
order_number
)
if
(
is_configured
and
not
is_default_page
)
else
'{default_receipt_page_url}{order_number}'
.
format
(
default_receipt_page_url
=
SiteConfiguration
.
DEFAULT_RECEIPT_PAGE_URL
,
order_number
=
self
.
order_number
)
self
.
assertEqual
(
receipt_page_url
,
expected_receipt_page_url
)
lms/djangoapps/student_account/views.py
View file @
13608048
...
...
@@ -347,7 +347,7 @@ def get_user_orders(user):
'order_date'
:
strftime_localized
(
date_placed
.
replace
(
tzinfo
=
pytz
.
UTC
),
'SHORT_DATE'
),
'receipt_url'
:
commerce_configuration
.
get_receipt_page_url
(
order
[
'number'
])
'receipt_url'
:
commerce_configuration
.
receipt_page
+
order
[
'number'
]
}
user_orders
.
append
(
order_data
)
except
KeyError
:
...
...
openedx/core/djangoapps/site_configuration/migrations/0003_siteconfiguration_receipt_page_url.py
deleted
100644 → 0
View file @
777964b9
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'site_configuration'
,
'0002_auto_20160720_0231'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'siteconfiguration'
,
name
=
'receipt_page_url'
,
field
=
models
.
CharField
(
default
=
b
'/commerce/checkout/receipt/?orderNum='
,
help_text
=
'Path to order receipt page.'
,
max_length
=
255
),
),
]
openedx/core/djangoapps/site_configuration/models.py
View file @
13608048
...
...
@@ -7,7 +7,6 @@ from django.db import models
from
django.contrib.sites.models
import
Site
from
django.db.models.signals
import
post_save
from
django.dispatch
import
receiver
from
django.utils.translation
import
ugettext_lazy
as
_
from
django_extensions.db.models
import
TimeStampedModel
from
jsonfield.fields
import
JSONField
...
...
@@ -26,8 +25,6 @@ class SiteConfiguration(models.Model):
site (OneToOneField): one to one field relating each configuration to a single site
values (JSONField): json field to store configurations for a site
"""
DEFAULT_RECEIPT_PAGE_URL
=
'/commerce/checkout/receipt/?orderNum='
site
=
models
.
OneToOneField
(
Site
,
related_name
=
'configuration'
)
enabled
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"Enabled"
)
values
=
JSONField
(
...
...
@@ -35,11 +32,6 @@ class SiteConfiguration(models.Model):
blank
=
True
,
load_kwargs
=
{
'object_pairs_hook'
:
collections
.
OrderedDict
}
)
receipt_page_url
=
models
.
CharField
(
max_length
=
255
,
default
=
DEFAULT_RECEIPT_PAGE_URL
,
help_text
=
_
(
'Path to order receipt page.'
)
)
def
__unicode__
(
self
):
return
u"<SiteConfiguration: {site} >"
.
format
(
site
=
self
.
site
)
...
...
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