Moderation Priority + IP
This commit is contained in:
parent
79cf463cf2
commit
deb6d12108
|
@ -9,4 +9,52 @@ class ModerationController < ApplicationController
|
|||
Report.where(deleted: false).where('LOWER(type) = ?', "reports::#{@type}").reverse_order
|
||||
end
|
||||
end
|
||||
|
||||
def priority
|
||||
@user_id = params[:user_id]
|
||||
if @user_id.nil?
|
||||
@users = {}
|
||||
Report.where(deleted: false).each do |report|
|
||||
target = if report.target.is_a? User
|
||||
report.target
|
||||
else
|
||||
next if report.target.user.nil?
|
||||
report.target.user
|
||||
end
|
||||
|
||||
@users[target] ||= 0
|
||||
@users[target] += 1
|
||||
end
|
||||
|
||||
@users = @users.sort_by do |k, v|
|
||||
v
|
||||
end.reverse.to_h
|
||||
else
|
||||
@user_id = @user_id.to_i
|
||||
@type = 'all'
|
||||
@reports = []
|
||||
Report.where(deleted: false).each do |report|
|
||||
if report.target.is_a? User
|
||||
@reports.push report if report.target.id == @user_id
|
||||
else
|
||||
next if report.target.user.nil?
|
||||
@reports.push report if report.target.user.id == @user_id
|
||||
end
|
||||
end
|
||||
|
||||
@target_user = User.find(@user_id)
|
||||
render template: 'moderation/index'
|
||||
end
|
||||
end
|
||||
|
||||
def ip
|
||||
@user_id = params[:user_id]
|
||||
@host = User.find(@user_id)
|
||||
@users = []
|
||||
return if @host.nil?
|
||||
@users = User.where('(current_sign_in_ip = ? OR last_sign_in_ip = ?) AND id != ?', @host.current_sign_in_ip, @host.last_sign_in_ip, @user_id)
|
||||
@users.unshift @host
|
||||
|
||||
render template: 'moderation/priority'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
%a.btn.btn-default.btn-block{href: moderation_priority_path(user.id)}
|
||||
View reports relating to user
|
||||
%a.btn.btn-default.btn-block{href: moderation_ip_path(user.id)}
|
||||
View users with same IP
|
|
@ -14,3 +14,4 @@
|
|||
= nav_entry t('views.general.comment').pluralize(2), moderation_path('comment')
|
||||
= nav_entry t('views.general.user').pluralize(2) , moderation_path('user')
|
||||
= nav_entry t('views.general.question').pluralize(2), moderation_path('question')
|
||||
= nav_entry 'Priority', moderation_priority_path
|
||||
|
|
|
@ -6,3 +6,4 @@
|
|||
= list_group_item t('views.general.comment').pluralize(2), moderation_path('comment')
|
||||
= list_group_item t('views.general.user').pluralize(2), moderation_path('user')
|
||||
= list_group_item t('views.general.question').pluralize(2), moderation_path('question')
|
||||
= list_group_item 'Priority', moderation_priority_path
|
||||
|
|
|
@ -12,18 +12,24 @@
|
|||
%p
|
||||
%b= t 'views.moderation.moderationbox.reason'
|
||||
%br
|
||||
- (report.reason || "No reason provided.").lines.each do |reason|
|
||||
- next unless reason.strip.length > 0
|
||||
= reason.strip
|
||||
%br
|
||||
- if report.reason.nil? or report.reason.strip.blank?
|
||||
No reason provided
|
||||
- else
|
||||
- report.reason.lines.each do |reason|
|
||||
- next if reason.strip.blank?
|
||||
= reason.strip
|
||||
.row
|
||||
.col-md-6.col-sm-4.col-xs-6.text-left
|
||||
.col-md-8.col-sm-8.col-xs-8.text-left
|
||||
%a.btn.btn-primary{href: content_url(report)}
|
||||
= t('views.moderation.moderationbox.view', content: report.type.sub('Reports::', ''))
|
||||
- if report.target.respond_to? :user and not report.target.user.nil?
|
||||
%a.btn.btn-primary{href: show_user_profile_path(report.target.user.screen_name)}
|
||||
= t('views.moderation.moderationbox.view', content: t('views.general.user'))
|
||||
.col-md-6.col-sm-8.col-xs-6.text-right
|
||||
%a.btn.btn-primary{href: moderation_priority_path(report.target.user.id)}
|
||||
Reports
|
||||
%a.btn.btn-primary{href: moderation_ip_path(report.target.user.id)}
|
||||
IP
|
||||
.col-md-4.col-sm-4.col-xs-4.text-right
|
||||
%span.mod-count{id: "mod-count-#{report.id}"}
|
||||
= report.votes
|
||||
.btn-group
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
.panel.panel-default
|
||||
.panel-body
|
||||
.media
|
||||
.pull-left
|
||||
%img.img-rounded.profile--img{src: gravatar_url(user)}
|
||||
.media-body
|
||||
- if user.display_name.blank?
|
||||
%h2
|
||||
%a{href: show_user_profile_path(user.screen_name)}
|
||||
= user.screen_name
|
||||
- else
|
||||
%h2.profile--displayname
|
||||
%a{href: show_user_profile_path(user.screen_name)}
|
||||
= user.display_name
|
||||
%h4.text-muted.profile--username= user.screen_name
|
||||
.row
|
||||
.col-md-12.col-sm-12.col-xs-12
|
||||
- unless count.nil?
|
||||
%h4.entry-text#asked-count
|
||||
= count
|
||||
= 'Report'.pluralize(user.asked_count)
|
||||
%br
|
||||
%br
|
||||
- else
|
||||
%br
|
||||
= render 'actions', user: user
|
|
@ -0,0 +1,16 @@
|
|||
- provide(:title, generate_title("Moderation"))
|
||||
= render 'moderation/moderation_nav'
|
||||
.container.j2-page
|
||||
.row
|
||||
= render 'moderation/moderation_tabs'
|
||||
.col-md-9.col-sm-9.col-xs-12
|
||||
%h2
|
||||
- if @host.nil?
|
||||
Users sorted by reports
|
||||
- else
|
||||
Users with the same IP
|
||||
#users
|
||||
.row
|
||||
- @users.each do |u, c|
|
||||
.col-md-4.col-sm-12col-xs-12
|
||||
= render 'moderation/userbox', user: u, count: c
|
|
@ -13,6 +13,8 @@ Rails.application.routes.draw do
|
|||
# Moderation panel
|
||||
constraints ->(req) { req.env['warden'].authenticate?(scope: :user) &&
|
||||
(req.env['warden'].user.mod?) } do
|
||||
match '/moderation/priority(/:user_id)', to: 'moderation#priority', via: :get, as: :moderation_priority
|
||||
match '/moderation/ip/:user_id', to: 'moderation#ip', via: :get, as: :moderation_ip
|
||||
match '/moderation(/:type)', to: 'moderation#index', via: :get, as: :moderation, defaults: {type: 'all'}
|
||||
namespace :ajax do
|
||||
match '/mod/destroy_report', to: 'moderation#destroy_report', via: :post, as: :mod_destroy_report
|
||||
|
|
Loading…
Reference in New Issue