Merge pull request #520 from warpc/207-platform_clone
[refs #207] Fix and refactor active menu.
This commit is contained in:
commit
6775372eca
|
@ -29,8 +29,6 @@ class Ability
|
||||||
else # Registered user rights
|
else # Registered user rights
|
||||||
if user.admin?
|
if user.admin?
|
||||||
can :manage, :all
|
can :manage, :all
|
||||||
# Resque authorize
|
|
||||||
can :manage, Resque
|
|
||||||
# Protection
|
# Protection
|
||||||
cannot :approve, RegisterRequest, :approved => true
|
cannot :approve, RegisterRequest, :approved => true
|
||||||
cannot :reject, RegisterRequest, :rejected => true
|
cannot :reject, RegisterRequest, :rejected => true
|
||||||
|
|
|
@ -5,5 +5,3 @@
|
||||||
%li= link_to title, send(:"#{namespace}#{base}_path"), :class => top_menu_class(base)
|
%li= link_to title, send(:"#{namespace}#{base}_path"), :class => top_menu_class(base)
|
||||||
- if current_user.try(:admin?) and which_menu == 'top_menu'
|
- 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')
|
%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
|
|
||||||
|
|
|
@ -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.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']
|
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 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Rosa::Application.routes.draw do
|
Rosa::Application.routes.draw do
|
||||||
require 'resque/server'
|
|
||||||
|
|
||||||
devise_scope :users do
|
devise_scope :users do
|
||||||
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
||||||
end
|
end
|
||||||
|
@ -24,10 +22,6 @@ Rosa::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
constraints CanAccessResque do
|
|
||||||
mount Resque::Server, at: 'resque'
|
|
||||||
end
|
|
||||||
|
|
||||||
resources :users do
|
resources :users do
|
||||||
get :list, :on => :collection
|
get :list, :on => :collection
|
||||||
end
|
end
|
||||||
|
@ -39,6 +33,9 @@ Rosa::Application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :event_logs, :only => :index
|
resources :event_logs, :only => :index
|
||||||
|
constraints AdminAccess do
|
||||||
|
mount Resque::Server => 'resque'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :advisories, :only => [:index, :show]
|
resources :advisories, :only => [:index, :show]
|
||||||
|
|
|
@ -10,3 +10,9 @@ class OwnerConstraint
|
||||||
@class_name.send(@finder, request.params[:uname]).present?
|
@class_name.send(@finder, request.params[:uname]).present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class AdminAccess
|
||||||
|
def self.matches?(request)
|
||||||
|
!!request.env['warden'].user.try(:admin?)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue