django-notifications/notifications/models.py

23 lines
826 B
Python
Raw Permalink Normal View History

from swapper import swappable_setting
2018-05-30 05:18:33 +00:00
from .base.models import AbstractNotification, notify_handler # noqa
2015-04-28 12:10:49 +00:00
class Notification(AbstractNotification):
class Meta(AbstractNotification.Meta):
abstract = False
swappable = swappable_setting('notifications', 'Notification')
2023-05-07 20:41:35 +00:00
def naturalday(self):
"""
Shortcut for the ``humanize``.
Take a parameter humanize_type. This parameter control the which humanize method use.
Return ``today``, ``yesterday`` ,``now``, ``2 seconds ago``etc.
"""
from django.contrib.humanize.templatetags.humanize import naturalday
return naturalday(self.timestamp)
def naturaltime(self):
from django.contrib.humanize.templatetags.humanize import naturaltime
2023-05-07 20:41:35 +00:00
return naturaltime(self.timestamp)