jet_custom_apps_example.py 1.1 KB

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