Disallow reporting and upvoting of your own posts in discussion forums
This commit is contained in:
@@ -387,3 +387,24 @@ describe "DiscussionThreadView", ->
|
||||
"Showing first 6 responses",
|
||||
"Load all responses"
|
||||
)
|
||||
|
||||
describe "post restrictions", ->
|
||||
beforeEach ->
|
||||
@thread.attributes.ability = _.extend(@thread.attributes.ability, {
|
||||
can_report: false
|
||||
can_vote: false
|
||||
})
|
||||
@view = new DiscussionThreadView(
|
||||
model: @thread
|
||||
el: $("#fixture-element")
|
||||
mode: "tab"
|
||||
course_settings: DiscussionSpecHelper.makeCourseSettings()
|
||||
)
|
||||
|
||||
it "doesn't show report option if can_report ability is disabled", ->
|
||||
@view.render()
|
||||
expect(@view.$el.find(".action-report").closest(".actions-item")).toHaveClass('is-hidden')
|
||||
|
||||
it "doesn't show voting button if can_vote ability is disabled", ->
|
||||
@view.render()
|
||||
expect(@view.$el.find(".action-vote").closest(".actions-item")).toHaveClass('is-hidden')
|
||||
|
||||
@@ -11,6 +11,8 @@ if Backbone?
|
||||
can_reply: '.discussion-reply'
|
||||
can_delete: '.admin-delete'
|
||||
can_openclose: '.admin-openclose'
|
||||
can_report: '.admin-report'
|
||||
can_vote: '.admin-vote'
|
||||
|
||||
urlMappers: {}
|
||||
|
||||
@@ -97,7 +99,7 @@ if Backbone?
|
||||
pinned = @get("pinned")
|
||||
@set("pinned",pinned)
|
||||
@trigger "change", @
|
||||
|
||||
|
||||
flagAbuse: ->
|
||||
temp_array = @get("abuse_flaggers")
|
||||
temp_array.push(window.user.get('id'))
|
||||
@@ -123,7 +125,7 @@ if Backbone?
|
||||
|
||||
unvote: ->
|
||||
@incrementVote(-1)
|
||||
|
||||
|
||||
class @Thread extends @Content
|
||||
urlMappers:
|
||||
'retrieve' : -> DiscussionUtil.urlFor('retrieve_single_thread', @.get('commentable_id'), @id)
|
||||
|
||||
@@ -33,6 +33,12 @@ if Backbone?
|
||||
[".action-close", ".action-pin"],
|
||||
(selector) => @$(selector).closest(".actions-item").addClass("is-hidden")
|
||||
)
|
||||
can_report:
|
||||
enable: -> @$(".action-report").closest(".actions-item").removeClass("is-hidden")
|
||||
disable: -> @$(".action-report").closest(".actions-item").addClass("is-hidden")
|
||||
can_vote:
|
||||
enable: -> @$(".action-vote").closest(".actions-item").removeClass("is-hidden")
|
||||
disable: -> @$(".action-vote").closest(".actions-item").addClass("is-hidden")
|
||||
|
||||
renderPartialAttrs: ->
|
||||
for attr, value of @model.changedAttributes()
|
||||
|
||||
Reference in New Issue
Block a user