Merge branch 'master' of https://github.com/inventree/InvenTree into plugin-app-refactor

This commit is contained in:
Matthias 2022-05-11 22:03:32 +02:00
commit fdc6c8300a
No known key found for this signature in database
GPG Key ID: AB6D0E6C4CB65093

View File

@ -190,9 +190,12 @@ class InvenTreeConfig(AppConfig):
user = get_user_model() user = get_user_model()
try: try:
with transaction.atomic(): with transaction.atomic():
new_user = user.objects.create_superuser(add_user, add_email, add_password) if user.objects.filter(username=add_user).exists():
logger.info(f'User {str(new_user)} was created!') logger.info(f"User {add_user} already exists - skipping creation")
except IntegrityError as _e: # pragma: no cover else:
new_user = user.objects.create_superuser(add_user, add_email, add_password)
logger.info(f'User {str(new_user)} was created!')
except IntegrityError as _e:
logger.warning(f'The user "{add_user}" could not be created due to the following error:\n{str(_e)}') logger.warning(f'The user "{add_user}" could not be created due to the following error:\n{str(_e)}')
# do not try again # do not try again