From de4d66cecd7c7a0ebba62a55d799959940e98fcc Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Sat, 15 Oct 2022 14:02:55 -0700 Subject: [PATCH] Set superuser for CLI created users Closes #543 --- babybuddy/forms.py | 1 + babybuddy/management/commands/createuser.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/babybuddy/forms.py b/babybuddy/forms.py index 9c91cb5b..c33c2b0a 100644 --- a/babybuddy/forms.py +++ b/babybuddy/forms.py @@ -20,6 +20,7 @@ class UserAddForm(UserCreationForm): def save(self, commit=True): user = super(UserAddForm, self).save(commit=False) + # All Baby Buddy users are superusers. user.is_superuser = True if commit: user.save() diff --git a/babybuddy/management/commands/createuser.py b/babybuddy/management/commands/createuser.py index a14ec161..8d8bb1fd 100644 --- a/babybuddy/management/commands/createuser.py +++ b/babybuddy/management/commands/createuser.py @@ -113,6 +113,8 @@ class Command(BaseCommand): ).create_user(**user_data, password=user_password) user.email = options.get("email") user.is_staff = options.get("is_staff") + # All Baby Buddy users are superusers. + user.is_superuser = True user.save() if options.get("verbosity") > 0: