made tabs work

This commit is contained in:
nilsding 2014-12-29 01:25:48 +01:00
parent 34a2f3cd6b
commit 27558f83c4
4 changed files with 15 additions and 6 deletions

View File

@ -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

View File

@ -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", "#"
= 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')

View File

@ -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

View File

@ -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