Le serveur gitlab sera inaccessible le mercredi 19 février 2020 de 13h à 14h pour une intervention de maintenance programmée.

Commit da50e66a authored by Lev-Arcady Sellem's avatar Lev-Arcady Sellem

Factorisation

parent 3c9d4b0e
......@@ -26,6 +26,7 @@ from django.db import transaction
from reversion import revisions as reversion
from users.models import User, ListShell
from re2o.script_utils import get_user, get_system_user
class Command(BaseCommand):
help = 'Change the default shell of a user'
......@@ -35,14 +36,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
def get_user(user_pseudo):
"""Return the user queried by pseudo, and exit the script if not found."""
user = User.objects.filter(pseudo=user_pseudo)
if not user:
raise CommandError("Utilisateur invalide")
return user[0]
current_username = pwd.getpwuid(int(os.getenv("SUDO_UID") or os.getuid())).pw_name
current_username = get_system_user()
current_user = get_user(current_username)
target_username = options["target_username"] or current_username
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment