Sha256: d836508e98198f37db81765007db361f3c742ec6dcfad0dec55ce6dd57bf8c3e

Contents?: true

Size: 894 Bytes

Versions: 13

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # The controller to handle the user's notifications deletion.
  class NotificationsController < Decidim::ApplicationController
    include HasSpecificBreadcrumb

    def index
      enforce_permission_to :read, :notification
    end

    def destroy
      notification = notifications.find(params[:id])
      enforce_permission_to(:destroy, :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

    def breadcrumb_item
      {
        label: t("layouts.decidim.user_menu.notifications"),
        active: true,
        url: notifications_path
      }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.28.4 app/controllers/decidim/notifications_controller.rb
decidim-core-0.29.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.28.3 app/controllers/decidim/notifications_controller.rb
decidim-core-0.29.0.rc4 app/controllers/decidim/notifications_controller.rb
decidim-core-0.29.0.rc3 app/controllers/decidim/notifications_controller.rb
decidim-core-0.29.0.rc2 app/controllers/decidim/notifications_controller.rb
decidim-core-0.29.0.rc1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.28.2 app/controllers/decidim/notifications_controller.rb
decidim-core-0.28.1 app/controllers/decidim/notifications_controller.rb
decidim-core-0.28.0 app/controllers/decidim/notifications_controller.rb
decidim-core-0.28.0.rc5 app/controllers/decidim/notifications_controller.rb
decidim-core-0.28.0.rc4 app/controllers/decidim/notifications_controller.rb