mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-12 05:50:16 +02:00
max number of notifications per user
deletes oldest once surpassed closes #368
This commit is contained in:
parent
94cd0b98d5
commit
01c06cced8
@ -3,7 +3,12 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
MAX_NOTIFICATIONS = 50
|
||||
|
||||
def notify(user, title, message=None, level='info'):
|
||||
if Notification.objects.filter(user=user).count() > MAX_NOTIFICATIONS:
|
||||
for n in Notification.objects.filter(user=user)[MAX_NOTIFICATIONS:]:
|
||||
n.delete()
|
||||
notif = Notification()
|
||||
notif.user = user
|
||||
notif.title = title
|
||||
|
Loading…
x
Reference in New Issue
Block a user