diff --git a/infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/admin.py b/infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/admin.py index 2f3640f4..ea3d423d 100644 --- a/infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/admin.py +++ b/infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/admin.py @@ -4,7 +4,7 @@ from django.contrib.auth.models import User, Group from admin_extra_buttons.api import ExtraButtonsMixin, button - +from .models import Member from cloudharness_django.services import get_user_service # Register your models here. @@ -13,8 +13,14 @@ admin.site.unregister(Group) +class MemberAdmin(admin.StackedInline): + model = Member + + class CHUserAdmin(ExtraButtonsMixin, UserAdmin): + inlines = [MemberAdmin] + def has_add_permission(self, request): return settings.DEBUG or settings.USER_CHANGE_ENABLED diff --git a/infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/services/user.py b/infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/services/user.py index fc49ba36..4aa0677c 100644 --- a/infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/services/user.py +++ b/infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/services/user.py @@ -100,7 +100,9 @@ def sync_kc_user(self, kc_user, is_superuser=False, delete=False): user, created = User.objects.get_or_create(username=kc_user["username"]) - Member.objects.get_or_create(user=user, kc_id=kc_user["id"]) + member = Member.objects.get_or_create(user=user) + member.kc_id = kc_user["id"] + member.save() user = self._map_kc_user(user, kc_user, is_superuser, delete) user.save() return user