From e34dffb17685f714a4c1469b80b91ae1571dab0a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 25 May 2016 02:48:35 -0400 Subject: [PATCH] Make a hybrid user manager class to allow calling 'create_user' and 'create_superuser' from the on_organization manager. --- mayan/apps/user_management/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mayan/apps/user_management/models.py b/mayan/apps/user_management/models.py index b45cf528e0..3abb5fae9e 100644 --- a/mayan/apps/user_management/models.py +++ b/mayan/apps/user_management/models.py @@ -21,6 +21,12 @@ class MayanGroup(Group): on_organization = CurrentOrganizationManager() +class OrganizationUserManagerHybridClass(CurrentOrganizationManager, UserManager): + """ + Hybrid class to allow calling 'create_superuser' from 'on_organization' + """ + + class MayanUser(AbstractUser): organization = models.ForeignKey( Organization, default=get_current_organization @@ -35,4 +41,4 @@ class MayanUser(AbstractUser): ) objects = UserManager() - on_organization = CurrentOrganizationManager() + on_organization = OrganizationUserManagerHybridClass()