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
3312eb2d
Commit
3312eb2d
authored
Feb 10, 2016
by
wajeeha-khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored code into exclusive functions
parent
fe9b1a0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
19 deletions
+35
-19
lms/djangoapps/discussion_api/api.py
+35
-19
No files found.
lms/djangoapps/discussion_api/api.py
View file @
3312eb2d
...
...
@@ -506,26 +506,42 @@ def _do_extra_actions(api_content, cc_content, request_fields, actions_form, con
if
field
in
request_fields
and
form_value
!=
api_content
[
field
]:
api_content
[
field
]
=
form_value
if
field
==
"following"
:
if
form_value
:
context
[
"cc_requester"
]
.
follow
(
cc_content
)
else
:
context
[
"cc_requester"
]
.
unfollow
(
cc_content
)
_handle_following_field
(
form_value
,
context
[
"cc_requester"
],
cc_content
)
elif
field
==
"abuse_flagged"
:
if
form_value
:
cc_content
.
flagAbuse
(
context
[
"cc_requester"
],
cc_content
)
else
:
cc_content
.
unFlagAbuse
(
context
[
"cc_requester"
],
cc_content
,
removeAll
=
False
)
else
:
assert
field
==
"voted"
signal
=
thread_voted
if
cc_content
.
type
==
'thread'
else
comment_voted
signal
.
send
(
sender
=
None
,
user
=
context
[
"request"
]
.
user
,
post
=
cc_content
)
if
form_value
:
context
[
"cc_requester"
]
.
vote
(
cc_content
,
"up"
)
api_content
[
"vote_count"
]
+=
1
else
:
context
[
"cc_requester"
]
.
unvote
(
cc_content
)
api_content
[
"vote_count"
]
-=
1
track_voted_event
(
request
,
context
[
"course"
],
cc_content
,
"up"
,
False
if
form_value
else
True
)
_handle_abuse_flagged_field
(
form_value
,
context
[
"cc_requester"
],
cc_content
)
elif
field
==
"voted"
:
_handle_voted_field
(
form_value
,
cc_content
,
api_content
,
request
,
context
)
def
_handle_following_field
(
form_value
,
user
,
cc_content
):
"""follow/unfollow thread for the user"""
if
form_value
:
user
.
follow
(
cc_content
)
else
:
user
.
unfollow
(
cc_content
)
def
_handle_abuse_flagged_field
(
form_value
,
user
,
cc_content
):
"""mark or unmark thread/comment as abused"""
if
form_value
:
cc_content
.
flagAbuse
(
user
,
cc_content
)
else
:
cc_content
.
unFlagAbuse
(
user
,
cc_content
,
removeAll
=
False
)
def
_handle_voted_field
(
form_value
,
cc_content
,
api_content
,
request
,
context
):
"""vote or undo vote on thread/comment"""
signal
=
thread_voted
if
cc_content
.
type
==
'thread'
else
comment_voted
signal
.
send
(
sender
=
None
,
user
=
context
[
"request"
]
.
user
,
post
=
cc_content
)
if
form_value
:
context
[
"cc_requester"
]
.
vote
(
cc_content
,
"up"
)
api_content
[
"vote_count"
]
+=
1
else
:
context
[
"cc_requester"
]
.
unvote
(
cc_content
)
api_content
[
"vote_count"
]
-=
1
track_voted_event
(
request
,
context
[
"course"
],
cc_content
,
vote_value
=
"up"
,
undo_vote
=
False
if
form_value
else
True
)
def
create_thread
(
request
,
thread_data
):
...
...
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