mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-10-26 07:46:35 +01:00
- Introduced a new model `UserNotificationPreferences` to store user-specific notification dismissal settings. - Added context processor to include notification preferences in templates. - Implemented API endpoints to dismiss backup and AI scanner notifications permanently. - Updated front-end logic to handle notification dismissal via server-side checks and API calls. - Enhanced documentation to include a new Custom CSS Guide for theme customization.
24 lines
864 B
Python
24 lines
864 B
Python
# -*- coding: utf-8 -*-
|
|
from django.db.models.signals import post_save
|
|
from django.dispatch import receiver
|
|
from django.contrib.auth.models import User
|
|
from .models import UserNotificationPreferences
|
|
|
|
|
|
@receiver(post_save, sender=User)
|
|
def create_user_notification_preferences(sender, instance, created, **kwargs):
|
|
"""Create default notification preferences when a new user is created"""
|
|
if created:
|
|
UserNotificationPreferences.objects.create(
|
|
user=instance,
|
|
backup_notification_dismissed=False,
|
|
ai_scanner_notification_dismissed=False
|
|
)
|
|
|
|
|
|
@receiver(post_save, sender=User)
|
|
def save_user_notification_preferences(sender, instance, **kwargs):
|
|
"""Save notification preferences when user is saved"""
|
|
if hasattr(instance, 'notification_preferences'):
|
|
instance.notification_preferences.save()
|