Commit 033ed6ce by Your Name

flagging done except returning abuse flaggers

parent 4dee832f
......@@ -15,7 +15,7 @@ class Thread(models.Model):
updatable_fields = [
'title', 'body', 'anonymous', 'anonymous_to_peers', 'course_id',
'closed', 'tags', 'user_id', 'commentable_id',
'closed', 'tags', 'user_id', 'commentable_id'
]
initializable_fields = updatable_fields
......@@ -80,21 +80,24 @@ class Thread(models.Model):
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}
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_flag_abuse_thread(voteable.id)
url = _url_for_unflag_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}
params = {'user_id': user.id}
request = perform_request('put', url, params)
voteable.update_attributes(request)
def _url_for_flag_abuse_thread(thread_id):
return "{prefix}/threads/{thread_id}/abuse_flags".format(prefix=settings.PREFIX, thread_id=thread_id)
def _url_for_unflag_abuse_thread(thread_id):
return "{prefix}/threads/{thread_id}/abuse_unflags".format(prefix=settings.PREFIX, thread_id=thread_id)
......@@ -121,7 +121,7 @@ if Backbone?
@trigger "change", @
unflagAbuse: ->
@get("abuse_flaggers").push window.user.get('id')
@get("abuse_flaggers").pop window.user.get('id')
@trigger "change", @
display_body: ->
......
......@@ -49,7 +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"
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"
......
......@@ -45,11 +45,11 @@ if Backbone?
renderFlagged: =>
if window.user.id in @model.get("abuse_flaggers")
@$("[thread-flag]").addClass("flagged")
@$("[thread-flag]").removeClass("notflagged")
@$("[data-role=thread-flag]").addClass("flagged")
@$("[data-role=thread-flag]").removeClass("notflagged")
else
@$("[thread-flag]").removeClass("flagged")
@$("[thread-flag]").addClass("notflagged")
@$("[data-role=thread-flag]").removeClass("flagged")
@$("[data-role=thread-flag]").addClass("notflagged")
updateModelDetails: =>
@renderVoted()
......@@ -70,10 +70,11 @@ if Backbone?
toggleFlagAbuse: (event) ->
event.preventDefault()
if window.user in @model.get("abuse_flaggers")
if window.user.id in @model.get("abuse_flaggers")
@unFlagAbuse()
else
@flagAbuse()
@renderFlagged()
toggleFollowing: (event) ->
......@@ -102,7 +103,6 @@ if Backbone?
@model.set(response, {silent: true})
flagAbuse: ->
alert('flag abuse')
url = @model.urlFor("flagAbuse")
DiscussionUtil.safeAjax
$elem: @$(".discussion-flag-abuse")
......@@ -124,7 +124,6 @@ if Backbone?
@model.set(response, {silent: true})
unFlagAbuse: ->
alert('unflag abuse')
url = @model.urlFor("unFlagAbuse")
DiscussionUtil.safeAjax
$elem: @$(".discussion-flag-abuse")
......
......@@ -44,7 +44,7 @@
</header>
<div class="post-body">${'<%- body %>'}</div>
<a href="#" class="discussion-flag-abuse <% if user in abuse_flaggers %>flagged <%else%> notflagged<%end%> " data-role="thread-flag" data-tooltip="flag">
<a href="#" class="discussion-flag-abuse notflagged" data-role="thread-flag" data-tooltip="flag">
<i class="icon"></i>Report Misuse</a>
${'<% if (obj.courseware_url) { %>'}
<div class="post-context">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment