OpenWISP Notifications Release 0.1.0

Gagan Deep
5 min readSep 2, 2020

What is OpenWISP Notifications?

As the name suggests OpenWISP Notifications is the notifications module of the OpenWISP eco-system. It aims to abstract and simplifies generating and sending notifications. Users not only receive notifications on the OpenWISP user interface but are also notified through emails.

Why OpenWISP Notifications?

One of the important aspects of managing a network is monitoring. And monitoring will be vague if maintainers are not notified of critical events in the network. This is where OpenWISP Notifications comes to play, aiding in the monitoring of your network.

Do one thing, and do it well.

OpenWISP derives its core values from The UNIX Philosophy. Instead of having a single application, we have multiple modules that ace at their work. These modules orchestrate at deployment providing the one-stop open-source network management solution we can rely on.

What “OpenWISP Notifications 0.1.0” has to offer?

Like any other OpenWISP module, OpenWISP Notifications is built on top of Django. We have made sure that OpenWISP Notifications works out of the box with minimal configuration required.

Notable features of OpenWISP Notifications

  • Notification Widget
  • Real-time Notifications
  • Notification Preferences

Notification Widget

OpenWISP Notifications introduces a notification widget on OpenWISP’s user interface which allows users to browse notifications from their network and get things done quickly.

Notification Widget

The widget allows users to quickly check all notification from their network. Hovering over an unread notification marks it as read. It also provides an option to filter only unread notifications. For users in a hurry, it also provides a single button to mark all notifications as read. Users can also check the count of unread notifications from the counter over the notification bell at a glance.

Real-time Notifications

OpenWISP Notifications delivers notifications to logged-in users in real-time. Through “Notification Toast” users get notified of new notifications on their screen. Interacting with Notification Toasts also marks that notification as read.

Notification Toasts

Notification Preferences

OpenWISP Notifications aims to give users control of their notifications. It allows users to choose the category(type) of notifications they receive for each organization they are members of. Along with that, it also allows users to choose their preferred medium of receiving notifications. Users can either disable email or web notifications for a category and organization.

Notification Preferences of a Superuser

Did we forget about developers who incorporate OpenWISP into their applications? How can we? We have accounted needs of everyone while developing OpenWISP Notifications. 😆

Features for Developers

Simplified Creating Notifications

We abstracted everything behind a Django signal. Use the notify signal to create notifications from anywhere in your code.

See the following example for using the “notify” signal:

from django.contrib.auth import get_user_model
from swapper import load_model

from openwisp_notifications.signals import notify

User = get_user_model()
Group = load_model('openwisp_users', 'Group')
admin = User.objects.get(email='admin@admin.com')
operators = Group.objects.get(name='Operator')

notify.send(
sender=admin,
recipient=operators,
type='default',
)

The notify signal honors multi-tenancy of OpenWISP. The default recipients of created notifications are users of the same organization as that of the target object and super-users. You can also provide the recipient to the signal, which can be a queryset, Group or User object. It also honors notification preferences of users and sends notifications only to users who have opted-in to receive such notification.

Configurable Email Notifications

OpenWISP Notifications provides a default notification e-mail template. But, you can customize the notification email template simply by configuring a few settings.

If you prefer receiving text-only e-mails instead of HTML rendered ones, you can simply turn HTML e-mails off. 😁

An email sent by OpenWISP Notifications using the default template

Notification Type

Notification Type is one of the revolutionizing features of OpenWISP Notifications. A Notification Type acts as a template for generating notifications. You can define the message, email subject, etc. in a notification type once and use that notification type while creating notifications.

Creating a notification type is as simple as defining a dictionary and calling a function. Try the example below to see it yourself:

from openwisp_notifications.types import register_notification_type

# Define configuration of your notification type
custom_type = {
'level': 'info',
'verb': 'added',
'verbose_name': 'device added',
'message': '[{notification.target}]({notification.target_link}) was {notification.verb} at {notification.timestamp}',
'email_subject' : '[{site.name}] A device has been added',
'web_notification': True,
'email_notification': True
}

# Register your custom notification type
register_notification_type('custom_type', custom_type)

Did I tell the notification message supports markdown formatting? Well, it does. You can customize your notification message using markdown. 😃

REST API for CRUD Operations

OpenWISP Notifications offers REST API endpoints for CRUD operations. It supports both session and bearer authentication. You can perform all operations which are available from the user interface through API endpoints also.

REST API endpoints of OpenWISP Notifications

Swappable and Extensible Classes

OpenWISP Notifications simplifies the work. But, this does not mean that we didn’t account for our power users. We used our learnings from the development of other OpenWISP modules and designed OpenWISP Notifications to allow configurability to the last bit. OpenWISP Notifications ships with swappable models. If you don’t like the default models, swap them. OpenWISP Notifications includes abstract models to ease extensibility. We have a dedicated section in the documentation for extending OpenWISP Notifications. Just keep it DRY. 😉

OpenWISP Notifications 0.1.0 has more to offer, don’t forget to check out the documentation to learn about all the features. Stay tuned for more features coming to OpenWISP Notifications soon.

Hang out with OpenWISP developers at our Gitter channel or send your queries and feature requests to our Mailing List.

Important Links

--

--

Gagan Deep
Gagan Deep

Written by Gagan Deep

CSE | GSoC’20 Student Developer @openWISP | Cyber-security | Computer Networks | Open Source Enthusiast |

No responses yet

Write a response