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
a93faad7
Commit
a93faad7
authored
Nov 10, 2014
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try importing the exact references we need rather than deferencing it from the djangoapp module
parent
81c1ae35
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
13 deletions
+45
-13
lms/djangoapps/courseware/tests/test_microsites.py
+32
-1
lms/djangoapps/courseware/views.py
+4
-1
lms/djangoapps/shoppingcart/context_processor.py
+5
-4
lms/envs/test.py
+2
-0
lms/templates/courseware/course_about.html
+2
-7
No files found.
lms/djangoapps/courseware/tests/test_microsites.py
View file @
a93faad7
...
...
@@ -10,7 +10,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from
helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
course_modes.models
import
CourseMode
from
xmodule.course_module
import
(
CATALOG_VISIBILITY_CATALOG_AND_ABOUT
,
CATALOG_VISIBILITY_NONE
)
...
...
@@ -55,6 +55,7 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
course_with_visibility
=
CourseFactory
.
create
(
display_name
=
'visible_course'
,
org
=
'TestMicrositeX'
,
course
=
"foo"
,
catalog_visibility
=
CATALOG_VISIBILITY_CATALOG_AND_ABOUT
,
)
...
...
@@ -189,3 +190,33 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
url
=
reverse
(
'about_course'
,
args
=
[
self
.
course_hidden_visibility
.
id
.
to_deprecated_string
()])
resp
=
self
.
client
.
get
(
url
,
HTTP_HOST
=
settings
.
MICROSITE_TEST_HOSTNAME
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
@override_settings
(
SITE_NAME
=
settings
.
MICROSITE_TEST_HOSTNAME
)
def
test_paid_course_registration
(
self
):
"""
Make sure that Microsite overrides on the ENABLE_SHOPPING_CART and
ENABLE_PAID_COURSE_ENROLLMENTS are honored
"""
course_mode
=
CourseMode
(
course_id
=
self
.
course_with_visibility
.
id
,
mode_slug
=
"honor"
,
mode_display_name
=
"honor cert"
,
min_price
=
10
,
)
course_mode
.
save
()
# first try on the non microsite, which
# should pick up the global configuration (where ENABLE_PAID_COURSE_REGISTRATIONS = False)
url
=
reverse
(
'about_course'
,
args
=
[
self
.
course_with_visibility
.
id
.
to_deprecated_string
()])
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
"Register for {}"
.
format
(
self
.
course_with_visibility
.
id
.
course
),
resp
.
content
)
self
.
assertNotIn
(
"Add {} to Cart ($10)"
.
format
(
self
.
course_with_visibility
.
id
.
course
),
resp
.
content
)
# now try on the microsite
url
=
reverse
(
'about_course'
,
args
=
[
self
.
course_with_visibility
.
id
.
to_deprecated_string
()])
resp
=
self
.
client
.
get
(
url
,
HTTP_HOST
=
settings
.
MICROSITE_TEST_HOSTNAME
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertNotIn
(
"Register for {}"
.
format
(
self
.
course_with_visibility
.
id
.
course
),
resp
.
content
)
self
.
assertIn
(
"Add {} to Cart ($10)"
.
format
(
self
.
course_with_visibility
.
id
.
course
),
resp
.
content
)
self
.
assertIn
(
'$("#add_to_cart_post").click'
,
resp
.
content
)
lms/djangoapps/courseware/views.py
View file @
a93faad7
...
...
@@ -733,7 +733,8 @@ def course_about(request, course_id):
in_cart
=
False
reg_then_add_to_cart_link
=
""
if
(
is_shopping_cart_enabled
()):
_is_shopping_cart_enabled
=
is_shopping_cart_enabled
()
if
(
_is_shopping_cart_enabled
):
registration_price
=
CourseMode
.
min_course_price_for_currency
(
course_key
,
settings
.
PAID_COURSE_REGISTRATION_CURRENCY
[
0
])
if
request
.
user
.
is_authenticated
():
...
...
@@ -775,6 +776,8 @@ def course_about(request, course_id):
# We do not want to display the internal courseware header, which is used when the course is found in the
# context. This value is therefor explicitly set to render the appropriate header.
'disable_courseware_header'
:
True
,
'is_shopping_cart_enabled'
:
_is_shopping_cart_enabled
,
'cart_link'
:
reverse
(
'shoppingcart.views.show_cart'
),
})
...
...
lms/djangoapps/shoppingcart/context_processor.py
View file @
a93faad7
...
...
@@ -6,7 +6,8 @@ navigation. We want to do this in the context_processor to
2) because navigation.html is "called" by being included in other templates, there's no "views.py" to put this.
"""
import
shoppingcart
from
.models
import
Order
,
PaidCourseRegistration
,
CourseRegCodeItem
from
.utils
import
is_shopping_cart_enabled
def
user_has_cart_context_processor
(
request
):
...
...
@@ -19,11 +20,11 @@ def user_has_cart_context_processor(request):
# user is logged in and
request
.
user
.
is_authenticated
()
and
# do we have the feature turned on
shoppingcart
.
utils
.
is_shopping_cart_enabled
()
and
is_shopping_cart_enabled
()
and
# user's cart has PaidCourseRegistrations
shoppingcart
.
models
.
Order
.
user_cart_has_items
(
Order
.
user_cart_has_items
(
request
.
user
,
[
shoppingcart
.
models
.
PaidCourseRegistration
,
shoppingcart
.
models
.
CourseRegCodeItem
]
[
PaidCourseRegistration
,
CourseRegCodeItem
]
)
)
...
...
lms/envs/test.py
View file @
a93faad7
...
...
@@ -352,6 +352,8 @@ MICROSITE_CONFIGURATION = {
"ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER"
:
False
,
"COURSE_CATALOG_VISIBILITY_PERMISSION"
:
"see_in_catalog"
,
"COURSE_ABOUT_VISIBILITY_PERMISSION"
:
"see_about_page"
,
"ENABLE_SHOPPING_CART"
:
True
,
"ENABLE_PAID_COURSE_REGISTRATION"
:
True
,
},
"default"
:
{
"university"
:
"default_university"
,
...
...
lms/templates/courseware/course_about.html
View file @
a93faad7
...
...
@@ -4,11 +4,6 @@
from
courseware
.
courses
import
course_image_url
,
get_course_about_section
from
django
.
conf
import
settings
from
edxmako
.
shortcuts
import
marketing_link
if
settings
.
FEATURES
.
get
('
ENABLE_SHOPPING_CART
')
:
cart_link =
reverse('shoppingcart.views.show_cart')
else:
cart_link =
""
%
>
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<
%!
from
microsite_configuration
import
microsite
%
>
...
...
@@ -42,7 +37,7 @@
event
.
preventDefault
();
});
%
if
settings
.
FEATURES
.
get
(
'ENABLE_SHOPPING_CART'
)
and
settings
.
FEATURES
.
get
(
'ENABLE_PAID_COURSE_REGISTRATION'
)
:
%
if
is_shopping_cart_enabled
:
add_course_complete_handler
=
function
(
jqXHR
,
textStatus
)
{
if
(
jqXHR
.
status
==
200
)
{
location
.
href
=
"${cart_link}"
;
...
...
@@ -162,7 +157,7 @@
## so that they can register and become a real user that can enroll.
% elif not is_shib_course and not can_enroll:
<span
class=
"register disabled"
>
${_("Enrollment is Closed")}
</span>
%elif
settings.FEATURES.get('ENABLE_PAID_COURSE_REGISTRATION')
and registration_price:
%elif
is_shopping_cart_enabled
and registration_price:
<
%
if
user
.
is_authenticated
()
:
reg_href =
"#"
...
...
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