From b574a6e17a86e3461f25ac958b477be6ac3522ca Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Tue, 8 Aug 2023 14:34:27 -0300 Subject: [PATCH] fix: Print decoded key and fully clean up test nomcom (#6094) * fix: Delete Person records when deleting a test nomcom * fix: Decode test nomcom private key before printing --- ietf/nomcom/management/commands/create_test_nomcom.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ietf/nomcom/management/commands/create_test_nomcom.py b/ietf/nomcom/management/commands/create_test_nomcom.py index bfca892b88..3365ea8f40 100644 --- a/ietf/nomcom/management/commands/create_test_nomcom.py +++ b/ietf/nomcom/management/commands/create_test_nomcom.py @@ -11,7 +11,7 @@ from ietf.nomcom.factories import nomcom_kwargs_for_year, NomComFactory, NomineePositionFactory, key from ietf.person.factories import EmailFactory from ietf.group.models import Group -from ietf.person.models import User +from ietf.person.models import Person, User class Command(BaseCommand): help = ("Create (or delete) a nomcom for test and development purposes.") @@ -27,7 +27,9 @@ def handle(self, *args, **options): if opt_delete: if Group.objects.filter(acronym='nomcom7437').exists(): Group.objects.filter(acronym='nomcom7437').delete() - User.objects.filter(username__in=['testchair','testmember','testcandidate']).delete() + users_to_delete = ['testchair','testmember','testcandidate'] + Person.objects.filter(user__username__in=users_to_delete).delete() + User.objects.filter(username__in=users_to_delete).delete() self.stdout.write("Deleted test group 'nomcom7437' and its related objects.") else: self.stderr.write("test nomcom 'nomcom7437' does not exist; nothing to do.\n") @@ -57,6 +59,6 @@ def handle(self, *args, **options): position__nomcom=nc, position__name='Test Area Director', position__is_iesg_position=True, ) - self.stdout.write("%s\n" % key) + self.stdout.write("%s\n" % key.decode()) self.stdout.write("Nomcom 7437 created. The private key can also be found at any time\nin ietf/nomcom/factories.py. Note that it is NOT a secure key.\n")