Skip to content

feat: Default versioning import user id setting via env #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions aldryn_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from functools import partial

from aldryn_client import forms


Expand All @@ -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']:
Expand Down