Sha256: d66c305a859eb21f0c444f7b9dae8c769bf693c32b70513d741d12799be4b493

Contents?: true

Size: 1.46 KB

Versions: 13

Compression:

Stored size: 1.46 KB

Contents

= Events

The concept regarding the notification is being described in the xref:develop:notifications.adoc[Notifications] page.

- To dispatch notifications in the user account when something happens on a resource or a space they are following
- To dispatch emails for the above notifications, if the user has not enabled the mail digest
- To dispatch push notifications  when the installation is active and the user has enabled them
- To show the activity done by the user in the user's account page
- In admin panel to show the activity of other admins
- To dispatch emails to admins when a resource or user is reported
- To dispatch emails to users when an admin performs an action on the resource owned (like approving Proposal, accepting budgets etc )

Event classes are located in the `app/events/decidim/<my_module>` directory, and named: `<my_resource>_event.rb`.

```ruby
# frozen_string_literal: true

# app/events/decidim/my_module/my_resource_event.rb
module Decidim
  module MyModule
    class MyResourceEvent < Decidim::Events::SimpleEvent
      # Defines a list of methods that will be used to translate the resource inside the event.
      i18n_attributes :example_resource_title

      # The name of the method can be 100% customized, but it must return a string.
      # the resource object used in the method body is the object that is being handled by the event.
      def example_resource_title
        translated_attribute(resource.title)
      end
    end
  end
end
```

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-0.29.1 docs/modules/develop/pages/classes/events.adoc
decidim-0.28.4 docs/modules/develop/pages/classes/events.adoc
decidim-0.29.0 docs/modules/develop/pages/classes/events.adoc
decidim-0.28.3 docs/modules/develop/pages/classes/events.adoc
decidim-0.29.0.rc4 docs/modules/develop/pages/classes/events.adoc
decidim-0.29.0.rc3 docs/modules/develop/pages/classes/events.adoc
decidim-0.29.0.rc2 docs/modules/develop/pages/classes/events.adoc
decidim-0.29.0.rc1 docs/modules/develop/pages/classes/events.adoc
decidim-0.28.2 docs/modules/develop/pages/classes/events.adoc
decidim-0.28.1 docs/modules/develop/pages/classes/events.adoc
decidim-0.28.0 docs/modules/develop/pages/classes/events.adoc
decidim-0.28.0.rc5 docs/modules/develop/pages/classes/events.adoc
decidim-0.28.0.rc4 docs/modules/develop/pages/classes/events.adoc