django-orchestra/orchestra/contrib/saas/validators.py
Jorge Pastor 53fa5a02eb inicio 2023/07/09
edited 2023/11/24 by pedro
2023-11-26 09:52:02 +00:00

15 lines
620 B
Python

from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _
from orchestra.utils.apps import isinstalled
def validate_website_saas_directives(app):
def validator(enabled, app=app):
if enabled and isinstalled('orchestra.contrib.websites'):
from orchestra.contrib.websites import settings
if app not in settings.WEBSITES_SAAS_DIRECTIVES:
raise ValidationError(_("Allow custom URL is enabled for '%s', "
"but has no associated WEBSITES_SAAS_DIRECTIVES" % app))
return validator