From 24b875090b4b0fbffea9f655cc30f8623e76b6a6 Mon Sep 17 00:00:00 2001 From: Marco Metz Date: Fri, 17 Apr 2015 18:30:41 +0200 Subject: [PATCH] Vitasteps haben nun einen Status --- Gemfile | 1 + Gemfile.lock | 6 +++++- admin/dashboards.rb | 19 +++++++++++++++++++ app/models/goldencobra/vita.rb | 3 +++ config/locales/active_admin.de.yml | 1 + config/locales/active_admin.en.yml | 1 + ...54_add_status_to_goldencobra_vita_steps.rb | 5 +++++ goldencobra.gemspec | 1 + 8 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20150417153454_add_status_to_goldencobra_vita_steps.rb diff --git a/Gemfile b/Gemfile index 220e8b96..c330a158 100644 --- a/Gemfile +++ b/Gemfile @@ -40,6 +40,7 @@ gem 'cancan' #gem 'linkchecker', :git => "http://github.com/seb/linkchecker.git" gem 'rmagick' +gem 'simple_enum' gem "paper_trail" diff --git a/Gemfile.lock b/Gemfile.lock index bdce65a4..a65ecfd9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,7 +38,7 @@ GIT PATH remote: . specs: - goldencobra (1.4.25) + goldencobra (1.4.26) activeadmin activeadmin-cancan acts-as-taggable-on @@ -81,6 +81,7 @@ PATH sass sass-rails sidekiq (= 3.2.1) + simple_enum sinatra slim sprockets @@ -494,6 +495,8 @@ GEM json redis (>= 3.0.6) redis-namespace (>= 1.3.1) + simple_enum (1.6.9) + activesupport (>= 3.0.0) sinatra (1.4.5) rack (~> 1.4) rack-protection (~> 1.4) @@ -604,6 +607,7 @@ DEPENDENCIES selenium-webdriver shoulda-matchers sidekiq + simple_enum sinatra slim sunspot_rails diff --git a/admin/dashboards.rb b/admin/dashboards.rb index 880c4cad..f446414e 100644 --- a/admin/dashboards.rb +++ b/admin/dashboards.rb @@ -54,6 +54,25 @@ end end + section I18n.t('active_admin.dashboards.vita_steps'), priority: 2, :if => proc{can?(:update, Goldencobra::Vita)} do + table do + tr do + ["Source", I18n.t("activerecord.attributes.goldencobra/widget.title"), "Description", ""].each do |sa| + th sa + end + end + + Goldencobra::Vita.where(status_cd: 2).last(5).each do |vita| + tr do + td "#{vita.loggable_type} ID:#{vita.loggable_id}" + td vita.title + td vita.description + td l(vita.created_at, format: :short) + end + end + end + end + # == Render Partial Section # The block is rendered within the context of the view, so you can # easily render a partial rather than build content in ruby. diff --git a/app/models/goldencobra/vita.rb b/app/models/goldencobra/vita.rb index 69273c7e..ef354bd0 100644 --- a/app/models/goldencobra/vita.rb +++ b/app/models/goldencobra/vita.rb @@ -19,5 +19,8 @@ class Vita < ActiveRecord::Base belongs_to :loggable, :polymorphic => true attr_accessible :description, :title, :user_id acts_as_taggable_on :tags + + as_enum :status, success: 0, warning: 1, error: 2 + end end diff --git a/config/locales/active_admin.de.yml b/config/locales/active_admin.de.yml index 1404fff4..9da59e5b 100644 --- a/config/locales/active_admin.de.yml +++ b/config/locales/active_admin.de.yml @@ -318,6 +318,7 @@ de: title2: "Artikel bearbeiten" title3: "Neuen Unterartikel erstellen" widget_section: "Neueste Schnipsel" + vita_steps: "Vita Step Errors" title4: "Schnipsel bearbeiten" new_link: "Neuen Artikel erstellen" domains: diff --git a/config/locales/active_admin.en.yml b/config/locales/active_admin.en.yml index 90f1b5c9..724e5dd1 100644 --- a/config/locales/active_admin.en.yml +++ b/config/locales/active_admin.en.yml @@ -318,6 +318,7 @@ en: title2: "Edit article" title3: "Create new sub article" widget_section: "Newest widget" + vita_steps: "Vita Step Errors" title4: "Edit widget" new_link: "Create new article" domains: diff --git a/db/migrate/20150417153454_add_status_to_goldencobra_vita_steps.rb b/db/migrate/20150417153454_add_status_to_goldencobra_vita_steps.rb new file mode 100644 index 00000000..c55eeca3 --- /dev/null +++ b/db/migrate/20150417153454_add_status_to_goldencobra_vita_steps.rb @@ -0,0 +1,5 @@ +class AddStatusToGoldencobraVitaSteps < ActiveRecord::Migration + def change + add_column :goldencobra_vita, :status_cd, :integer, :default => 0 + end +end diff --git a/goldencobra.gemspec b/goldencobra.gemspec index 43de3701..852ea6ff 100644 --- a/goldencobra.gemspec +++ b/goldencobra.gemspec @@ -75,6 +75,7 @@ Gem::Specification.new do |s| s.add_dependency 'iconv' s.add_dependency 'cocaine', '0.5.5' s.add_dependency 'rack-utf8_sanitizer' + s.add_dependency 'simple_enum' # s.add_dependency "wicked_pdf" s.add_development_dependency "mysql2" s.add_development_dependency 'annotate'