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
50db11a6
Commit
50db11a6
authored
Dec 05, 2012
by
Kevin Chugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
urls and views for comment flagging
parent
c4be2b51
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
10 deletions
+54
-10
lms/djangoapps/django_comment_client/base/urls.py
+5
-3
lms/djangoapps/django_comment_client/base/views.py
+12
-0
lms/envs/common.py
+1
-1
lms/lib/comment_client/comment.py
+28
-0
lms/lib/comment_client/thread.py
+4
-4
lms/static/coffee/src/discussion/content.coffee
+4
-2
No files found.
lms/djangoapps/django_comment_client/base/urls.py
View file @
50db11a6
...
...
@@ -11,8 +11,8 @@ urlpatterns = patterns('django_comment_client.base.views',
url
(
r'threads/(?P<thread_id>[\w\-]+)/delete'
,
'delete_thread'
,
name
=
'delete_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/upvote$'
,
'vote_for_thread'
,
{
'value'
:
'up'
},
name
=
'upvote_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/flagAbuse$'
,
'flag_abuse_for_thread'
,
{
'value'
:
'up'
},
name
=
'flag_abuse_for_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/unFlagAbuse$'
,
'un_flag_abuse_for_thread'
,
{
'value'
:
'up'
},
name
=
'un_flag_abuse_for_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/downvote$'
,
'vote_for_thread'
,
{
'value'
:
'down'
},
name
=
'downvote_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/unFlagAbuse$'
,
'un_flag_abuse_for_thread'
,
name
=
'un_flag_abuse_for_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/downvote$'
,
'vote_for_thread'
,
name
=
'downvote_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/unvote$'
,
'undo_vote_for_thread'
,
name
=
'undo_vote_for_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/follow$'
,
'follow_thread'
,
name
=
'follow_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/unfollow$'
,
'unfollow_thread'
,
name
=
'unfollow_thread'
),
...
...
@@ -25,7 +25,9 @@ urlpatterns = patterns('django_comment_client.base.views',
url
(
r'comments/(?P<comment_id>[\w\-]+)/upvote$'
,
'vote_for_comment'
,
{
'value'
:
'up'
},
name
=
'upvote_comment'
),
url
(
r'comments/(?P<comment_id>[\w\-]+)/downvote$'
,
'vote_for_comment'
,
{
'value'
:
'down'
},
name
=
'downvote_comment'
),
url
(
r'comments/(?P<comment_id>[\w\-]+)/unvote$'
,
'undo_vote_for_comment'
,
name
=
'undo_vote_for_comment'
),
url
(
r'threads/(?P<comment_id>[\w\-]+)/flagAbuse$'
,
'flag_abuse_for_comment'
,
name
=
'flag_abuse_for_comment'
),
url
(
r'threads/(?P<comment_id>[\w\-]+)/unFlagAbuse$'
,
'un_flag_abuse_for_comment'
,
name
=
'un_flag_abuse_for_comment'
),
url
(
r'(?P<commentable_id>[\w\-]+)/threads/create$'
,
'create_thread'
,
name
=
'create_thread'
),
# TODO should we search within the board?
url
(
r'(?P<commentable_id>[\w\-]+)/threads/search_similar$'
,
'search_similar_threads'
,
name
=
'search_similar_threads'
),
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
50db11a6
...
...
@@ -250,6 +250,18 @@ def un_flag_abuse_for_thread(request, course_id, thread_id, value):
thread
.
unFlagAbuse
(
user
,
thread
,
value
)
return
JsonResponse
(
utils
.
safe_content
(
thread
.
to_dict
()))
def
flag_abuse_for_comment
(
request
,
course_id
,
comment_id
,
value
):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
comment
=
cc
.
Comment
.
find
(
thread_id
)
comment
.
flagAbuse
(
user
,
comment
,
value
)
return
JsonResponse
(
utils
.
safe_content
(
comment
.
to_dict
()))
def
un_flag_abuse_for_comment
(
request
,
course_id
,
comment_id
,
value
):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
comment
=
cc
.
Comment
.
find
(
thread_id
)
comment
.
unFlagAbuse
(
user
,
comment
,
value
)
return
JsonResponse
(
utils
.
safe_content
(
comment
.
to_dict
()))
@require_POST
@login_required
@permitted
...
...
lms/envs/common.py
View file @
50db11a6
...
...
@@ -46,7 +46,7 @@ MITX_FEATURES = {
'USE_DJANGO_PIPELINE'
:
True
,
'DISPLAY_HISTOGRAMS_TO_STAFF'
:
True
,
'REROUTE_ACTIVATION_EMAIL'
:
False
,
# nonempty string = address for all activation emails
'DEBUG_LEVEL'
:
0
,
# 0 = lowest level, least verbose, 255 = max level, most verbose
'DEBUG_LEVEL'
:
255
,
# 0 = lowest level, least verbose, 255 = max level, most verbose
## DO NOT SET TO True IN THIS FILE
## Doing so will cause all courses to be released on production
...
...
lms/lib/comment_client/comment.py
View file @
50db11a6
...
...
@@ -40,9 +40,37 @@ class Comment(models.Model):
return
cls
.
url_for_comments
(
params
)
else
:
return
super
(
Comment
,
cls
)
.
url
(
action
,
params
)
def
flagAbuse
(
self
,
user
,
voteable
,
value
):
if
voteable
.
type
==
'thread'
:
url
=
_url_for_flag_abuse_thread
(
voteable
.
id
)
elif
voteable
.
type
==
'comment'
:
url
=
_url_for_flag_comment
(
voteable
.
id
)
else
:
raise
CommentClientError
(
"Can only flag/unflag threads or comments"
)
params
=
{
'user_id'
:
user
.
id
}
request
=
perform_request
(
'put'
,
url
,
params
)
voteable
.
update_attributes
(
request
)
def
unFlagAbuse
(
self
,
user
,
voteable
,
value
):
if
voteable
.
type
==
'thread'
:
url
=
_url_for_unflag_abuse_thread
(
voteable
.
id
)
elif
voteable
.
type
==
'comment'
:
url
=
_url_for_unflag_comment
(
voteable
.
id
)
else
:
raise
CommentClientError
(
"Can flag/unflag for threads or comments"
)
params
=
{
'user_id'
:
user
.
id
}
request
=
perform_request
(
'put'
,
url
,
params
)
voteable
.
update_attributes
(
request
)
def
_url_for_thread_comments
(
thread_id
):
return
"{prefix}/threads/{thread_id}/comments"
.
format
(
prefix
=
settings
.
PREFIX
,
thread_id
=
thread_id
)
def
_url_for_comment
(
comment_id
):
return
"{prefix}/comments/{comment_id}"
.
format
(
prefix
=
settings
.
PREFIX
,
comment_id
=
comment_id
)
def
_url_for_flag_abuse_comment
(
comment_id
):
return
"{prefix}/threads/{comment_id}/abuse_flags"
.
format
(
prefix
=
settings
.
PREFIX
,
thread_id
=
thread_id
)
def
_url_for_unflag_abuse_thread
(
comment_id
):
return
"{prefix}/threads/{comment_id}/abuse_unflags"
.
format
(
prefix
=
settings
.
PREFIX
,
thread_id
=
thread_id
)
lms/lib/comment_client/thread.py
View file @
50db11a6
...
...
@@ -77,9 +77,9 @@ class Thread(models.Model):
if
voteable
.
type
==
'thread'
:
url
=
_url_for_flag_abuse_thread
(
voteable
.
id
)
elif
voteable
.
type
==
'comment'
:
url
=
_url_for_
vote
_comment
(
voteable
.
id
)
url
=
_url_for_
flag
_comment
(
voteable
.
id
)
else
:
raise
CommentClientError
(
"Can only
vote / unvote for
threads or comments"
)
raise
CommentClientError
(
"Can only
flag/unflag
threads or comments"
)
params
=
{
'user_id'
:
user
.
id
}
request
=
perform_request
(
'put'
,
url
,
params
)
voteable
.
update_attributes
(
request
)
...
...
@@ -88,9 +88,9 @@ class Thread(models.Model):
if
voteable
.
type
==
'thread'
:
url
=
_url_for_unflag_abuse_thread
(
voteable
.
id
)
elif
voteable
.
type
==
'comment'
:
url
=
_url_for_
vote
_comment
(
voteable
.
id
)
url
=
_url_for_
unflag
_comment
(
voteable
.
id
)
else
:
raise
CommentClientError
(
"Can
only vote / unvote
for threads or comments"
)
raise
CommentClientError
(
"Can
flag/unflag
for threads or comments"
)
params
=
{
'user_id'
:
user
.
id
}
request
=
perform_request
(
'put'
,
url
,
params
)
voteable
.
update_attributes
(
request
)
...
...
lms/static/coffee/src/discussion/content.coffee
View file @
50db11a6
...
...
@@ -94,8 +94,6 @@ if Backbone?
urlMappers
:
'retrieve'
:
->
DiscussionUtil
.
urlFor
(
'retrieve_single_thread'
,
@
discussion
.
id
,
@
id
)
'reply'
:
->
DiscussionUtil
.
urlFor
(
'create_comment'
,
@
id
)
'flagAbuse'
:
->
DiscussionUtil
.
urlFor
(
"flagAbuse_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'unFlagAbuse'
:
->
DiscussionUtil
.
urlFor
(
"unFlagAbuse_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'unvote'
:
->
DiscussionUtil
.
urlFor
(
"undo_vote_for_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'upvote'
:
->
DiscussionUtil
.
urlFor
(
"upvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'downvote'
:
->
DiscussionUtil
.
urlFor
(
"downvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
...
...
@@ -104,6 +102,10 @@ if Backbone?
'delete'
:
->
DiscussionUtil
.
urlFor
(
'delete_thread'
,
@
id
)
'follow'
:
->
DiscussionUtil
.
urlFor
(
'follow_thread'
,
@
id
)
'unfollow'
:
->
DiscussionUtil
.
urlFor
(
'unfollow_thread'
,
@
id
)
'flagAbuse'
:
->
DiscussionUtil
.
urlFor
(
"flagAbuse_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'unFlagAbuse'
:
->
DiscussionUtil
.
urlFor
(
"unFlagAbuse_
#{
@
get
(
'type'
)
}
"
,
@
id
)
initialize
:
->
@
set
(
'thread'
,
@
)
...
...
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