reporting users works as well.
This commit is contained in:
parent
27558f83c4
commit
65e90e1c64
|
@ -43,3 +43,24 @@ $(document).on "click", "button[name=user-action]", ->
|
||||||
btn[0].dataset.action = 'follow'
|
btn[0].dataset.action = 'follow'
|
||||||
btn.attr 'class', 'btn btn-primary btn-block profile--follow-btn'
|
btn.attr 'class', 'btn btn-primary btn-block profile--follow-btn'
|
||||||
btn.html 'Follow'
|
btn.html 'Follow'
|
||||||
|
|
||||||
|
|
||||||
|
# report user
|
||||||
|
$(document).on "click", "a[data-action=report-user]", (ev) ->
|
||||||
|
ev.preventDefault()
|
||||||
|
btn = $(this)
|
||||||
|
target = btn[0].dataset.target
|
||||||
|
if confirm "Are you sure you want to report #{target}?"
|
||||||
|
$.ajax
|
||||||
|
url: '/ajax/report'
|
||||||
|
type: 'POST'
|
||||||
|
data:
|
||||||
|
id: target
|
||||||
|
type: 'user'
|
||||||
|
success: (data, status, jqxhr) ->
|
||||||
|
showNotification data.message, data.success
|
||||||
|
error: (jqxhr, status, error) ->
|
||||||
|
console.log jqxhr, status, error
|
||||||
|
showNotification "An error occurred, a developer should check the console for details", false
|
||||||
|
complete: (jqxhr, status) ->
|
||||||
|
btn.button "reset"
|
|
@ -16,7 +16,12 @@ class Ajax::ReportController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
object = params[:type].strip.capitalize.constantize.find params[:id]
|
object = if params[:type] == 'user'
|
||||||
|
User.find_by_screen_name params[:id]
|
||||||
|
else
|
||||||
|
params[:type].strip.capitalize.constantize.find params[:id]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if object.nil?
|
if object.nil?
|
||||||
@message = "Could not find #{params[:type]}"
|
@message = "Could not find #{params[:type]}"
|
||||||
|
|
|
@ -21,6 +21,6 @@
|
||||||
%i.fa.fa-minus-circle
|
%i.fa.fa-minus-circle
|
||||||
Block
|
Block
|
||||||
%li
|
%li
|
||||||
%a{href: '#', name: 'user-action', data: { action: :report, type: type, target: user.screen_name }}
|
%a{href: '#', data: { action: 'report-user', target: user.screen_name }}
|
||||||
%i.fa.fa-exclamation-triangle
|
%i.fa.fa-exclamation-triangle
|
||||||
Report
|
Report
|
Loading…
Reference in New Issue