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
f290204d
Commit
f290204d
authored
Jul 30, 2012
by
Brittany Cheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:dementrock/mitx into discussion
parents
65730c22
d15d2c55
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
lms/lib/comment_client.py
+14
-3
No files found.
lms/lib/comment_client.py
View file @
f290204d
...
...
@@ -5,6 +5,12 @@ SERVICE_HOST = 'http://localhost:4567'
PREFIX
=
SERVICE_HOST
+
'/api/v1'
class
CommentClientError
(
Exception
):
pass
class
CommentClientUnknownError
(
CommentClientError
):
pass
def
delete_threads
(
commentable_id
,
*
args
,
**
kwargs
):
return
_perform_request
(
'delete'
,
_url_for_commentable_threads
(
commentable_id
),
*
args
,
**
kwargs
)
...
...
@@ -98,10 +104,15 @@ def _perform_request(method, url, data_or_params=None, *args, **kwargs):
response
=
requests
.
request
(
method
,
url
,
data
=
data_or_params
)
else
:
response
=
requests
.
request
(
method
,
url
,
params
=
data_or_params
)
if
kwargs
.
get
(
"raw"
,
False
):
return
response
.
text
if
200
<
response
.
status_code
<
500
:
raise
CommentClientException
(
response
.
text
)
elif
response
.
status_code
==
500
:
raise
CommentClientUnknownException
(
response
.
text
)
else
:
return
json
.
loads
(
response
.
text
)
if
kwargs
.
get
(
"raw"
,
False
):
return
response
.
text
else
:
return
json
.
loads
(
response
.
text
)
def
_url_for_threads
(
commentable_id
):
return
"{prefix}/{commentable_id}/threads"
.
format
(
prefix
=
PREFIX
,
commentable_id
=
commentable_id
)
...
...
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