Browse Source

warn user that no admins exist when starting runserver

Nick Sweeting 6 years ago
parent
commit
b0ace38273
1 changed files with 9 additions and 2 deletions
  1. 9 2
      archivebox/cli/archivebox_server.py

+ 9 - 2
archivebox/cli/archivebox_server.py

@@ -7,7 +7,7 @@ __description__ = 'Run the ArchiveBox HTTP server'
 import sys
 import argparse
 
-from ..legacy.config import setup_django, OUTPUT_DIR, ANSI, check_data_folder
+from ..legacy.config import setup_django, IS_TTY, OUTPUT_DIR, ANSI, check_data_folder
 from ..legacy.util import reject_stdin
 
 
@@ -38,7 +38,14 @@ def main(args=None):
     
     setup_django(OUTPUT_DIR)
     from django.core.management import call_command
-
+    from django.contrib.auth.models import User
+
+    if IS_TTY and not User.objects.filter(is_superuser=True).exists():
+        print('{lightyellow}[!] No admin users exist yet, you will not be able to edit links in the UI.{reset}'.format(**ANSI))
+        print()
+        print('    To create an admin user, run:')
+        print('        archivebox manage createsuperuser')
+        print()
 
     print('{green}[+] Starting ArchiveBox webserver...{reset}'.format(**ANSI))
     if not command.reload: