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.23.3 app/controllers/decidim/notifications_controller.rb
decidim-core-0.23.2 app/controllers/decidim/notifications_controller.rb
decidim-core-0.23.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.23.1.rc1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.23.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.22.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.21.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.20.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.20.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.19.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.18.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.19.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.17.2 app/controllers/decidim/notifications_controller.rb
decidim-core-0.18.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.17.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.16.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.17.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.16.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.15.2 app/controllers/decidim/notifications_controller.rb
decidim-core-0.15.1 app/controllers/decidim/notifications_controller.rb