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
ec724553
Commit
ec724553
authored
Nov 07, 2016
by
Douglas Hall
Committed by
Douglas Hall
Nov 09, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow for not showing course modes on student dashboard
parent
82345810
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
5 deletions
+87
-5
common/djangoapps/student/tests/tests.py
+59
-0
common/djangoapps/student/views.py
+9
-0
lms/templates/dashboard.html
+1
-1
lms/templates/dashboard/_dashboard_course_listing.html
+3
-3
openedx/core/djangoapps/site_configuration/tests/mixins.py
+15
-1
No files found.
common/djangoapps/student/tests/tests.py
View file @
ec724553
...
...
@@ -34,6 +34,7 @@ from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangoapps.programs.tests
import
factories
as
programs_factories
from
openedx.core.djangoapps.programs.tests.mixins
import
ProgramsApiConfigMixin
from
openedx.core.djangoapps.site_configuration.tests.mixins
import
SiteMixin
import
shoppingcart
# pylint: disable=import-error
from
student.models
import
(
anonymous_id_for_user
,
user_by_anonymous_id
,
CourseEnrollment
,
...
...
@@ -525,6 +526,64 @@ class DashboardTest(ModuleStoreTestCase):
return
complete_course_mode_info
(
self
.
course
.
id
,
enrollment
)
@ddt.ddt
class
DashboardTestsWithSiteOverrides
(
SiteMixin
,
ModuleStoreTestCase
):
"""
Tests for site settings overrides used when rendering the dashboard view
"""
def
setUp
(
self
):
super
(
DashboardTestsWithSiteOverrides
,
self
)
.
setUp
()
self
.
org
=
'fakeX'
self
.
course
=
CourseFactory
.
create
(
org
=
self
.
org
)
self
.
user
=
UserFactory
.
create
(
username
=
'jack'
,
email
=
'jack@fake.edx.org'
,
password
=
'test'
)
CourseModeFactory
.
create
(
mode_slug
=
'no-id-professional'
,
course_id
=
self
.
course
.
id
)
CourseEnrollment
.
enroll
(
self
.
user
,
self
.
course
.
location
.
course_key
,
mode
=
'no-id-professional'
)
cache
.
clear
()
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
'ENABLE_VERIFIED_CERTIFICATES'
:
False
})
@ddt.data
(
(
'testserver1.com'
,
{
'ENABLE_VERIFIED_CERTIFICATES'
:
True
}),
(
'testserver2.com'
,
{
'ENABLE_VERIFIED_CERTIFICATES'
:
True
,
'DISPLAY_COURSE_MODES_ON_DASHBOARD'
:
True
}),
)
@ddt.unpack
def
test_course_mode_visible
(
self
,
site_domain
,
site_configuration_values
):
"""
Test that the course mode for courses is visible on the dashboard
when settings have been overridden by site configuration.
"""
site_configuration_values
.
update
({
'SITE_NAME'
:
site_domain
,
'course_org_filter'
:
self
.
org
})
self
.
set_up_site
(
site_domain
,
site_configuration_values
)
self
.
client
.
login
(
username
=
'jack'
,
password
=
'test'
)
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
self
.
assertContains
(
response
,
'class="course professional"'
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
'ENABLE_VERIFIED_CERTIFICATES'
:
False
})
@ddt.data
(
(
'testserver3.com'
,
{
'ENABLE_VERIFIED_CERTIFICATES'
:
False
}),
(
'testserver4.com'
,
{
'DISPLAY_COURSE_MODES_ON_DASHBOARD'
:
False
}),
)
@ddt.unpack
def
test_course_mode_invisible
(
self
,
site_domain
,
site_configuration_values
):
"""
Test that the course mode for courses is invisible on the dashboard
when settings have been overridden by site configuration.
"""
site_configuration_values
.
update
({
'SITE_NAME'
:
site_domain
,
'course_org_filter'
:
self
.
org
})
self
.
set_up_site
(
site_domain
,
site_configuration_values
)
self
.
client
.
login
(
username
=
'jack'
,
password
=
'test'
)
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
self
.
assertNotContains
(
response
,
'class="course professional"'
)
class
UserSettingsEventTestMixin
(
EventTestMixin
):
"""
Mixin for verifying that user setting events were emitted during a test.
...
...
common/djangoapps/student/views.py
View file @
ec724553
...
...
@@ -570,6 +570,14 @@ def dashboard(request):
user
=
request
.
user
platform_name
=
configuration_helpers
.
get_value
(
"platform_name"
,
settings
.
PLATFORM_NAME
)
enable_verified_certificates
=
configuration_helpers
.
get_value
(
'ENABLE_VERIFIED_CERTIFICATES'
,
settings
.
FEATURES
.
get
(
'ENABLE_VERIFIED_CERTIFICATES'
)
)
display_course_modes_on_dashboard
=
configuration_helpers
.
get_value
(
'DISPLAY_COURSE_MODES_ON_DASHBOARD'
,
settings
.
FEATURES
.
get
(
'DISPLAY_COURSE_MODES_ON_DASHBOARD'
,
True
)
)
# we want to filter and only show enrollments for courses within
# the 'ORG' defined in configuration.
...
...
@@ -762,6 +770,7 @@ def dashboard(request):
'programs_by_run'
:
programs_by_run
,
'show_program_listing'
:
ProgramsApiConfig
.
current
()
.
show_program_listing
,
'disable_courseware_js'
:
True
,
'display_course_modes_on_dashboard'
:
enable_verified_certificates
and
display_course_modes_on_dashboard
,
}
ecommerce_service
=
EcommerceService
()
...
...
lms/templates/dashboard.html
View file @
ec724553
...
...
@@ -99,7 +99,7 @@ from openedx.core.djangolib.markup import HTML, Text
<
%
course_verification_status =
verification_status_by_course.get(enrollment.course_id,
{})
%
>
<
%
course_requirements =
courses_requirements_not_met.get(enrollment.course_id)
%
>
<
%
related_programs =
programs_by_run.get(unicode(enrollment.course_id))
%
>
<
%
include
file
=
'dashboard/_dashboard_course_listing.html'
args=
"course_overview=enrollment.course_overview, enrollment=enrollment, show_courseware_link=show_courseware_link, cert_status=cert_status, can_unenroll=can_unenroll, credit_status=credit_status, show_email_settings=show_email_settings, course_mode_info=course_mode_info, show_refund_option=show_refund_option, is_paid_course=is_paid_course, is_course_blocked=is_course_blocked, verification_status=course_verification_status, course_requirements=course_requirements, dashboard_index=dashboard_index, share_settings=share_settings, user=user, related_programs=related_programs"
/>
<
%
include
file
=
'dashboard/_dashboard_course_listing.html'
args=
'course_overview=enrollment.course_overview, enrollment=enrollment, show_courseware_link=show_courseware_link, cert_status=cert_status, can_unenroll=can_unenroll, credit_status=credit_status, show_email_settings=show_email_settings, course_mode_info=course_mode_info, show_refund_option=show_refund_option, is_paid_course=is_paid_course, is_course_blocked=is_course_blocked, verification_status=course_verification_status, course_requirements=course_requirements, dashboard_index=dashboard_index, share_settings=share_settings, user=user, related_programs=related_programs, display_course_modes_on_dashboard=display_course_modes_on_dashboard'
/>
% endfor
</ul>
...
...
lms/templates/dashboard/_dashboard_course_listing.html
View file @
ec724553
<
%
page
args=
"course_overview, enrollment, show_courseware_link, cert_status, can_unenroll, credit_status, show_email_settings, course_mode_info, show_refund_option, is_paid_course, is_course_blocked, verification_status, course_requirements, dashboard_index, share_settings, related_programs"
expression_filter=
"h"
/>
<
%
page
args=
"course_overview, enrollment, show_courseware_link, cert_status, can_unenroll, credit_status, show_email_settings, course_mode_info, show_refund_option, is_paid_course, is_course_blocked, verification_status, course_requirements, dashboard_index, share_settings, related_programs
, display_course_modes_on_dashboard
"
expression_filter=
"h"
/>
<
%!
import
urllib
...
...
@@ -37,7 +37,7 @@ from student.helpers import (
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<li
class=
"course-item"
>
% if
settings.FEATURES.get('ENABLE_VERIFIED_CERTIFICATES')
:
% if
display_course_modes_on_dashboard
:
<
%
course_verified_certs =
enrollment_mode_display(
enrollment
.
mode
,
...
...
@@ -74,7 +74,7 @@ from student.helpers import (
<img
src=
"${course_overview.image_urls['small']}"
class=
"course-image"
alt=
"${_('{course_number} {course_name} Cover Image').format(course_number=course_overview.number, course_name=course_overview.display_name_with_default)}"
/>
</a>
% endif
% if
settings.FEATURES.get('ENABLE_VERIFIED_CERTIFICATES')
and course_verified_certs.get('display_mode') != 'audit':
% if
display_course_modes_on_dashboard
and course_verified_certs.get('display_mode') != 'audit':
<span
class=
"sts-enrollment"
title=
"${course_verified_certs.get('enrollment_title')}"
>
<span
class=
"label"
>
${_("Enrolled as: ")}
</span>
% if course_verified_certs.get('show_image'):
...
...
openedx/core/djangoapps/site_configuration/tests/mixins.py
View file @
ec724553
...
...
@@ -42,8 +42,22 @@ class SiteMixin(object):
# Initialize client with default site domain
self
.
use_site
(
self
.
site
)
def
set_up_site
(
self
,
domain
,
site_configuration_values
):
"""
Create Site and SiteConfiguration models and initialize test client with the created site
"""
site
=
SiteFactory
.
create
(
domain
=
domain
,
name
=
domain
)
__
=
SiteConfigurationFactory
.
create
(
site
=
site
,
values
=
site_configuration_values
)
self
.
use_site
(
site
)
def
use_site
(
self
,
site
):
"""
#
Initializes the test client with the domain of the given site
Initializes the test client with the domain of the given site
"""
self
.
client
=
self
.
client_class
(
SERVER_NAME
=
site
.
domain
)
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