def setUp(self): user = create_superuser('*****@*****.**','passpenguji') organisasi = Organisasi.objects.create(nama="Organisasi Uji") kolega = Kolega.objects.create( nama="Mister Uji", organisasi=organisasi, email = "*****@*****.**",) status = Status.objects.create(user=user, organisasi=organisasi)
def handle(self, *args, **options): email = options.get('email', None) interactive = options.get('interactive') verbosity = int(options.get('verbosity', 1)) # Do quick and dirty validation if --noinput if not interactive: if not email: raise CommandError("You must use --email with --noinput.") try: is_valid_email(email) except exceptions.ValidationError: raise CommandError("Invalid email address.") # If not provided, create the user with an unusable password password = None # Prompt for username/email/password. Enclose this whole thing in a # try/except to trap for a keyboard interrupt and exit gracefully. if interactive: try: # Get an email while 1: if not email: email = raw_input('E-mail address: ') try: is_valid_email(email) except exceptions.ValidationError: sys.stderr.write("Error: That e-mail address is invalid.\n") email = None continue try: get_user(email) except User.DoesNotExist: break else: sys.stderr.write("Error: That email is already taken.\n") email = None # Get a password while 1: if not password: password = getpass.getpass() password2 = getpass.getpass('Password (again): ') if password != password2: sys.stderr.write("Error: Your passwords didn't match.\n") password = None continue if password.strip() == '': sys.stderr.write("Error: Blank passwords aren't allowed.\n") password = None continue break except KeyboardInterrupt: sys.stderr.write("\nOperation cancelled.\n") sys.exit(1) # Make Django's tests work by accepting a username through # call_command() but not through manage.py username = options.get('username', None) if username is None: create_superuser(email, password) else: User.objects.create_superuser(username, email, password) if verbosity >= 1: self.stdout.write("Superuser created successfully.\n")
def handle(self, *args, **options): email = options.get('email', None) interactive = options.get('interactive') verbosity = int(options.get('verbosity', 1)) # Do quick and dirty validation if --noinput if not interactive: if not email: raise CommandError("You must use --email with --noinput.") try: is_valid_email(email) except exceptions.ValidationError: raise CommandError("Invalid email address.") # If not provided, create the user with an unusable password password = None # Prompt for username/email/password. Enclose this whole thing in a # try/except to trap for a keyboard interrupt and exit gracefully. if interactive: try: # Get an email while 1: if not email: email = raw_input('E-mail address: ') try: is_valid_email(email) except exceptions.ValidationError: sys.stderr.write( "Error: That e-mail address is invalid.\n") email = None continue try: get_user(email) except User.DoesNotExist: break else: sys.stderr.write( "Error: That email is already taken.\n") email = None # Get a password while 1: if not password: password = getpass.getpass() password2 = getpass.getpass('Password (again): ') if password != password2: sys.stderr.write( "Error: Your passwords didn't match.\n") password = None continue if password.strip() == '': sys.stderr.write( "Error: Blank passwords aren't allowed.\n") password = None continue break except KeyboardInterrupt: sys.stderr.write("\nOperation cancelled.\n") sys.exit(1) # Make Django's tests work by accepting a username through # call_command() but not through manage.py username = options.get('username', None) if username is None: create_superuser(email, password) else: User.objects.create_superuser(username, email, password) if verbosity >= 1: self.stdout.write("Superuser created successfully.\n")