The user/staff can create a new variable in django-admin and use it later in other template-type variables.
Or in code you can get list of all variables with the specific prefix
There are several reasons to have user-defined variables:
to use it later in other code-defined variables, for example as DjangoTemplate through the {{CONTENT_SETTINGS.USER_VAR}}
list variables through the conf.search
API first development. The front-end team can start with creating variable without dive in backend code
We now have code-defined (defined in content_settings.py) and user-defined (defined in django-admin only with no definition in content_settings.py)
[x] the list of available types for user-defined variables can be listed in settings USER_DEFINED_TYPES as a list of tuples (slug, type, name).. slug - for db, type - is import string for the variable type, name - is how it is shown in Django Admin.
[x] the list of user-defined types is empty by default
[x] if the list of user-defined types is not empty - adding content setting variable to admin is possible
[x] form with name, value, help, tags, and user-defined type
[x] preview based on user-defined type
[x] the change form is different depending on whether it is user-defined or code-defined variable
[x] caching. Should work in the same way, but for version will be used key generated by USER_DEFINED_TYPES list. Concatenation of types and generated version of the types. The value is checksum of concatenation name, value and tags
[x] conf.startswith - find variables by name.
[x] startswith__NAME - prefix, with will work in the same way as conf.startswith('NAME') (possible bug with ''.isupper())
Other Cases to cover:
[x] migration user-defined to code-defined (how to prevent mistakes here)
[x] if user-defined type no longer exists - variable itself no longer exists as well
[x] variable history should show type-change and migration from user to code defined variables
The user/staff can create a new variable in django-admin and use it later in other template-type variables. Or in code you can get list of all variables with the specific prefix
There are several reasons to have user-defined variables:
DjangoTemplate
through the{{CONTENT_SETTINGS.USER_VAR}}
conf.search
We now have code-defined (defined in
content_settings.py
) and user-defined (defined in django-admin only with no definition incontent_settings.py
)USER_DEFINED_TYPES
as a list of tuples(slug, type, name).
. slug - for db, type - is import string for the variable type, name - is how it is shown in Django Admin.user-defined
orcode-defined
variableUSER_DEFINED_TYPES
list. Concatenation of types and generated version of the types. The value is checksum of concatenation name, value and tagsconf.startswith
- find variables by name.startswith__NAME
- prefix, with will work in the same way asconf.startswith('NAME')
(possible bug with''.isupper()
)Other Cases to cover: