mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
30 lines
763 B
Python
30 lines
763 B
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
import logging
|
|
from datetime import timedelta, datetime
|
|
|
|
from django.core.exceptions import AppRegistryNotReady
|
|
|
|
|
|
logger = logging.getLogger('inventree')
|
|
|
|
|
|
def delete_old_notifications():
|
|
"""
|
|
Remove old notifications from the database.
|
|
|
|
Anything older than ~3 months is removed
|
|
"""
|
|
|
|
try:
|
|
from common.models import NotificationEntry
|
|
except AppRegistryNotReady: # pragma: no cover
|
|
logger.info("Could not perform 'delete_old_notifications' - App registry not ready")
|
|
return
|
|
|
|
before = datetime.now() - timedelta(days=90)
|
|
|
|
# Delete notification records before the specified date
|
|
NotificationEntry.objects.filter(updated__lte=before).delete()
|