Skip to content

Commit 55abe67

Browse files
authored
feat: Default versioning import user id setting can be set via environment variable (#89)
1 parent 7d752e6 commit 55abe67

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44

55
Unreleased
66
==================
7+
* feat: Exposed the setting DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID as an environment variable for the Divio addon
78
* fix: Error when rendering a Draft Snippet plugin on a Published page
89
* fix: Publish snippets by default as they were already in that state pre-versioning and cleanup unnecessary migration files before release!
910
* feat: djangocms-versioning support added, including model restructure and configuration

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ please set ``DJANGOCMS_SNIPPET_CACHE`` to ``False`` in your settings::
8282

8383
Migration 0010 requires the use of a user in order to create versions for existing snippets (if djangocms_versioning is installed and enabled),
8484
a user can be chosen with the setting ``DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID``, the default is 1.
85+
This setting is also exposed as an Environment variable for Divio projects using the Divio addon.
8586

8687
DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID = 2 # Will use user with id: 2
8788

aldryn_config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from functools import partial
2+
13
from aldryn_client import forms
24

35

@@ -17,6 +19,18 @@ class Form(forms.BaseForm):
1719
)
1820

1921
def to_settings(self, data, settings):
22+
from aldryn_addons.utils import djsenv
23+
24+
env = partial(djsenv, settings=settings)
25+
26+
# Get a migration user if the env setting has been added
27+
migration_user_id = env(
28+
'DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID',
29+
default=False
30+
)
31+
if migration_user_id:
32+
settings['DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID'] = int(migration_user_id)
33+
2034
if data['editor_theme']:
2135
settings['DJANGOCMS_SNIPPET_THEME'] = data['editor_theme']
2236
if data['editor_mode']:

0 commit comments

Comments
 (0)