Merge branch 'feature' into issue_8233

This commit is contained in:
PieterL75
2022-06-17 16:31:13 +02:00
committed by GitHub
162 changed files with 2098 additions and 598 deletions
+5
View File
@@ -28,6 +28,11 @@ class NestedUserSerializer(WritableNestedSerializer):
model = User
fields = ['id', 'url', 'display', 'username']
def get_display(self, obj):
if full_name := obj.get_full_name():
return f"{obj.username} ({full_name})"
return obj.username
class NestedTokenSerializer(WritableNestedSerializer):
url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')
+5
View File
@@ -45,6 +45,11 @@ class UserSerializer(ValidatedModelSerializer):
return user
def get_display(self, obj):
if full_name := obj.get_full_name():
return f"{obj.username} ({full_name})"
return obj.username
class GroupSerializer(ValidatedModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='users-api:group-detail')
+3 -3
View File
@@ -176,11 +176,11 @@ class UserConfig(models.Model):
@receiver(post_save, sender=User)
def create_userconfig(instance, created, **kwargs):
def create_userconfig(instance, created, raw=False, **kwargs):
"""
Automatically create a new UserConfig when a new User is created.
Automatically create a new UserConfig when a new User is created. Skip this if importing a user from a fixture.
"""
if created:
if created and not raw:
config = get_config()
UserConfig(user=instance, data=config.DEFAULT_USER_PREFERENCES).save()