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
985a492e
Commit
985a492e
authored
Feb 19, 2015
by
Christina Roberts
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4891 from aboudreault/discussion-digest-default
Add ENABLE_DISCUSSION_EMAIL_DIGEST feature
parents
18a916ba
ac445d6e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
12 deletions
+55
-12
common/djangoapps/student/tests/test_create_account.py
+14
-1
common/djangoapps/student/views.py
+7
-0
lms/djangoapps/notification_prefs/views.py
+27
-11
lms/envs/common.py
+7
-0
No files found.
common/djangoapps/student/tests/test_create_account.py
View file @
985a492e
...
@@ -14,6 +14,7 @@ import mock
...
@@ -14,6 +14,7 @@ import mock
from
openedx.core.djangoapps.user_api.models
import
UserPreference
from
openedx.core.djangoapps.user_api.models
import
UserPreference
from
lang_pref
import
LANGUAGE_KEY
from
lang_pref
import
LANGUAGE_KEY
from
notification_prefs
import
NOTIFICATION_PREF_KEY
from
edxmako.tests
import
mako_middleware_process_request
from
edxmako.tests
import
mako_middleware_process_request
from
external_auth.models
import
ExternalAuthMap
from
external_auth.models
import
ExternalAuthMap
...
@@ -50,8 +51,8 @@ class TestCreateAccount(TestCase):
...
@@ -50,8 +51,8 @@ class TestCreateAccount(TestCase):
@ddt.data
(
"en"
,
"eo"
)
@ddt.data
(
"en"
,
"eo"
)
def
test_header_lang_pref_saved
(
self
,
lang
):
def
test_header_lang_pref_saved
(
self
,
lang
):
response
=
self
.
client
.
post
(
self
.
url
,
self
.
params
,
HTTP_ACCEPT_LANGUAGE
=
lang
)
response
=
self
.
client
.
post
(
self
.
url
,
self
.
params
,
HTTP_ACCEPT_LANGUAGE
=
lang
)
self
.
assertEqual
(
response
.
status_code
,
200
)
user
=
User
.
objects
.
get
(
username
=
self
.
username
)
user
=
User
.
objects
.
get
(
username
=
self
.
username
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
UserPreference
.
get_preference
(
user
,
LANGUAGE_KEY
),
lang
)
self
.
assertEqual
(
UserPreference
.
get_preference
(
user
,
LANGUAGE_KEY
),
lang
)
def
base_extauth_bypass_sending_activation_email
(
self
,
bypass_activation_email_for_extauth_setting
):
def
base_extauth_bypass_sending_activation_email
(
self
,
bypass_activation_email_for_extauth_setting
):
...
@@ -98,6 +99,18 @@ class TestCreateAccount(TestCase):
...
@@ -98,6 +99,18 @@ class TestCreateAccount(TestCase):
"""
"""
self
.
base_extauth_bypass_sending_activation_email
(
False
)
self
.
base_extauth_bypass_sending_activation_email
(
False
)
@ddt.data
(
True
,
False
)
def
test_discussions_email_digest_pref
(
self
,
digest_enabled
):
with
mock
.
patch
.
dict
(
"student.models.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_EMAIL_DIGEST"
:
digest_enabled
}):
response
=
self
.
client
.
post
(
self
.
url
,
self
.
params
)
self
.
assertEqual
(
response
.
status_code
,
200
)
user
=
User
.
objects
.
get
(
username
=
self
.
username
)
preference
=
UserPreference
.
get_preference
(
user
,
NOTIFICATION_PREF_KEY
)
if
digest_enabled
:
self
.
assertIsNotNone
(
preference
)
else
:
self
.
assertIsNone
(
preference
)
@mock.patch.dict
(
"student.models.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@mock.patch.dict
(
"student.models.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@mock.patch
(
"lms.lib.comment_client.User.base_url"
,
TEST_CS_URL
)
@mock.patch
(
"lms.lib.comment_client.User.base_url"
,
TEST_CS_URL
)
...
...
common/djangoapps/student/views.py
View file @
985a492e
...
@@ -86,6 +86,7 @@ from bulk_email.models import Optout, CourseAuthorization
...
@@ -86,6 +86,7 @@ from bulk_email.models import Optout, CourseAuthorization
import
shoppingcart
import
shoppingcart
from
openedx.core.djangoapps.user_api.models
import
UserPreference
from
openedx.core.djangoapps.user_api.models
import
UserPreference
from
lang_pref
import
LANGUAGE_KEY
from
lang_pref
import
LANGUAGE_KEY
from
notification_prefs.views
import
enable_notifications
import
track.views
import
track.views
...
@@ -1589,6 +1590,12 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
...
@@ -1589,6 +1590,12 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
(
user
,
profile
,
registration
)
=
ret
(
user
,
profile
,
registration
)
=
ret
if
settings
.
FEATURES
.
get
(
'ENABLE_DISCUSSION_EMAIL_DIGEST'
):
try
:
enable_notifications
(
user
)
except
Exception
:
log
.
exception
(
"Enable discussion notifications failed for user {id}."
.
format
(
id
=
user
.
id
))
dog_stats_api
.
increment
(
"common.student.account_created"
)
dog_stats_api
.
increment
(
"common.student.account_created"
)
email
=
post_vars
[
'email'
]
email
=
post_vars
[
'email'
]
...
...
lms/djangoapps/notification_prefs/views.py
View file @
985a492e
...
@@ -90,6 +90,31 @@ class UsernameCipher(object):
...
@@ -90,6 +90,31 @@ class UsernameCipher(object):
return
UsernameCipher
.
_remove_padding
(
decrypted
)
return
UsernameCipher
.
_remove_padding
(
decrypted
)
def
enable_notifications
(
user
):
"""
Enable notifications for a user.
Currently only used for daily forum digests.
"""
UserPreference
.
objects
.
get_or_create
(
user
=
user
,
key
=
NOTIFICATION_PREF_KEY
,
defaults
=
{
"value"
:
UsernameCipher
.
encrypt
(
user
.
username
)
}
)
def
disable_notifications
(
user
):
"""
Disable notifications for a user.
Currently only used for daily forum digests.
"""
UserPreference
.
objects
.
filter
(
user
=
user
,
key
=
NOTIFICATION_PREF_KEY
)
.
delete
()
@require_POST
@require_POST
def
ajax_enable
(
request
):
def
ajax_enable
(
request
):
"""
"""
...
@@ -103,13 +128,7 @@ def ajax_enable(request):
...
@@ -103,13 +128,7 @@ def ajax_enable(request):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
raise
PermissionDenied
raise
PermissionDenied
UserPreference
.
objects
.
get_or_create
(
enable_notifications
(
request
.
user
)
user
=
request
.
user
,
key
=
NOTIFICATION_PREF_KEY
,
defaults
=
{
"value"
:
UsernameCipher
.
encrypt
(
request
.
user
.
username
)
}
)
return
HttpResponse
(
status
=
204
)
return
HttpResponse
(
status
=
204
)
...
@@ -125,10 +144,7 @@ def ajax_disable(request):
...
@@ -125,10 +144,7 @@ def ajax_disable(request):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
raise
PermissionDenied
raise
PermissionDenied
UserPreference
.
objects
.
filter
(
disable_notifications
(
request
.
user
)
user
=
request
.
user
,
key
=
NOTIFICATION_PREF_KEY
)
.
delete
()
return
HttpResponse
(
status
=
204
)
return
HttpResponse
(
status
=
204
)
...
...
lms/envs/common.py
View file @
985a492e
...
@@ -103,6 +103,13 @@ FEATURES = {
...
@@ -103,6 +103,13 @@ FEATURES = {
# this should remain off in production until digest notifications are online.
# this should remain off in production until digest notifications are online.
'ENABLE_DISCUSSION_HOME_PANEL'
:
False
,
'ENABLE_DISCUSSION_HOME_PANEL'
:
False
,
# Set this to True if you want the discussion digest emails enabled automatically for new users.
# This will be set on all new account registrations.
# It is not recommended to enable this feature if ENABLE_DISCUSSION_HOME_PANEL is not enabled, since
# subscribers who receive digests in that case will only be able to unsubscribe via links embedded
# in their emails, and they will have no way to resubscribe.
'ENABLE_DISCUSSION_EMAIL_DIGEST'
:
False
,
'ENABLE_PSYCHOMETRICS'
:
False
,
# real-time psychometrics (eg item response theory analysis in instructor dashboard)
'ENABLE_PSYCHOMETRICS'
:
False
,
# real-time psychometrics (eg item response theory analysis in instructor dashboard)
'ENABLE_DJANGO_ADMIN_SITE'
:
True
,
# set true to enable django's admin site, even on prod (e.g. for course ops)
'ENABLE_DJANGO_ADMIN_SITE'
:
True
,
# set true to enable django's admin site, even on prod (e.g. for course ops)
...
...
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