Jet fork des offiziellen jet-admin projekts. Geupdated für Django4.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

50 lignes
1.4KB

  1. try:
  2. from django.core.management.base import NoArgsCommand
  3. except ImportError:
  4. from django.core.management import BaseCommand as NoArgsCommand
  5. from jet.utils import get_app_list
  6. class Command(NoArgsCommand):
  7. help = 'Generates example of JET custom apps setting'
  8. item_order = 0
  9. def handle(self, *args, **options):
  10. if args:
  11. raise CommandError("Command doesn't accept any arguments")
  12. return self.handle_noargs(**options)
  13. def handle_noargs(self, **options):
  14. class User:
  15. is_active = True
  16. is_staff = True
  17. is_superuser = True
  18. def has_module_perms(self, app):
  19. return True
  20. def has_perm(self, object):
  21. return True
  22. class Request:
  23. user = User()
  24. app_list = get_app_list({
  25. 'request': Request(),
  26. 'user': None
  27. })
  28. self.stdout.write('# Add this to your settings.py to customize applications and models list')
  29. self.stdout.write('JET_SIDE_MENU_CUSTOM_APPS = [')
  30. for app in app_list:
  31. app_label = app.get('app_label', app.get('name'))
  32. self.stdout.write(' (\'%s\', [' % app_label)
  33. for model in app['models']:
  34. self.stdout.write(' \'%s\',' % model['object_name'])
  35. self.stdout.write(' ]),')
  36. self.stdout.write(']')