diff --git a/app/controllers/moderation_controller.rb b/app/controllers/moderation_controller.rb index ad56f876..5e4ef475 100644 --- a/app/controllers/moderation_controller.rb +++ b/app/controllers/moderation_controller.rb @@ -1,4 +1,12 @@ class ModerationController < ApplicationController + before_filter :authenticate_user! + def index + @type = params[:type] + @reports = if @type == 'all' + Report.where(deleted: false).reverse_order + else + Report.where(deleted: false).where('LOWER(type) = ?', "reports::#{@type}").reverse_order + end end end diff --git a/app/views/moderation/_moderation_tabs.html.haml b/app/views/moderation/_moderation_tabs.html.haml index e85ddb21..05d93880 100644 --- a/app/views/moderation/_moderation_tabs.html.haml +++ b/app/views/moderation/_moderation_tabs.html.haml @@ -2,7 +2,8 @@ .panel.panel-default .panel-body %ul.nav.nav-pills.nav-stacked - = nav_entry "All reports", "#" - = nav_entry "Users", "#" - = nav_entry "Answers", "#" - = nav_entry "Comments", "#" \ No newline at end of file + = nav_entry "All reports", moderation_path + = nav_entry "Answers", moderation_path('answer') + = nav_entry "Comments", moderation_path('comment') + = nav_entry "Users", moderation_path('user') + = nav_entry "Questions", moderation_path('question') diff --git a/app/views/moderation/index.html.haml b/app/views/moderation/index.html.haml index f9f64d5e..a2407e94 100644 --- a/app/views/moderation/index.html.haml +++ b/app/views/moderation/index.html.haml @@ -2,5 +2,5 @@ .row = render 'moderation/moderation_tabs' .col-md-9.col-sm-9.col-xs-12 - - Report.where(deleted: false).reverse_order.each do |r| + - @reports.each do |r| = render 'moderation/moderationbox', report: r \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 298ee719..49f115f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,7 +13,7 @@ Rails.application.routes.draw do # Moderation panel constraints ->(req) { req.env['warden'].authenticate?(scope: :user) && (req.env['warden'].user.admin? or req.env['warden'].user.moderator?) } do - match '/moderation', to: 'moderation#index', via: :get, as: :moderation + 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 match '/mod/create_comment', to: 'moderation#create_comment', via: :post, as: :mod_create_comment