diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 06cd54cf..44c86be5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog Unreleased ================== +* feat: Exposed the setting DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID as an environment variable for the Divio addon * fix: Error when rendering a Draft Snippet plugin on a Published page * fix: Publish snippets by default as they were already in that state pre-versioning and cleanup unnecessary migration files before release! * feat: djangocms-versioning support added, including model restructure and configuration diff --git a/README.rst b/README.rst index 6cedd459..4fe1bf5a 100644 --- a/README.rst +++ b/README.rst @@ -82,6 +82,7 @@ please set ``DJANGOCMS_SNIPPET_CACHE`` to ``False`` in your settings:: Migration 0010 requires the use of a user in order to create versions for existing snippets (if djangocms_versioning is installed and enabled), a user can be chosen with the setting ``DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID``, the default is 1. +This setting is also exposed as an Environment variable for Divio projects using the Divio addon. DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID = 2 # Will use user with id: 2 diff --git a/aldryn_config.py b/aldryn_config.py index 3e532b2c..c97e8a56 100644 --- a/aldryn_config.py +++ b/aldryn_config.py @@ -1,3 +1,5 @@ +from functools import partial + from aldryn_client import forms @@ -17,6 +19,18 @@ class Form(forms.BaseForm): ) def to_settings(self, data, settings): + from aldryn_addons.utils import djsenv + + env = partial(djsenv, settings=settings) + + # Get a migration user if the env setting has been added + migration_user_id = env( + 'DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID', + default=False + ) + if migration_user_id: + settings['DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID'] = int(migration_user_id) + if data['editor_theme']: settings['DJANGOCMS_SNIPPET_THEME'] = data['editor_theme'] if data['editor_mode']: