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
57b70092
Commit
57b70092
authored
Nov 20, 2012
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update front end to handle flagging
parent
fb6a07c8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
3 deletions
+63
-3
lms/djangoapps/django_comment_client/base/urls.py
+1
-0
lms/djangoapps/django_comment_client/base/views.py
+10
-1
lms/djangoapps/django_comment_client/permissions.py
+1
-0
lms/djangoapps/django_comment_client/utils.py
+1
-1
lms/static/coffee/src/discussion/content.coffee
+9
-0
lms/static/coffee/src/discussion/utils.coffee
+1
-0
lms/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
+37
-0
lms/templates/discussion/_underscore_templates.html
+3
-1
No files found.
lms/djangoapps/django_comment_client/base/urls.py
View file @
57b70092
...
...
@@ -10,6 +10,7 @@ urlpatterns = patterns('django_comment_client.base.views',
url
(
r'threads/(?P<thread_id>[\w\-]+)/reply$'
,
'create_comment'
,
name
=
'create_comment'
),
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_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 @
57b70092
...
...
@@ -136,7 +136,7 @@ def _create_comment(request, course_id, thread_id=None, parent_id=None):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
user
.
follow
(
comment
.
thread
)
if
request
.
is_ajax
():
return
ajax_content_response
(
request
,
course_id
,
comment
.
to_dict
(),
'discussion/ajax_create_comment.html'
)
return
ajax_content_response
(
request
,
course_id
,
comment
.
to_dict
(),
'discussion/ajax_create_comment.html'
)
else
:
return
JsonResponse
(
utils
.
safe_content
(
comment
.
to_dict
()))
...
...
@@ -238,6 +238,15 @@ def vote_for_thread(request, course_id, thread_id, value):
@require_POST
@login_required
@permitted
def
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
.
flagAbuse
(
thread
,
value
)
return
JsonResponse
(
utils
.
safe_content
(
thread
.
to_dict
()))
@require_POST
@login_required
@permitted
def
undo_vote_for_thread
(
request
,
course_id
,
thread_id
):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
...
...
lms/djangoapps/django_comment_client/permissions.py
View file @
57b70092
...
...
@@ -85,6 +85,7 @@ VIEW_PERMISSIONS = {
'vote_for_comment'
:
[[
'vote'
,
'is_open'
]],
'undo_vote_for_comment'
:
[[
'unvote'
,
'is_open'
]],
'vote_for_thread'
:
[[
'vote'
,
'is_open'
]],
'flag_abuse_for_thread'
:
[[
'vote'
,
'is_open'
]],
'undo_vote_for_thread'
:
[[
'unvote'
,
'is_open'
]],
'follow_thread'
:
[
'follow_thread'
],
'follow_commentable'
:
[
'follow_commentable'
],
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
57b70092
...
...
@@ -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'
,
'read'
,
"abuse_flaggers"
,
"spoiler_flaggers"
]
if
(
content
.
get
(
'anonymous'
)
is
False
)
and
(
content
.
get
(
'anonymous_to_peers'
)
is
False
):
...
...
lms/static/coffee/src/discussion/content.coffee
View file @
57b70092
...
...
@@ -84,6 +84,7 @@ 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
)
'unvote'
:
->
DiscussionUtil
.
urlFor
(
"undo_vote_for_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'upvote'
:
->
DiscussionUtil
.
urlFor
(
"upvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'downvote'
:
->
DiscussionUtil
.
urlFor
(
"downvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
...
...
@@ -113,6 +114,14 @@ if Backbone?
unvote
:
->
@
get
(
"votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
-
1
@
trigger
"change"
,
@
flagAbuse
:
->
@
get
(
"abuse_flaggers"
).
push
window
.
user
.
get
(
'id'
)
@
trigger
"change"
,
@
unflagAbuse
:
->
@
get
(
"votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
-
1
@
trigger
"change"
,
@
display_body
:
->
if
@
has
(
"highlighted_body"
)
...
...
lms/static/coffee/src/discussion/utils.coffee
View file @
57b70092
...
...
@@ -48,6 +48,7 @@ class @DiscussionUtil
update_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/update"
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"
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 @
57b70092
...
...
@@ -3,6 +3,8 @@ 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"
...
...
@@ -57,6 +59,20 @@ if Backbone?
else
@
vote
()
toggleFlagAbuse
:
(
event
)
->
event
.
preventDefault
()
if
window
.
user
in
@
model
.
get
(
"abuse_flaggers"
)
@
unFlagAbuse
()
else
@
flagAbuse
()
toggleFlagSpoiler
:
(
event
)
->
event
.
preventDefault
()
if
window
.
user
in
@
model
.
abuse_flaggers
@
unFlagAbuse
()
else
@
flagAbuse
()
toggleFollowing
:
(
event
)
->
$elem
=
$
(
event
.
target
)
url
=
null
...
...
@@ -82,6 +98,16 @@ if Backbone?
if
textStatus
==
'success'
@
model
.
set
(
response
,
{
silent
:
true
})
flagAbuse
:
->
url
=
@
model
.
urlFor
(
"flagAbuse"
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-flag-abuse"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
,
{
silent
:
true
})
unvote
:
->
window
.
user
.
unvote
(
@
model
)
url
=
@
model
.
urlFor
(
"unvote"
)
...
...
@@ -93,6 +119,17 @@ if Backbone?
if
textStatus
==
'success'
@
model
.
set
(
response
,
{
silent
:
true
})
unFlagAbuse
:
->
window
.
user
.
unvote
(
@
model
)
url
=
@
model
.
urlFor
(
"unvote"
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
,
{
silent
:
true
})
edit
:
(
event
)
->
@
trigger
"thread:edit"
,
event
...
...
lms/templates/discussion/_underscore_templates.html
View file @
57b70092
...
...
@@ -28,8 +28,10 @@
<
header
>
<
a
href
=
"#"
class
=
"vote-btn discussion-vote discussion-vote-up"
data
-
role
=
"discussion-vote"
data
-
tooltip
=
"vote"
>
<
span
class
=
"plus-icon"
>+<
/span> <span class='votes-count-number'>${'<%- votes
[
"up_count"
]
%>'}</
span
><
/a
>
<
a
href
=
"#"
class
=
"abuse-btn discussion-
vote discussion-vote-up"
data
-
role
=
"discussion-flag
"
data
-
tooltip
=
"flag as abusive"
>
<
a
href
=
"#"
class
=
"abuse-btn discussion-
flag-abuse"
data
-
role
=
"discussion-flag-abuse
"
data
-
tooltip
=
"flag as abusive"
>
<
span
class
=
"plus-icon"
>+<
/span> <span class='votes-count-number'>${'<%- abuse_flaggers.length%>'}</
span
><
/a
>
<
a
href
=
"#"
class
=
"abuse-btn discussion-flag-spoiler"
data
-
role
=
"discussion-flag-abuse"
data
-
tooltip
=
"flag as abusive"
>
<
span
class
=
"plus-icon"
>+<
/span> <span class='votes-count-number'>${'<%- spoiler_flaggers.length%>'}</
span
><
/a
>
<
h1
>
$
{
'<%- title %>'
}
<
/h1
>
<
p
class
=
"posted-details"
>
$
{
"<% if (obj.username) { %>"
}
...
...
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