fairdm.conf.checks#
System checks that validate the configuration and service availability.
Provides fail-fast validation for production and graceful degradation for development.
Module Contents#
Classes#
Custom tags for deployment-related checks. |
Functions#
Report fairdm.E100 when DATABASES[‘default’] is not configured. |
|
Report fairdm.E101 when the database is not PostgreSQL with PostGIS. |
|
Report fairdm.E102 when DATABASES[‘default’] has no NAME, as a malformed DATABASE_URL leaves it. |
|
Report fairdm.E200 when the cache is not a shared backend, or is the baseline’s placeholder. |
|
Report fairdm.E001 when SECRET_KEY is empty, insecure or too short. |
|
Report fairdm.E003 when ALLOWED_HOSTS is empty. |
|
Report fairdm.E004 when ALLOWED_HOSTS contains the wildcard ‘*’. |
|
Report fairdm.E005 when DEBUG is True. |
|
Report fairdm.E700 when BACKUP_PUBLIC_KEY is not set. |
|
Report fairdm.E701 when BACKUP_PUBLIC_KEY cannot be encrypted to, or gpg is missing. |
|
Report fairdm.W700 when production keeps backups on the local disk. |
|
Report fairdm.E006 when a |
|
Report fairdm.W601 when REST_FRAMEWORK has no NUM_PROXIES. |
|
Report fairdm.E300 when CELERY_BROKER_URL is not configured. |
|
Report fairdm.E301 when CELERY_TASK_ALWAYS_EAGER is True. |
|
Report fairdm.E500 when a shipped portal role is missing from the database. |
|
Report fairdm.E501 when development accounts exist outside development. |
|
Return fairdm.E400 for the given setting values. |
|
Refuse to continue when PARLER_LANGUAGES and LANGUAGES disagree, naming both. |
|
Report fairdm.E400 when PARLER_LANGUAGES names a code LANGUAGES lacks. |
|
Validate that an addon’s setup module can be found. |
Data#
API#
- logger#
‘getLogger(…)’
- class DeployTags[source]#
Bases:
django.core.checks.TagsCustom tags for deployment-related checks.
- deploy#
‘deploy’
- production_critical#
‘production_critical’
- POSTGIS_ENGINE#
‘django.contrib.gis.db.backends.postgis’
- check_database_configured(app_configs, **kwargs)[source]#
Report fairdm.E100 when DATABASES[‘default’] is not configured.
- check_database_production_ready(app_configs, **kwargs)[source]#
Report fairdm.E101 when the database is not PostgreSQL with PostGIS.
- check_database_usable(app_configs, **kwargs)[source]#
Report fairdm.E102 when DATABASES[‘default’] has no NAME, as a malformed DATABASE_URL leaves it.
- SHARED_CACHE_BACKENDS#
‘frozenset(…)’
- UNCONFIGURED_REDIS_LOCATION#
‘redis://unconfigured.invalid:6379/0’
- check_cache_backend(app_configs, **kwargs)[source]#
Report fairdm.E200 when the cache is not a shared backend, or is the baseline’s placeholder.
- INSECURE_SECRET_KEY_PREFIX#
‘django-insecure-’
- MINIMUM_SECRET_KEY_LENGTH#
50
- check_secret_key_exists(app_configs, **kwargs)[source]#
Report fairdm.E001 when SECRET_KEY is empty, insecure or too short.
- check_allowed_hosts_configured(app_configs, **kwargs)[source]#
Report fairdm.E003 when ALLOWED_HOSTS is empty.
- check_allowed_hosts_secure(app_configs, **kwargs)[source]#
Report fairdm.E004 when ALLOWED_HOSTS contains the wildcard ‘*’.
- check_backup_key_present(app_configs, **kwargs)[source]#
Report fairdm.E700 when BACKUP_PUBLIC_KEY is not set.
- check_backup_key_usable(app_configs, **kwargs)[source]#
Report fairdm.E701 when BACKUP_PUBLIC_KEY cannot be encrypted to, or gpg is missing.
- check_backup_storage_is_remote(app_configs, **kwargs)[source]#
Report fairdm.W700 when production keeps backups on the local disk.
- BROWSER_ENFORCED_SECURE_COOKIE_PREFIXES#
(‘__Secure-’, ‘__Host-’)
- PREFIX_CHECKED_COOKIE_SETTINGS#
((‘CSRF_COOKIE_NAME’, ‘CSRF_COOKIE_SECURE’), (‘SESSION_COOKIE_NAME’, ‘SESSION_COOKIE_SECURE’), (‘LAN…
- check_secure_cookie_prefixes_match_secure_flag(app_configs, **kwargs)[source]#
Report fairdm.E006 when a
__Secure-or__Host-cookie name is paired with an insecure flag.
- check_api_proxy_count(app_configs, **kwargs)[source]#
Report fairdm.W601 when REST_FRAMEWORK has no NUM_PROXIES.
Without it, the API takes a caller’s address from the
X-Forwarded-Forheader, which the caller writes, so the request limits can be avoided. Any value an operator sets,0andNoneincluded, is a decision and is left alone.
- check_celery_broker(app_configs, **kwargs)[source]#
Report fairdm.E300 when CELERY_BROKER_URL is not configured.
- check_celery_async(app_configs, **kwargs)[source]#
Report fairdm.E301 when CELERY_TASK_ALWAYS_EAGER is True.
- MIGRATE_COMMAND_NAME#
‘migrate’
- PRE_MIGRATE_COMMAND_NAMES#
‘frozenset(…)’
- UNREADABLE_DATABASE#
()
- check_portal_roles_present(app_configs, **kwargs)[source]#
Report fairdm.E500 when a shipped portal role is missing from the database.
- check_dev_accounts_absent(app_configs, **kwargs)[source]#
Report fairdm.E501 when development accounts exist outside development.
- parler_languages_errors(languages, parler_languages, parler_default_language_code=None) list[django.core.checks.Error][source]#
Return fairdm.E400 for the given setting values.
Takes values rather than reading
settingsso the rule can run before settings load, asraise_on_parler_languages_mismatchdoes.Args: languages: The LANGUAGES setting. parler_languages: The PARLER_LANGUAGES setting. parler_default_language_code: The PARLER_DEFAULT_LANGUAGE_CODE setting.
Returns: One error naming the missing codes, or an empty list when the settings agree.
- raise_on_parler_languages_mismatch(languages, parler_languages, parler_default_language_code=None) None[source]#
Refuse to continue when PARLER_LANGUAGES and LANGUAGES disagree, naming both.
Called from
fairdm.conf.setup()on the composed settings, the only point ahead of every app’s models, and again fromFairDMConfig.import_models()on the loaded settings, which sees assignments a portal makes aftersetup(). A portal that does both still gets parler’s own error.Args: languages: The LANGUAGES setting. parler_languages: The PARLER_LANGUAGES setting. parler_default_language_code: The PARLER_DEFAULT_LANGUAGE_CODE setting.
Raises: SystemCheckError: The two settings disagree.
- check_parler_languages_subset_of_languages(app_configs, **kwargs)[source]#
Report fairdm.E400 when PARLER_LANGUAGES names a code LANGUAGES lacks.
- validate_addon_module(addon_name: str, module_path: str, env_profile: str) bool[source]#
Validate that an addon’s setup module can be found.
Only checks that the module can be found, not imported, because addon setup modules are executed via
split_settings.include(), which supplies the scope they need.Args: addon_name: The name of the addon package. module_path: The path to the addon’s setup module. env_profile: The resolved environment name (e.g. “production”, “development”).
Returns:
Trueif the module is valid,Falseotherwise.Raises: ImproperlyConfigured: The module is invalid and the environment is production. ModuleNotFoundError: The module cannot be found. Handled inside this function, so callers see
False, orImproperlyConfiguredin production.