mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Fix code guidelines
This commit is contained in:
		| @@ -3,6 +3,7 @@ import os | |||||||
| from django.contrib.auth.models import User | from django.contrib.auth.models import User | ||||||
| from django.core.management.base import BaseCommand, CommandError | from django.core.management.base import BaseCommand, CommandError | ||||||
|  |  | ||||||
|  |  | ||||||
| class Command(BaseCommand): | class Command(BaseCommand): | ||||||
|  |  | ||||||
|     help = """ |     help = """ | ||||||
| @@ -11,23 +12,29 @@ class Command(BaseCommand): | |||||||
|  |  | ||||||
|     def handle(self, *args, **options): |     def handle(self, *args, **options): | ||||||
|  |  | ||||||
|         # Get user details from env variables |         PAPERLESS_ADMIN_USER = os.getenv('PAPERLESS_ADMIN_USER') | ||||||
|         PAPERLESS_ADMIN_USER=os.getenv('PAPERLESS_ADMIN_USER') |         PAPERLESS_ADMIN_MAIL = os.getenv('PAPERLESS_ADMIN_MAIL', 'root@localhost') | ||||||
|         PAPERLESS_ADMIN_MAIL=os.getenv('PAPERLESS_ADMIN_MAIL', 'root@localhost') |         PAPERLESS_ADMIN_PASSWORD = os.getenv('PAPERLESS_ADMIN_PASSWORD') | ||||||
|         PAPERLESS_ADMIN_PASSWORD=os.getenv('PAPERLESS_ADMIN_PASSWORD') |  | ||||||
|  |  | ||||||
|         # If PAPERLESS_ADMIN_USER env variable is set |         # If PAPERLESS_ADMIN_USER env variable is set | ||||||
|         if PAPERLESS_ADMIN_USER: |         if PAPERLESS_ADMIN_USER: | ||||||
|             try: |             try: | ||||||
|                 # Check if user exists already, leave as is if it does |                 # Check if user exists already, leave as is if it does | ||||||
|                 if User.objects.filter(username=PAPERLESS_ADMIN_USER).exists(): |                 if User.objects.filter( | ||||||
|                     self.stdout.write(f'The user "{PAPERLESS_ADMIN_USER}" already exists! Leaving user as is.') |                     username=PAPERLESS_ADMIN_USER).exists(): | ||||||
|  |                     self.stdout.write( | ||||||
|  |                         f'The user "{PAPERLESS_ADMIN_USER}" already exists! Leaving user as is.') | ||||||
|                 elif PAPERLESS_ADMIN_PASSWORD: |                 elif PAPERLESS_ADMIN_PASSWORD: | ||||||
|                     # Create superuser based on env variables |                     # Create superuser based on env variables | ||||||
|                     User.objects.create_superuser(PAPERLESS_ADMIN_USER, PAPERLESS_ADMIN_MAIL, PAPERLESS_ADMIN_PASSWORD) |                     User.objects.create_superuser( | ||||||
|                     self.stdout.write(f'Created superuser "{PAPERLESS_ADMIN_USER}" with provided password.') |                         PAPERLESS_ADMIN_USER, PAPERLESS_ADMIN_MAIL, PAPERLESS_ADMIN_PASSWORD) | ||||||
|  |                     self.stdout.write( | ||||||
|  |                         f'Created superuser "{PAPERLESS_ADMIN_USER}" with provided password.') | ||||||
|                 else: |                 else: | ||||||
|                     self.stdout.write(f'Did not create superuser "{PAPERLESS_ADMIN_USER}".') |                     self.stdout.write( | ||||||
|                     self.stdout.write('Make sure you specified "PAPERLESS_ADMIN_PASSWORD" in your "docker-compose.env" file.') |                         f'Did not create superuser "{PAPERLESS_ADMIN_USER}".') | ||||||
|  |                     self.stdout.write( | ||||||
|  |                         'Make sure you specified "PAPERLESS_ADMIN_PASSWORD" in your "docker-compose.env" file.') | ||||||
|             except Exception as error: |             except Exception as error: | ||||||
|                 self.stdout.write(f'Exception occured while creating superuser: {error}') |                 self.stdout.write( | ||||||
|  |                     f'Exception occured while creating superuser: {error}') | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Chris Nagy
					Chris Nagy