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
02ab4a03
Commit
02ab4a03
authored
Oct 16, 2017
by
Aamish Baloch
Committed by
GitHub
Oct 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16146 from edx/aamishbaloch/YONK-776
YONK-776: added thread_followed and thread_unfollowed signals
parents
4a1e8af7
7c3dab08
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
3 deletions
+37
-3
common/djangoapps/django_comment_common/signals.py
+2
-0
lms/djangoapps/django_comment_client/base/tests.py
+17
-0
lms/djangoapps/django_comment_client/base/views.py
+7
-2
lms/djangoapps/teams/models.py
+11
-1
No files found.
common/djangoapps/django_comment_common/signals.py
View file @
02ab4a03
...
...
@@ -7,6 +7,8 @@ thread_created = Signal(providing_args=['user', 'post'])
thread_edited
=
Signal
(
providing_args
=
[
'user'
,
'post'
])
thread_voted
=
Signal
(
providing_args
=
[
'user'
,
'post'
])
thread_deleted
=
Signal
(
providing_args
=
[
'user'
,
'post'
])
thread_followed
=
Signal
(
providing_args
=
[
'user'
,
'post'
])
thread_unfollowed
=
Signal
(
providing_args
=
[
'user'
,
'post'
])
comment_created
=
Signal
(
providing_args
=
[
'user'
,
'post'
])
comment_edited
=
Signal
(
providing_args
=
[
'user'
,
'post'
])
comment_voted
=
Signal
(
providing_args
=
[
'user'
,
'post'
])
...
...
lms/djangoapps/django_comment_client/base/tests.py
View file @
02ab4a03
...
...
@@ -510,6 +510,23 @@ class ViewsTestCase(
# create_thread_helper verifies that extra data are passed through to the comments service
self
.
create_thread_helper
(
mock_request
,
extra_response_data
=
{
'context'
:
ThreadContext
.
STANDALONE
})
@ddt.data
(
(
'follow_thread'
,
'thread_followed'
),
(
'unfollow_thread'
,
'thread_unfollowed'
),
)
@ddt.unpack
def
test_follow_unfollow_thread_signals
(
self
,
view_name
,
signal
,
mock_request
):
self
.
create_thread_helper
(
mock_request
)
with
self
.
assert_discussion_signals
(
signal
):
response
=
self
.
client
.
post
(
reverse
(
view_name
,
kwargs
=
{
"course_id"
:
unicode
(
self
.
course_id
),
"thread_id"
:
'i4x-MITx-999-course-Robot_Super_Course'
}
)
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_delete_thread
(
self
,
mock_request
):
self
.
_set_mock_request_data
(
mock_request
,
{
"user_id"
:
str
(
self
.
student
.
id
),
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
02ab4a03
...
...
@@ -42,7 +42,9 @@ from django_comment_common.signals import (
thread_created
,
thread_deleted
,
thread_edited
,
thread_voted
thread_voted
,
thread_followed
,
thread_unfollowed
,
)
from
django_comment_common.utils
import
ThreadContext
import
eventtracking
...
...
@@ -291,6 +293,7 @@ def create_thread(request, course_id, commentable_id):
if
follow
:
cc_user
=
cc
.
User
.
from_django_user
(
user
)
cc_user
.
follow
(
thread
)
thread_followed
.
send
(
sender
=
None
,
user
=
user
,
post
=
thread
)
data
=
thread
.
to_dict
()
...
...
@@ -525,6 +528,7 @@ def _vote_or_unvote(request, course_id, obj, value='up', undo_vote=False):
# (People could theoretically downvote by handcrafting AJAX requests.)
else
:
user
.
vote
(
obj
,
value
)
thread_voted
.
send
(
sender
=
None
,
user
=
request
.
user
,
post
=
obj
)
track_voted_event
(
request
,
course
,
obj
,
value
,
undo_vote
)
return
JsonResponse
(
prepare_content
(
obj
.
to_dict
(),
course_key
))
...
...
@@ -563,7 +567,6 @@ def vote_for_thread(request, course_id, thread_id, value):
"""
thread
=
cc
.
Thread
.
find
(
thread_id
)
result
=
_vote_or_unvote
(
request
,
course_id
,
thread
,
value
)
thread_voted
.
send
(
sender
=
None
,
user
=
request
.
user
,
post
=
thread
)
return
result
...
...
@@ -689,6 +692,7 @@ def follow_thread(request, course_id, thread_id):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
user
.
follow
(
thread
)
thread_followed
.
send
(
sender
=
None
,
user
=
request
.
user
,
post
=
thread
)
return
JsonResponse
({})
...
...
@@ -717,6 +721,7 @@ def unfollow_thread(request, course_id, thread_id):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
user
.
unfollow
(
thread
)
thread_unfollowed
.
send
(
sender
=
None
,
user
=
request
.
user
,
post
=
thread
)
return
JsonResponse
({})
...
...
lms/djangoapps/teams/models.py
View file @
02ab4a03
...
...
@@ -21,7 +21,9 @@ from django_comment_common.signals import (
thread_created
,
thread_deleted
,
thread_edited
,
thread_voted
thread_voted
,
thread_followed
,
thread_unfollowed
,
)
from
lms.djangoapps.teams
import
TEAM_DISCUSSION_CONTEXT
from
lms.djangoapps.teams.utils
import
emit_team_event
...
...
@@ -42,6 +44,14 @@ def post_create_vote_handler(sender, **kwargs): # pylint: disable=unused-argume
handle_activity
(
kwargs
[
'user'
],
kwargs
[
'post'
])
@receiver
(
thread_followed
)
@receiver
(
thread_unfollowed
)
def
post_followed_unfollowed_handler
(
sender
,
**
kwargs
):
# pylint: disable=unused-argument
"""Update the user's last activity date upon followed or unfollowed of a
post."""
handle_activity
(
kwargs
[
'user'
],
kwargs
[
'post'
])
@receiver
(
thread_edited
)
@receiver
(
thread_deleted
)
@receiver
(
comment_edited
)
...
...
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