Fix and refactor active menu. Refs #207
This commit is contained in:
parent
a2c14313ed
commit
ec21c042dd
|
@ -29,8 +29,6 @@ class Ability
|
|||
else # Registered user rights
|
||||
if user.admin?
|
||||
can :manage, :all
|
||||
# Resque authorize
|
||||
can :manage, Resque
|
||||
# Protection
|
||||
cannot :approve, RegisterRequest, :approved => true
|
||||
cannot :reject, RegisterRequest, :rejected => true
|
||||
|
|
|
@ -5,5 +5,3 @@
|
|||
%li= link_to title, send(:"#{namespace}#{base}_path"), :class => top_menu_class(base)
|
||||
- if current_user.try(:admin?) and which_menu == 'top_menu'
|
||||
%li= link_to t('admins_menu_header'), admin_users_path, :class => top_menu_class('admin')
|
||||
- if current_user.try(:admin?) and which_menu == 'admins_menu'
|
||||
%li= link_to t('resque_server'), admin_resque_server_path, :class => top_menu_class('admin')
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# config/initializers/admin.rb
|
||||
class CanAccessResque
|
||||
def self.matches?(request)
|
||||
current_user = request.env['warden'].user
|
||||
return false if current_user.blank?
|
||||
Ability.new(current_user).can? :manage, Resque
|
||||
end
|
||||
end
|
|
@ -12,3 +12,6 @@ Rosa::Application.config.middleware.insert_after ::Rails::Rack::Logger, ::Grack:
|
|||
Rosa::Application.config.middleware.insert_before ::Grack::Handler, ::Grack::Auth
|
||||
|
||||
Rosa::Application.config.action_mailer.default_url_options = { :host => APP_CONFIG['action_mailer_host'] } if APP_CONFIG['action_mailer_host']
|
||||
|
||||
require 'resque/server'
|
||||
::ResqueServer = ::Resque::Server # need for CanCan
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
Rosa::Application.routes.draw do
|
||||
require 'resque/server'
|
||||
|
||||
devise_scope :users do
|
||||
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
||||
end
|
||||
|
@ -24,10 +22,6 @@ Rosa::Application.routes.draw do
|
|||
end
|
||||
|
||||
namespace :admin do
|
||||
constraints CanAccessResque do
|
||||
mount Resque::Server, at: 'resque'
|
||||
end
|
||||
|
||||
resources :users do
|
||||
get :list, :on => :collection
|
||||
end
|
||||
|
@ -39,6 +33,9 @@ Rosa::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
resources :event_logs, :only => :index
|
||||
constraints AdminAccess do
|
||||
mount Resque::Server => 'resque'
|
||||
end
|
||||
end
|
||||
|
||||
resources :advisories, :only => [:index, :show]
|
||||
|
|
|
@ -10,3 +10,9 @@ class OwnerConstraint
|
|||
@class_name.send(@finder, request.params[:uname]).present?
|
||||
end
|
||||
end
|
||||
|
||||
class AdminAccess
|
||||
def self.matches?(request)
|
||||
!!request.env['warden'].user.try(:admin?)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue