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
b177f3da
Commit
b177f3da
authored
Dec 18, 2017
by
McKenzie Welter
Committed by
Michael LoTurco
Dec 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include email settings in fulfilled entitlement action items
parent
128486d7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
10 deletions
+57
-10
common/djangoapps/student/tests/test_views.py
+29
-0
lms/static/js/dashboard/legacy.js
+1
-2
lms/templates/dashboard.html
+4
-1
lms/templates/dashboard/_dashboard_course_listing.html
+5
-5
lms/templates/dashboard/_dashboard_entitlement_actions.html
+14
-1
themes/edx.org/lms/templates/dashboard.html
+4
-1
No files found.
common/djangoapps/student/tests/test_views.py
View file @
b177f3da
...
...
@@ -19,6 +19,7 @@ from mock import patch
from
opaque_keys
import
InvalidKeyError
from
pyquery
import
PyQuery
as
pq
from
bulk_email.models
import
BulkEmailFlag
from
entitlements.tests.factories
import
CourseEntitlementFactory
from
openedx.core.djangoapps.catalog.tests.factories
import
ProgramFactory
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
...
...
@@ -238,6 +239,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
Tests for the student dashboard.
"""
EMAIL_SETTINGS_ELEMENT_ID
=
"#actions-item-email-settings-0"
ENABLED_SIGNALS
=
[
'course_published'
]
TOMORROW
=
datetime
.
datetime
.
now
(
pytz
.
utc
)
+
datetime
.
timedelta
(
days
=
1
)
THREE_YEARS_AGO
=
datetime
.
datetime
.
now
(
pytz
.
utc
)
-
datetime
.
timedelta
(
days
=
(
365
*
3
))
...
...
@@ -533,6 +535,33 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
self
.
assertIn
(
'You can no longer change sessions.'
,
response
.
content
)
self
.
assertIn
(
'Related Programs:'
,
response
.
content
)
@patch.object
(
CourseOverview
,
'get_from_id'
)
@patch.object
(
BulkEmailFlag
,
'feature_enabled'
)
def
test_email_settings_fulfilled_entitlement
(
self
,
mock_email_feature
,
mock_course_overview
):
"""
Assert that the Email Settings action is shown when the user has a fulfilled entitlement.
"""
mock_email_feature
.
return_value
=
True
mock_course_overview
.
return_value
=
CourseOverviewFactory
(
start
=
self
.
TOMORROW
,
self_paced
=
True
,
enrollment_end
=
self
.
TOMORROW
)
course_enrollment
=
CourseEnrollmentFactory
(
user
=
self
.
user
)
CourseEntitlementFactory
(
user
=
self
.
user
,
enrollment_course_run
=
course_enrollment
)
response
=
self
.
client
.
get
(
self
.
path
)
self
.
assertEqual
(
pq
(
response
.
content
)(
self
.
EMAIL_SETTINGS_ELEMENT_ID
)
.
length
,
1
)
@patch.object
(
CourseOverview
,
'get_from_id'
)
@patch.object
(
BulkEmailFlag
,
'feature_enabled'
)
def
test_email_settings_unfulfilled_entitlement
(
self
,
mock_email_feature
,
mock_course_overview
):
"""
Assert that the Email Settings action is not shown when the entitlement is not fulfilled.
"""
mock_email_feature
.
return_value
=
True
mock_course_overview
.
return_value
=
CourseOverviewFactory
(
start
=
self
.
TOMORROW
)
CourseEntitlementFactory
(
user
=
self
.
user
)
response
=
self
.
client
.
get
(
self
.
path
)
self
.
assertEqual
(
pq
(
response
.
content
)(
self
.
EMAIL_SETTINGS_ELEMENT_ID
)
.
length
,
0
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@override_settings
(
BRANCH_IO_KEY
=
'test_key'
)
...
...
lms/static/js/dashboard/legacy.js
View file @
b177f3da
...
...
@@ -131,7 +131,6 @@
if
(
$
(
event
.
target
).
data
(
'optout'
)
===
'False'
)
{
$
(
'#receive_emails'
).
prop
(
'checked'
,
true
);
}
edx
.
dashboard
.
dropdown
.
toggleCourseActionsDropdownMenu
(
event
);
});
$
(
'.action-unenroll'
).
click
(
function
(
event
)
{
var
isPaidCourse
=
$
(
event
.
target
).
data
(
'course-is-paid-course'
)
===
'True'
;
...
...
@@ -211,6 +210,7 @@
});
$
(
'.action-email-settings'
).
each
(
function
(
index
)
{
$
(
this
).
attr
(
'id'
,
'email-settings-'
+
index
);
// a bit of a hack, but gets the unique selector for the modal trigger
var
trigger
=
'#'
+
$
(
this
).
attr
(
'id'
);
accessibleModal
(
...
...
@@ -219,7 +219,6 @@
'#email-settings-modal'
,
'#dashboard-main'
);
$
(
this
).
attr
(
'id'
,
'email-settings-'
+
index
);
});
$
(
'.action-unenroll'
).
each
(
function
(
index
)
{
...
...
lms/templates/dashboard.html
View file @
b177f3da
...
...
@@ -167,6 +167,10 @@ from student.models import CourseEnrollment
if
not
next_session:
continue
enrollment =
CourseEnrollment(user=user,
course_id=
next_session['key'],
mode=
next_session['type'])
#
We
only
show
email
settings
for
entitlement
cards
if
the
entitlement
has
an
associated
enrollment
show_email_settings =
is_fulfilled_entitlement
and
(
entitlement_session
.
course_id
in
show_email_settings_for
)
else:
show_email_settings =
(enrollment.course_id
in
show_email_settings_for
)
session_id =
enrollment.course_id
show_courseware_link =
(session_id
in
show_courseware_links_for
)
...
...
@@ -174,7 +178,6 @@ from student.models import CourseEnrollment
can_refund_entitlement =
entitlement
and
entitlement
.
is_entitlement_refundable
()
can_unenroll =
(not
cert_status
)
or
cert_status
.
get
('
can_unenroll
')
if
not
unfulfilled_entitlement
else
False
credit_status =
credit_statuses.get(session_id)
show_email_settings =
(session_id
in
show_email_settings_for
)
course_mode_info =
all_course_modes.get(session_id)
is_paid_course =
True
if
entitlement
else
(
session_id
in
enrolled_courses_either_paid
)
is_course_blocked =
(session_id
in
block_courses
)
...
...
lms/templates/dashboard/_dashboard_course_listing.html
View file @
b177f3da
...
...
@@ -235,11 +235,11 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_
% endif
% endif
##
Right now, the gear dropdown for entitlements only contains the 'unenroll' link, so we should hide the
##
gear altogether if the user is unable to unenroll/refund their entitlement. Later, when we add more options
##
to the gear dropdown, we can remove this check.
% if entitlement and
can_refund_entitlement
:
<
%
include
file=
'_dashboard_entitlement_actions.html'
args=
'course_overview=course_overview,entitlement=entitlement,dashboard_index=dashboard_index, can_refund_entitlement=can_refund_entitlement'
/>
##
We should only show the gear dropdown if the user is able to refund/unenroll from their entitlement
##
and/or if they have selected a course run and email_settings are enabled
##
as these are the only actions currently available
% if entitlement and
(can_refund_entitlement or show_email_settings)
:
<
%
include
file=
'_dashboard_entitlement_actions.html'
args=
'course_overview=course_overview,entitlement=entitlement,dashboard_index=dashboard_index, can_refund_entitlement=can_refund_entitlement
, show_email_settings=show_email_settings
'
/>
% elif not entitlement:
<div
class=
"wrapper-action-more"
data-course-key=
"${enrollment.course_id}"
>
<button
type=
"button"
class=
"action action-more"
id=
"actions-dropdown-link-${dashboard_index}"
aria-haspopup=
"true"
aria-expanded=
"false"
aria-controls=
"actions-dropdown-${dashboard_index}"
data-course-number=
"${course_overview.number}"
data-course-name=
"${course_overview.display_name_with_default}"
data-dashboard-index=
"${dashboard_index}"
>
...
...
lms/templates/dashboard/_dashboard_entitlement_actions.html
View file @
b177f3da
<
%
page
args=
"course_overview, entitlement, dashboard_index, can_refund_entitlement"
expression_filter=
"h"
/>
<
%
page
args=
"course_overview, entitlement, dashboard_index, can_refund_entitlement
, show_email_settings
"
expression_filter=
"h"
/>
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
...
...
@@ -43,6 +43,19 @@ dropdown_btn_id = "entitlement-actions-dropdown-btn-{}".format(dashboard_index)
</a>
</li>
% endif
% if show_email_settings:
<li
class=
"entitlement-actions-item"
id=
"actions-item-email-settings-${dashboard_index}"
role=
"menuitem"
>
## href and rel must be defined for compatibility with lms/static/js/leanModal.js
## data-dropdown-selector and data-dropdown-button-selector must be defined for compatibility with lms/static/js/dashboard/dropdown.js
<a
href=
"#email-settings-modal"
class=
"entitlement-action action-email-settings"
rel=
"leanModal"
data-dropdown-selector=
"#${dropdown_id}"
data-dropdown-button-selector=
"#${dropdown_btn_id}"
data-course-id=
"${course_overview.id}"
data-course-number=
"${course_overview.number}"
data-dashboard-index=
"${dashboard_index}"
data-optout=
"${unicode(course_overview.id) in course_optouts}"
>
${_('Email Settings')}
</a>
</li>
% endif
</ul>
</div>
</div>
themes/edx.org/lms/templates/dashboard.html
View file @
b177f3da
...
...
@@ -163,6 +163,10 @@ from student.models import CourseEnrollment
if
not
next_session:
continue
enrollment =
CourseEnrollment(user=user,
course_id=
next_session['key'],
mode=
next_session['type'])
#
We
only
show
email
settings
for
entitlement
cards
if
the
entitlement
has
an
associated
enrollment
show_email_settings =
is_fulfilled_entitlement
and
(
entitlement_session
.
course_id
in
show_email_settings_for
)
else:
show_email_settings =
(enrollment.course_id
in
show_email_settings_for
)
session_id =
enrollment.course_id
show_courseware_link =
(session_id
in
show_courseware_links_for
)
...
...
@@ -170,7 +174,6 @@ from student.models import CourseEnrollment
can_refund_entitlement =
entitlement
and
entitlement
.
is_entitlement_refundable
()
can_unenroll =
(not
cert_status
)
or
cert_status
.
get
('
can_unenroll
')
if
not
unfulfilled_entitlement
else
False
credit_status =
credit_statuses.get(session_id)
show_email_settings =
(session_id
in
show_email_settings_for
)
course_mode_info =
all_course_modes.get(session_id)
is_paid_course =
True
if
entitlement
else
(
session_id
in
enrolled_courses_either_paid
)
is_course_blocked =
(session_id
in
block_courses
)
...
...
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