import os from django.conf import settings from django.core import checks @checks.register('directories') def check_cdn_directory_exists(app_configs, **kwargs): """This checks that the path from which the CDN will serve static files for this version of the datatracker actually exists. In development and test mode STATIC_ROOT will normally be just static/, but in production it will be set to a different part of the file system which is served via CDN, and the path will contain the datatracker release version. """ errors = [] if settings.SERVER_MODE == 'production' and not os.path.exists(settings.STATIC_ROOT): errors.append(checks.Error( "The static files directory has not been set up.", hint="Please run 'ietf/manage.py collectstatic'.", obj=None, id='datatracker.E001', )) return errors