made tabs work
This commit is contained in:
parent
34a2f3cd6b
commit
27558f83c4
|
@ -1,4 +1,12 @@
|
||||||
class ModerationController < ApplicationController
|
class ModerationController < ApplicationController
|
||||||
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def index
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-body
|
.panel-body
|
||||||
%ul.nav.nav-pills.nav-stacked
|
%ul.nav.nav-pills.nav-stacked
|
||||||
= nav_entry "All reports", "#"
|
= nav_entry "All reports", moderation_path
|
||||||
= nav_entry "Users", "#"
|
= nav_entry "Answers", moderation_path('answer')
|
||||||
= nav_entry "Answers", "#"
|
= nav_entry "Comments", moderation_path('comment')
|
||||||
= nav_entry "Comments", "#"
|
= nav_entry "Users", moderation_path('user')
|
||||||
|
= nav_entry "Questions", moderation_path('question')
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
.row
|
.row
|
||||||
= render 'moderation/moderation_tabs'
|
= render 'moderation/moderation_tabs'
|
||||||
.col-md-9.col-sm-9.col-xs-12
|
.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
|
= render 'moderation/moderationbox', report: r
|
|
@ -13,7 +13,7 @@ Rails.application.routes.draw do
|
||||||
# Moderation panel
|
# Moderation panel
|
||||||
constraints ->(req) { req.env['warden'].authenticate?(scope: :user) &&
|
constraints ->(req) { req.env['warden'].authenticate?(scope: :user) &&
|
||||||
(req.env['warden'].user.admin? or req.env['warden'].user.moderator?) } do
|
(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
|
namespace :ajax do
|
||||||
match '/mod/destroy_report', to: 'moderation#destroy_report', via: :post, as: :mod_destroy_report
|
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
|
match '/mod/create_comment', to: 'moderation#create_comment', via: :post, as: :mod_create_comment
|
||||||
|
|
Loading…
Reference in New Issue