17 lines
781 B
Python
17 lines
781 B
Python
from django.db.models.signals import post_save
|
|
from django.dispatch import receiver
|
|
from manage_wallets.models import Wallet
|
|
from .models import IAmPrincipalNotificationSettings, NotificationCategoryChoices
|
|
|
|
@receiver(post_save, sender=Wallet)
|
|
def create_default_notification_settings(sender, instance, created, **kwargs):
|
|
if created:
|
|
principal = instance.principal
|
|
# Assuming NotificationCategoryChoices is a list of tuples as choices for the field
|
|
for category in NotificationCategoryChoices:
|
|
IAmPrincipalNotificationSettings.objects.create(
|
|
principal=principal,
|
|
notification_category=category.value, # Assuming category is a tuple and the value is at index 0
|
|
is_enabled=True
|
|
)
|