diff --git a/Gemfile b/Gemfile index c20395b85..de35b0b26 100644 --- a/Gemfile +++ b/Gemfile @@ -36,7 +36,7 @@ gem 'initialjs-rails' gem 'unicorn' gem 'paranoia' -gem 'ahoy_matey' # stats +gem 'ahoy_matey', '~> 1.2.1' gem 'groupdate' # group temporary data group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index f64a46d7d..2753c16ba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,7 +44,7 @@ GEM awesome_nested_set (>= 3.0) acts_as_votable (0.10.0) addressable (2.3.8) - ahoy_matey (1.2.0) + ahoy_matey (1.2.1) addressable browser (>= 0.4.0) errbase @@ -338,7 +338,7 @@ DEPENDENCIES acts-as-taggable-on acts_as_commentable_with_threading acts_as_votable - ahoy_matey + ahoy_matey (~> 1.2.1) byebug cancancan capistrano (= 3.4.0) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index c33f6843e..1e76feb42 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -1,5 +1,14 @@ class StatsController < ApplicationController + skip_authorization_check + before_action :verify_administrator + def show @event_types = Ahoy::Event.select(:name).uniq.pluck(:name) end + + private + + def verify_administrator + raise CanCan::AccessDenied unless current_user.try(:administrator?) + end end diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 5ade5615a..e91ca7a7b 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -38,5 +38,12 @@ <%= t('admin.menu.settings') %> <% end %> + +