mirror of
https://github.com/Hopiu/django-notifications.git
synced 2026-04-23 22:44:44 +00:00
Remove custom now() function, since django.utils.timezone.now does the same thing
This commit is contained in:
parent
7dc21ef556
commit
5944862a5f
1 changed files with 4 additions and 16 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import datetime
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from django import get_version
|
||||
from django.utils import timezone
|
||||
|
||||
from distutils.version import StrictVersion
|
||||
|
||||
if StrictVersion(get_version()) >= StrictVersion('1.8.0'):
|
||||
|
|
@ -23,18 +23,6 @@ from jsonfield.fields import JSONField
|
|||
from django.contrib.auth.models import Group
|
||||
|
||||
|
||||
def now():
|
||||
# Needs to be be a function as USE_TZ can change based on if we are testing or not.
|
||||
_now = datetime.datetime.now
|
||||
if getattr(settings, 'USE_TZ'):
|
||||
try:
|
||||
from django.utils import timezone
|
||||
_now = timezone.now
|
||||
except ImportError:
|
||||
pass
|
||||
return _now()
|
||||
|
||||
|
||||
# SOFT_DELETE = getattr(settings, 'NOTIFICATIONS_SOFT_DELETE', False)
|
||||
def is_soft_delete():
|
||||
# TODO: SOFT_DELETE = getattr(settings, ...) doesn't work with "override_settings" decorator in unittest
|
||||
|
|
@ -181,7 +169,7 @@ class Notification(models.Model):
|
|||
action_object_object_id = models.CharField(max_length=255, blank=True, null=True)
|
||||
action_object = GenericForeignKey('action_object_content_type', 'action_object_object_id')
|
||||
|
||||
timestamp = models.DateTimeField(default=now)
|
||||
timestamp = models.DateTimeField(default=timezone.now)
|
||||
|
||||
public = models.BooleanField(default=True)
|
||||
deleted = models.BooleanField(default=False)
|
||||
|
|
@ -257,7 +245,7 @@ def notify_handler(verb, **kwargs):
|
|||
]
|
||||
public = bool(kwargs.pop('public', True))
|
||||
description = kwargs.pop('description', None)
|
||||
timestamp = kwargs.pop('timestamp', now())
|
||||
timestamp = kwargs.pop('timestamp', timezone.now())
|
||||
level = kwargs.pop('level', Notification.LEVELS.info)
|
||||
|
||||
# Check if User or Group
|
||||
|
|
|
|||
Loading…
Reference in a new issue