6
6
7
7
8
8
class Notifiable :
9
- """Notifiable mixin allowing to send notification to a model. It's often used with the
9
+ """Notifiable mixin allowing to send
10
+ notification to a model. It's often used with the
10
11
User model.
11
12
12
13
Usage:
@@ -15,17 +16,18 @@ class Notifiable:
15
16
def notify (self , notification , drivers = [], dry = False , fail_silently = False ):
16
17
"""Send the given notification."""
17
18
from wsgi import application
18
-
19
+
19
20
if hasattr (notification , "send" ):
20
21
notification .send (notification , drivers , dry , fail_silently )
21
-
22
+
22
23
return application .make ("notification" ).send (
23
24
self , notification , drivers , dry , fail_silently
24
25
)
25
26
26
27
def route_notification_for (self , driver ):
27
- """Get the notification routing information for the given driver. If method has not been
28
- defined on the model: for mail driver try to use 'email' field of model."""
28
+ """Get the notification routing information for the given driver.
29
+ If method has not been defined on the model:
30
+ for mail driver try to use 'email' field of model."""
29
31
# check if routing has been specified on the model
30
32
method_name = "route_notification_for_{0}" .format (driver )
31
33
@@ -41,7 +43,8 @@ def route_notification_for(self, driver):
41
43
return self .email
42
44
else :
43
45
raise NotificationException (
44
- "Notifiable model does not implement {}" .format (method_name )
46
+ "Notifiable model "
47
+ "does not implement {}" .format (method_name )
45
48
)
46
49
47
50
@has_many ("id" , "notifiable_id" )
0 commit comments