mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fix automatic creation of UserConfig for user created via admin UI
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.admin import UserAdmin as UserAdmin_
|
from django.contrib.auth.admin import UserAdmin as UserAdmin_
|
||||||
from django.contrib.auth.models import Group as StockGroup, User as StockUser
|
from django.contrib.auth.models import Group, User
|
||||||
from django.core.exceptions import FieldError, ValidationError
|
from django.core.exceptions import FieldError, ValidationError
|
||||||
|
|
||||||
from extras.admin import order_content_types
|
from extras.admin import order_content_types
|
||||||
@ -13,8 +13,8 @@ from .models import AdminGroup, AdminUser, ObjectPermission, Token, UserConfig
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Unregister the built-in GroupAdmin and UserAdmin classes so that we can use our custom admin classes below
|
# Unregister the built-in GroupAdmin and UserAdmin classes so that we can use our custom admin classes below
|
||||||
admin.site.unregister(StockGroup)
|
admin.site.unregister(Group)
|
||||||
admin.site.unregister(StockUser)
|
admin.site.unregister(User)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(AdminGroup)
|
@admin.register(AdminGroup)
|
||||||
|
@ -159,6 +159,7 @@ class UserConfig(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=User)
|
@receiver(post_save, sender=User)
|
||||||
|
@receiver(post_save, sender=AdminUser)
|
||||||
def create_userconfig(instance, created, **kwargs):
|
def create_userconfig(instance, created, **kwargs):
|
||||||
"""
|
"""
|
||||||
Automatically create a new UserConfig when a new User is created.
|
Automatically create a new UserConfig when a new User is created.
|
||||||
|
Reference in New Issue
Block a user