Sha256: 959c72e22c5ba9395fa75deb4bfe444a4690ba377d761e415a5430c7606a18a9

Contents?: true

Size: 707 Bytes

Versions: 65

Compression:

Stored size: 707 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # The controller to handle the user's notifications deletion.
  class NotificationsController < Decidim::ApplicationController
    def index
      enforce_permission_to :read, :notification
    end

    def destroy
      notification = notifications.find(params[:id])
      enforce_permission_to :destroy, :notification, notification: notification
      notification.destroy
    end

    def read_all
      enforce_permission_to :destroy, :notification, notification: notifications.first
      notifications.destroy_all
    end

    private

    def notifications
      @notifications ||= current_user.notifications.order(created_at: :desc)
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.8 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.7 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.6 app/controllers/decidim/notifications_controller.rb
decidim-core-0.26.10 app/controllers/decidim/notifications_controller.rb
decidim-core-0.26.9 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.5 app/controllers/decidim/notifications_controller.rb
decidim-core-0.26.8 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.4 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.3 app/controllers/decidim/notifications_controller.rb
decidim-core-0.26.7 app/controllers/decidim/notifications_controller.rb
decidim-core-0.26.5 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.2 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.26.4 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.26.3 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.0.rc2 app/controllers/decidim/notifications_controller.rb
decidim-core-0.27.0.rc1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.26.2 app/controllers/decidim/notifications_controller.rb