Initialize clean CSR inventory repository

This commit is contained in:
DenisToxic
2026-09-29 08:43:05 +02:00
commit 059f386c60
107 changed files with 9639 additions and 0 deletions

12
inventory/signals.py Normal file
View File

@@ -0,0 +1,12 @@
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import UserProfile
@receiver(post_save, sender=User)
def ensure_user_profile(sender, instance: User, created: bool, raw=False, **kwargs) -> None:
if created and not raw:
role = UserProfile.Role.ADMIN if instance.is_superuser else UserProfile.Role.VIEWER
UserProfile.objects.create(user=instance, role=role)