/usr/lib/python3/dist-packages/django_python3_ldap/management/commands/ldap_promote.py is in python3-django-python3-ldap 0.9.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
from django.contrib.auth import get_user_model
class Command(BaseCommand):
help = "Promotes the named users to an admin superuser."
args = "[username, ...]"
@transaction.atomic()
def handle(self, *usernames, **kwargs):
verbosity = int(kwargs.get("verbosity", 1))
User = get_user_model()
for username in usernames:
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
raise CommandError("User with username {username} does not exist".format(
username = username,
))
else:
user.is_staff = True
user.is_superuser = True
user.save()
if verbosity >= 1:
self.stdout.write("Promoted {user} to admin superuser".format(
user = user,
))
|