-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathmodels.py
40 lines (32 loc) · 1.29 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from swapper import swappable_setting
from openwisp_notifications.base.models import (
AbstractIgnoreObjectNotification,
AbstractNotification,
AbstractNotificationSetting,
)
from .types import get_notification_configuration
class Notification(AbstractNotification):
class Meta(AbstractNotification.Meta):
abstract = False
app_label = 'openwisp_notifications'
swappable = swappable_setting('openwisp_notifications', 'Notification')
@property
def notification_verb(self):
"""
Returns notification verb from type configuration if verb is None,
otherwise returns the stored verb
"""
if self.verb is None and self.type:
config = get_notification_configuration(self.type)
return config.get('verb', '')
return self.verb
class NotificationSetting(AbstractNotificationSetting):
class Meta(AbstractNotificationSetting.Meta):
abstract = False
swappable = swappable_setting('openwisp_notifications', 'NotificationSetting')
class IgnoreObjectNotification(AbstractIgnoreObjectNotification):
class Meta(AbstractIgnoreObjectNotification.Meta):
abstract = False
swappable = swappable_setting(
'openwisp_notifications', 'IgnoreObjectNotification'
)