"""Helper functions for the django_tenant_options app."""fromdjango_tenant_options.modelsimportAbstractOptionfromdjango_tenant_options.modelsimportAbstractSelection
[docs]defall_option_subclasses():"""Returns a list of model classes that subclass AbstractOption."""returnAbstractOption.get_concrete_subclasses()
[docs]defall_selection_subclasses():"""Returns a list of model classes that subclass AbstractSelection."""returnAbstractSelection.get_concrete_subclasses()
[docs]defget_default_option_names(option_model):"""Return the sorted list of default option names for a concrete Option model. Reads the ``default_options`` class dict on the given model and returns its keys sorted alphabetically. Returns an empty list when the model defines no defaults. """default_options=getattr(option_model,"default_options",{})or{}returnsorted(default_options.keys())