diff --git a/app/models/concerns/flash_notify/finders.rb b/app/models/concerns/flash_notify/finders.rb deleted file mode 100644 index 14f6e5bd7..000000000 --- a/app/models/concerns/flash_notify/finders.rb +++ /dev/null @@ -1,33 +0,0 @@ -# Private: Finders of all sorts: methods to find FlashNotify records, methods to find -# other records which belong to given FlashNotify. -# -# This module gets included into FlashNotify. -module FlashNotify::Finders - extend ActiveSupport::Concern - - included do - scope :published, -> { where(published: true) } - - after_commit :clear_caches - after_touch :clear_caches - end - - module ClassMethods - - # Public: Get cached first published FlashNotify record. - # - # Returns FlashNotify record or nil. - def published_first_cached - Rails.cache.fetch('FlashNotify.published.first') do - published.first - end - end - end - - protected - - # Private: after_commit and after_touch hook which clears find_cached cache. - def clear_caches - Rails.cache.delete('FlashNotify.published.first') - end -end diff --git a/app/models/flash_notify.rb b/app/models/flash_notify.rb deleted file mode 100644 index e725175fa..000000000 --- a/app/models/flash_notify.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'digest/md5' - -class FlashNotify < ActiveRecord::Base - include FlashNotify::Finders - - STATUSES = %w[error success info] - - validates :status, inclusion: {in: STATUSES} - validates :body_ru, :body_en, :status, presence: true - - def hash_id - @digest ||= Digest::MD5.hexdigest("#{self.id}-#{self.updated_at}") - end - - def body(language) - read_attribute("body_#{language}") - end - - def should_show?(cookie_hash_id) - cookie_hash_id != hash_id && published - end -end diff --git a/app/views/layouts/_notifies.html.haml b/app/views/layouts/_notifies.html.haml deleted file mode 100644 index 8a039b690..000000000 --- a/app/views/layouts/_notifies.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -- if current_user || APP_CONFIG['anonymous_access'] - .flash_notify - - if (flash_notify = FlashNotify.published_first_cached) && flash_notify.should_show?(cookies[:flash_notify_hash]) - .alert{class: "alert-#{flash_notify.status}"} - = flash_notify.body(I18n.locale).html_safe - %a.close#close-alert{:'data-dismiss'=>"alert", href: "#"} × - - :javascript - var FLASH_HASH_ID = "#{flash_notify.hash_id}";