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
923917c0
Commit
923917c0
authored
Nov 01, 2015
by
Eric Fischer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10452 from edx/bderusha/rc-2015-11-03-bug
Fix dashboard page load error when cert_status is None
parents
9724684d
62f3cf9c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
11 deletions
+40
-11
common/djangoapps/student/tests/test_views.py
+19
-1
common/djangoapps/student/tests/tests.py
+13
-6
common/djangoapps/student/views.py
+4
-1
lms/templates/dashboard.html
+2
-1
lms/templates/dashboard/_dashboard_course_listing.html
+2
-2
No files found.
common/djangoapps/student/tests/test_views.py
View file @
923917c0
...
...
@@ -11,6 +11,7 @@ from django.conf import settings
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
student.models
import
CourseEnrollment
from
student.helpers
import
DISABLE_UNENROLL_CERT_STATES
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -38,7 +39,10 @@ class TestStudentDashboardUnenrollments(ModuleStoreTestCase):
def
mock_cert
(
self
,
_user
,
_course_overview
,
_course_mode
):
# pylint: disable=unused-argument
""" Return a preset certificate status. """
if
self
.
cert_status
is
not
None
:
return
{
'status'
:
self
.
cert_status
}
return
{
'status'
:
self
.
cert_status
,
'can_unenroll'
:
self
.
cert_status
not
in
DISABLE_UNENROLL_CERT_STATES
}
else
:
return
{}
...
...
@@ -85,3 +89,17 @@ class TestStudentDashboardUnenrollments(ModuleStoreTestCase):
course_enrollment
.
assert_called_with
(
self
.
user
,
self
.
course
.
id
)
else
:
course_enrollment
.
assert_not_called
()
def
test_no_cert_status
(
self
):
""" Assert that the dashboard loads when cert_status is None."""
with
patch
(
'student.views.cert_info'
,
return_value
=
None
):
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_cant_unenroll_status
(
self
):
""" Assert that the dashboard loads when cert_status does not allow for unenrollment"""
with
patch
(
'certificates.models.certificate_status_for_student'
,
return_value
=
{
'status'
:
'ready'
}):
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
common/djangoapps/student/tests/tests.py
View file @
923917c0
...
...
@@ -79,6 +79,7 @@ class CourseEndingTest(TestCase):
'show_disabled_download_button'
:
False
,
'show_download_url'
:
False
,
'show_survey_button'
:
False
,
'can_unenroll'
:
True
,
}
)
...
...
@@ -91,7 +92,8 @@ class CourseEndingTest(TestCase):
'show_download_url'
:
False
,
'show_survey_button'
:
False
,
'mode'
:
None
,
'linked_in_url'
:
None
'linked_in_url'
:
None
,
'can_unenroll'
:
True
,
}
)
...
...
@@ -106,7 +108,8 @@ class CourseEndingTest(TestCase):
'survey_url'
:
survey_url
,
'grade'
:
'67'
,
'mode'
:
'honor'
,
'linked_in_url'
:
None
'linked_in_url'
:
None
,
'can_unenroll'
:
False
,
}
)
...
...
@@ -121,7 +124,8 @@ class CourseEndingTest(TestCase):
'survey_url'
:
survey_url
,
'grade'
:
'67'
,
'mode'
:
'verified'
,
'linked_in_url'
:
None
'linked_in_url'
:
None
,
'can_unenroll'
:
False
,
}
)
...
...
@@ -143,7 +147,8 @@ class CourseEndingTest(TestCase):
'survey_url'
:
survey_url
,
'grade'
:
'67'
,
'mode'
:
'honor'
,
'linked_in_url'
:
None
'linked_in_url'
:
None
,
'can_unenroll'
:
False
,
}
)
...
...
@@ -162,7 +167,8 @@ class CourseEndingTest(TestCase):
'survey_url'
:
survey_url
,
'grade'
:
'67'
,
'mode'
:
'honor'
,
'linked_in_url'
:
None
'linked_in_url'
:
None
,
'can_unenroll'
:
True
,
}
)
...
...
@@ -181,7 +187,8 @@ class CourseEndingTest(TestCase):
'show_survey_button'
:
False
,
'grade'
:
'67'
,
'mode'
:
'honor'
,
'linked_in_url'
:
None
'linked_in_url'
:
None
,
'can_unenroll'
:
True
,
}
)
...
...
common/djangoapps/student/views.py
View file @
923917c0
...
...
@@ -202,6 +202,7 @@ def cert_info(user, course_overview, course_mode):
'show_survey_button': bool
'survey_url': url, only if show_survey_button is True
'grade': if status is not 'processing'
'can_unenroll': if status allows for unenrollment
"""
if
not
course_overview
.
may_certify
():
return
{}
...
...
@@ -302,6 +303,7 @@ def _cert_info(user, course_overview, cert_status, course_mode): # pylint: disa
'show_disabled_download_button'
:
False
,
'show_download_url'
:
False
,
'show_survey_button'
:
False
,
'can_unenroll'
:
True
}
if
cert_status
is
None
:
...
...
@@ -319,7 +321,8 @@ def _cert_info(user, course_overview, cert_status, course_mode): # pylint: disa
'show_download_url'
:
status
==
'ready'
,
'show_disabled_download_button'
:
status
==
'generating'
,
'mode'
:
cert_status
.
get
(
'mode'
,
None
),
'linked_in_url'
:
None
'linked_in_url'
:
None
,
'can_unenroll'
:
status
not
in
DISABLE_UNENROLL_CERT_STATES
,
}
if
(
status
in
(
'generating'
,
'ready'
,
'notpassing'
,
'restricted'
)
and
...
...
lms/templates/dashboard.html
View file @
923917c0
...
...
@@ -87,6 +87,7 @@ import json
% for dashboard_index, enrollment in enumerate(course_enrollments):
<
%
show_courseware_link =
(enrollment.course_id
in
show_courseware_links_for
)
%
>
<
%
cert_status =
cert_statuses.get(enrollment.course_id)
%
>
<
%
can_unenroll =
(not
cert_status
)
or
cert_status
.
get
('
can_unenroll
')
%
>
<
%
credit_status =
credit_statuses.get(enrollment.course_id)
%
>
<
%
show_email_settings =
(enrollment.course_id
in
show_email_settings_for
)
%
>
<
%
course_mode_info =
all_course_modes.get(enrollment.course_id)
%
>
...
...
@@ -96,7 +97,7 @@ import json
<
%
course_verification_status =
verification_status_by_course.get(enrollment.course_id,
{})
%
>
<
%
course_requirements =
courses_requirements_not_met.get(enrollment.course_id)
%
>
<
%
course_program_info =
course_programs.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, 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, course_program_info=course_program_info"
/>
<
%
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, c
an_unenroll=can_unenroll, c
redit_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, course_program_info=course_program_info"
/>
% endfor
</ul>
...
...
lms/templates/dashboard/_dashboard_course_listing.html
View file @
923917c0
<
%
page
args=
"course_overview, enrollment, show_courseware_link, cert_status, 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, course_program_info"
/>
<
%
page
args=
"course_overview, enrollment, show_courseware_link, cert_status, c
an_unenroll, c
redit_status, show_email_settings, course_mode_info, show_refund_option, is_paid_course, is_course_blocked, verification_status, course_requirements, dashboard_index, share_settings, course_program_info"
/>
<
%!
import
urllib
...
...
@@ -178,7 +178,7 @@ from student.helpers import (
</a>
<div
class=
"actions-dropdown"
id=
"actions-dropdown-${dashboard_index}"
aria-label=
"${_('Additional Actions Menu')}"
>
<ul
class=
"actions-dropdown-list"
id=
"actions-dropdown-list-${dashboard_index}"
aria-label=
"${_('Available Actions')}"
role=
"menu"
>
% if c
ert_status.get('status') not in DISABLE_UNENROLL_CERT_STATES
:
% if c
an_unenroll
:
<li
class=
"actions-item"
id=
"actions-item-unenroll-${dashboard_index}"
>
% if is_paid_course and show_refund_option:
## Translators: The course name will be added to the end of this sentence.
...
...
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