-
Notifications
You must be signed in to change notification settings - Fork 12
Guia Notificações [EN US] [PT BR]
[EN-US]
The notification system is mostly used to make the user able to perceive important information that is happening on the system. Teachers and students alike know when someone answers them on a forum, per example.
In order to add a notification in our system, we'll have to use one of the three ways:
- Import NotificationMixin from core.Mixins: This way you just have to inherit from NotificationMixin to be able to call it's method createNotification. Here is a screenshot of it's signature and how to call it from any part of your class.
createNotification Signature:
def createNotification(self, message='', actor=None, users = User.objects.all(), resource_slug='' ,action_slug = '', resource_name='', resource_link=''): #the default will be a broadcast
And to call you only have to understand it's parameters:
Example:
uper(CreateTopicView, self).createNotification("Topic "+ self.object.name + " was created", resource_name=self.object.name, resource_link= reverse('course:view_topic',args=[self.object.slug]), actor=self.request.user, users = self.object.subject.course.students.all() )
- Import notification_decorator from core.decorators
It's signature is similar from the mixin and does the same thing, as it is a decorator, it works for CBV (Class Based View) methods or FBVs (Function Based View), there are examples below on how to wrap them around a function.
[PT-BR]