From 32f2a4f2a147dd93cc59458a3d2599cce1bebcd1 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 17 Aug 2015 22:30:24 +0200 Subject: [PATCH 1/3] adds admin verification to view stats --- app/controllers/stats_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) 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 From 89aab092b4c222d58acdc1c100faa17d16b14f55 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 17 Aug 2015 22:36:00 +0200 Subject: [PATCH 2/3] upgrades ahoy gem --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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) From c56742118cb3b9bf14f1cfb67ac3732f7365f2b1 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 17 Aug 2015 22:36:24 +0200 Subject: [PATCH 3/3] adds stats to admin menu --- app/views/admin/_menu.html.erb | 7 +++++++ config/locales/admin.en.yml | 1 + config/locales/admin.es.yml | 1 + 3 files changed, 9 insertions(+) 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 %> + +
  • + <%= link_to stats_path do %> + + <%= t('admin.menu.stats') %> + <% end %> +
  • diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 76bd55598..154cde012 100644 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -14,6 +14,7 @@ en: hidden_debates: Hidden debates hidden_comments: Hidden comments officials: Officials + stats: Statistics actions: hide: Hide restore: Restore diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 4889f4813..419300cf9 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -14,6 +14,7 @@ es: hidden_debates: Debates ocultos hidden_comments: Comentarios ocultos officials: Cargos públicos + stats: Estadísticas actions: hide: Ocultar restore: Permitir