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
5cf016cf
Commit
5cf016cf
authored
Oct 23, 2017
by
Alex Dusenbery
Committed by
Alex Dusenbery
Oct 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDUCATOR-1570 | Wire up a stub signal receiver to handle comment_created signals.
parent
63d26070
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
1 deletions
+75
-1
lms/djangoapps/discussion/apps.py
+20
-0
lms/djangoapps/discussion/signals/__init__.py
+0
-0
lms/djangoapps/discussion/signals/handlers.py
+25
-0
lms/djangoapps/discussion/tests/test_signals.py
+29
-0
lms/envs/common.py
+1
-1
No files found.
lms/djangoapps/discussion/apps.py
0 → 100644
View file @
5cf016cf
"""
Discussion Application Configuration
Signal handlers are connected here.
"""
from
django.apps
import
AppConfig
class
DiscussionConfig
(
AppConfig
):
"""
Application Configuration for Grades.
"""
name
=
u'lms.djangoapps.discussion'
def
ready
(
self
):
"""
Connect handlers to send notifications about discussions.
"""
from
.signals
import
handlers
# pylint: disable=unused-variable
lms/djangoapps/discussion/signals/__init__.py
0 → 100644
View file @
5cf016cf
lms/djangoapps/discussion/signals/handlers.py
0 → 100644
View file @
5cf016cf
"""
Signal handlers related to discussions.
"""
import
logging
from
django.dispatch
import
receiver
from
django_comment_common
import
signals
from
lms.djangoapps.discussion.config.waffle
import
waffle
,
FORUM_RESPONSE_NOTIFICATIONS
log
=
logging
.
getLogger
(
__name__
)
@receiver
(
signals
.
comment_created
)
def
send_discussion_email_notification
(
sender
,
user
,
post
,
**
kwargs
):
if
waffle
()
.
is_enabled
(
FORUM_RESPONSE_NOTIFICATIONS
):
send_message
(
post
)
def
send_message
(
post
):
"""
TODO: https://openedx.atlassian.net/browse/EDUCATOR-1572
"""
log
.
info
(
'Sending message about thread
%
s'
,
post
.
thread_id
)
lms/djangoapps/discussion/tests/test_signals.py
0 → 100644
View file @
5cf016cf
from
django.test
import
TestCase
import
mock
from
django_comment_common
import
signals
from
lms.djangoapps.discussion.config.waffle
import
waffle
,
FORUM_RESPONSE_NOTIFICATIONS
class
SendMessageHandlerTestCase
(
TestCase
):
@mock.patch
(
'lms.djangoapps.discussion.signals.handlers.send_message'
)
def
test_comment_created_signal_sends_message
(
self
,
mock_send_message
):
with
waffle
()
.
override
(
FORUM_RESPONSE_NOTIFICATIONS
):
sender
=
mock
.
Mock
()
user
=
mock
.
Mock
()
post
=
mock
.
Mock
()
signals
.
comment_created
.
send
(
sender
=
sender
,
user
=
user
,
post
=
post
)
mock_send_message
.
assert_called_once_with
(
post
)
@mock.patch
(
'lms.djangoapps.discussion.signals.handlers.send_message'
)
def
test_comment_created_signal_message_not_sent_without_waffle_switch
(
self
,
mock_send_message
):
with
waffle
()
.
override
(
FORUM_RESPONSE_NOTIFICATIONS
,
active
=
False
):
sender
=
mock
.
Mock
()
user
=
mock
.
Mock
()
post
=
mock
.
Mock
()
signals
.
comment_created
.
send
(
sender
=
sender
,
user
=
user
,
post
=
post
)
self
.
assertFalse
(
mock_send_message
.
called
)
lms/envs/common.py
View file @
5cf016cf
...
...
@@ -2098,7 +2098,7 @@ INSTALLED_APPS = [
'django_comment_client'
,
'django_comment_common'
,
'discussion_api'
,
'lms.djangoapps.discussion'
,
'lms.djangoapps.discussion
.apps.DiscussionConfig
'
,
# Notes
'notes'
,
...
...
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