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
4dee832f
Commit
4dee832f
authored
Dec 02, 2012
by
Kevin Chugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert flagging to one flag
parent
229a48db
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
28 deletions
+51
-28
lms/djangoapps/django_comment_client/base/urls.py
+1
-0
lms/djangoapps/django_comment_client/base/views.py
+6
-0
lms/djangoapps/django_comment_client/utils.py
+1
-1
lms/lib/comment_client/comment.py
+1
-1
lms/lib/comment_client/thread.py
+12
-1
lms/static/coffee/src/discussion/content.coffee
+13
-12
lms/static/coffee/src/discussion/utils.coffee
+1
-0
lms/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
+15
-12
lms/templates/discussion/_underscore_templates.html
+1
-1
No files found.
lms/djangoapps/django_comment_client/base/urls.py
View file @
4dee832f
...
...
@@ -11,6 +11,7 @@ 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\-]+)/unvote$'
,
'undo_vote_for_thread'
,
name
=
'undo_vote_for_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/follow$'
,
'follow_thread'
,
name
=
'follow_thread'
),
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
4dee832f
...
...
@@ -244,6 +244,12 @@ def flag_abuse_for_thread(request, course_id, thread_id, value):
thread
.
flagAbuse
(
user
,
thread
,
value
)
return
JsonResponse
(
utils
.
safe_content
(
thread
.
to_dict
()))
def
un_flag_abuse_for_thread
(
request
,
course_id
,
thread_id
,
value
):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
thread
.
unFlagAbuse
(
user
,
thread
,
value
)
return
JsonResponse
(
utils
.
safe_content
(
thread
.
to_dict
()))
@require_POST
@login_required
@permitted
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
4dee832f
...
...
@@ -352,7 +352,7 @@ def safe_content(content):
'updated_at'
,
'depth'
,
'type'
,
'commentable_id'
,
'comments_count'
,
'at_position_list'
,
'children'
,
'highlighted_title'
,
'highlighted_body'
,
'courseware_title'
,
'courseware_url'
,
'tags'
,
'unread_comments_count'
,
'read'
,
"abuse_flaggers"
,
"spoiler_flaggers"
'read'
,
"abuse_flaggers"
]
if
(
content
.
get
(
'anonymous'
)
is
False
)
and
(
content
.
get
(
'anonymous_to_peers'
)
is
False
):
...
...
lms/lib/comment_client/comment.py
View file @
4dee832f
...
...
@@ -10,7 +10,7 @@ class Comment(models.Model):
'id'
,
'body'
,
'anonymous'
,
'anonymous_to_peers'
,
'course_id'
,
'endorsed'
,
'parent_id'
,
'thread_id'
,
'username'
,
'votes'
,
'user_id'
,
'closed'
,
'created_at'
,
'updated_at'
,
'depth'
,
'at_position_list'
,
'type'
,
'commentable_id'
,
'abuse_flaggers'
,
'spoiler_flaggers'
'type'
,
'commentable_id'
,
'abuse_flaggers'
]
updatable_fields
=
[
...
...
lms/lib/comment_client/thread.py
View file @
4dee832f
...
...
@@ -10,7 +10,7 @@ class Thread(models.Model):
'closed'
,
'tags'
,
'votes'
,
'commentable_id'
,
'username'
,
'user_id'
,
'created_at'
,
'updated_at'
,
'comments_count'
,
'unread_comments_count'
,
'at_position_list'
,
'children'
,
'type'
,
'highlighted_title'
,
'highlighted_body'
,
'endorsed'
,
'read'
,
'abuse_flaggers'
,
'spoiler_flaggers'
'highlighted_body'
,
'endorsed'
,
'read'
,
'abuse_flaggers'
]
updatable_fields
=
[
...
...
@@ -82,6 +82,17 @@ class Thread(models.Model):
raise
CommentClientError
(
"Can only vote / unvote for threads or comments"
)
params
=
{
'user_id'
:
user
.
id
,
'value'
:
value
}
request
=
perform_request
(
'put'
,
url
,
params
)
voteable
.
update_attributes
(
request
)
def
unFlagAbuse
(
self
,
user
,
voteable
,
value
):
if
voteable
.
type
==
'thread'
:
url
=
_url_for_flag_abuse_thread
(
voteable
.
id
)
elif
voteable
.
type
==
'comment'
:
url
=
_url_for_vote_comment
(
voteable
.
id
)
else
:
raise
CommentClientError
(
"Can only vote / unvote for threads or comments"
)
params
=
{
'user_id'
:
user
.
id
,
'value'
:
value
}
request
=
perform_request
(
'put'
,
url
,
params
)
voteable
.
update_attributes
(
request
)
def
_url_for_flag_abuse_thread
(
thread_id
):
...
...
lms/static/coffee/src/discussion/content.coffee
View file @
4dee832f
...
...
@@ -82,17 +82,18 @@ if Backbone?
class
@
Thread
extends
@
Content
urlMappers
:
'retrieve'
:
->
DiscussionUtil
.
urlFor
(
'retrieve_single_thread'
,
@
discussion
.
id
,
@
id
)
'reply'
:
->
DiscussionUtil
.
urlFor
(
'create_comment'
,
@
id
)
'flagAbuse'
:
->
DiscussionUtil
.
urlFor
(
"flagAbuse_
#{
@
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
)
'close'
:
->
DiscussionUtil
.
urlFor
(
'openclose_thread'
,
@
id
)
'update'
:
->
DiscussionUtil
.
urlFor
(
'update_thread'
,
@
id
)
'delete'
:
->
DiscussionUtil
.
urlFor
(
'delete_thread'
,
@
id
)
'follow'
:
->
DiscussionUtil
.
urlFor
(
'follow_thread'
,
@
id
)
'unfollow'
:
->
DiscussionUtil
.
urlFor
(
'unfollow_thread'
,
@
id
)
'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
)
'close'
:
->
DiscussionUtil
.
urlFor
(
'openclose_thread'
,
@
id
)
'update'
:
->
DiscussionUtil
.
urlFor
(
'update_thread'
,
@
id
)
'delete'
:
->
DiscussionUtil
.
urlFor
(
'delete_thread'
,
@
id
)
'follow'
:
->
DiscussionUtil
.
urlFor
(
'follow_thread'
,
@
id
)
'unfollow'
:
->
DiscussionUtil
.
urlFor
(
'unfollow_thread'
,
@
id
)
initialize
:
->
@
set
(
'thread'
,
@
)
...
...
@@ -120,7 +121,7 @@ if Backbone?
@
trigger
"change"
,
@
unflagAbuse
:
->
@
get
(
"
votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
-
1
@
get
(
"
abuse_flaggers"
).
push
window
.
user
.
get
(
'id'
)
@
trigger
"change"
,
@
display_body
:
->
...
...
lms/static/coffee/src/discussion/utils.coffee
View file @
4dee832f
...
...
@@ -49,6 +49,7 @@ class @DiscussionUtil
create_comment
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/reply"
delete_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/delete"
flagAbuse_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/flagAbuse"
unflagAbuse_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/unFlagAbuse"
upvote_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/upvote"
downvote_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/downvote"
undo_vote_for_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/unvote"
...
...
lms/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
View file @
4dee832f
...
...
@@ -4,7 +4,6 @@ if Backbone?
events
:
"click .discussion-vote"
:
"toggleVote"
"click .discussion-flag-abuse"
:
"toggleFlagAbuse"
"click .discussion-flag-spoiler"
:
"toggleFlagSpoiler"
"click .action-follow"
:
"toggleFollowing"
"click .action-edit"
:
"edit"
"click .action-delete"
:
"delete"
...
...
@@ -26,6 +25,7 @@ if Backbone?
@
delegateEvents
()
@
renderDogear
()
@
renderVoted
()
@
renderFlagged
()
@
renderAttrs
()
@
$
(
"span.timeago"
).
timeago
()
@
convertMath
()
...
...
@@ -42,9 +42,18 @@ if Backbone?
@
$
(
"[data-role=discussion-vote]"
).
addClass
(
"is-cast"
)
else
@
$
(
"[data-role=discussion-vote]"
).
removeClass
(
"is-cast"
)
renderFlagged
:
=>
if
window
.
user
.
id
in
@
model
.
get
(
"abuse_flaggers"
)
@
$
(
"[thread-flag]"
).
addClass
(
"flagged"
)
@
$
(
"[thread-flag]"
).
removeClass
(
"notflagged"
)
else
@
$
(
"[thread-flag]"
).
removeClass
(
"flagged"
)
@
$
(
"[thread-flag]"
).
addClass
(
"notflagged"
)
updateModelDetails
:
=>
@
renderVoted
()
@
renderFlagged
()
@
$
(
"[data-role=discussion-vote] .votes-count-number"
).
html
(
@
model
.
get
(
"votes"
)[
"up_count"
])
convertMath
:
->
...
...
@@ -60,20 +69,13 @@ if Backbone?
@
vote
()
toggleFlagAbuse
:
(
event
)
->
alert
(
'flag'
)
event
.
preventDefault
()
if
window
.
user
in
@
model
.
get
(
"abuse_flaggers"
)
@
flagAbuse
()
else
@
unFlagAbuse
()
toggleFlagSpoiler
:
(
event
)
->
event
.
preventDefault
()
if
window
.
user
in
@
model
.
abuse_flaggers
@
unFlagAbuse
()
else
@
flagAbuse
()
toggleFollowing
:
(
event
)
->
$elem
=
$
(
event
.
target
)
url
=
null
...
...
@@ -100,6 +102,7 @@ if Backbone?
@
model
.
set
(
response
,
{
silent
:
true
})
flagAbuse
:
->
alert
(
'flag abuse'
)
url
=
@
model
.
urlFor
(
"flagAbuse"
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-flag-abuse"
)
...
...
@@ -121,10 +124,10 @@ if Backbone?
@
model
.
set
(
response
,
{
silent
:
true
})
unFlagAbuse
:
->
window
.
user
.
unvote
(
@
model
)
url
=
@
model
.
urlFor
(
"un
vot
e"
)
alert
(
'unflag abuse'
)
url
=
@
model
.
urlFor
(
"un
FlagAbus
e"
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-
vot
e"
)
$elem
:
@
$
(
".discussion-
flag-abus
e"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
...
...
lms/templates/discussion/_underscore_templates.html
View file @
4dee832f
...
...
@@ -44,7 +44,7 @@
<
/header
>
<
div
class
=
"post-body"
>
$
{
'<%- body %>'
}
<
/div
>
<
a
href
=
"#"
class
=
"discussion-flag-abuse notflagged
"
data
-
role
=
"thread-flag"
data
-
tooltip
=
"flag"
>
<
a
href
=
"#"
class
=
"discussion-flag-abuse <% if user in abuse_flaggers %>flagged <%else%> notflagged<%end%>
"
data
-
role
=
"thread-flag"
data
-
tooltip
=
"flag"
>
<
i
class
=
"icon"
><
/i>Report Misuse</
a
>
$
{
'<% if (obj.courseware_url) { %>'
}
<
div
class
=
"post-context"
>
...
...
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