Skip to content

Moderation configuration and copy method #77

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
Show all changes
107 commits
Select commit Hold shift + click to select a range
6368d7e
Added cms_config versionable item and grouper
adam-murray Aug 9, 2021
75449d6
Added admin, requirements for testing and requirements for running
adam-murray Aug 9, 2021
9bc367c
Update
adam-murray Aug 11, 2021
7c9455c
Fixed issue in setup.py and added basic first migration
adam-murray Aug 11, 2021
4954ee4
Added migration to cms4
adam-murray Aug 12, 2021
8defe7f
Added migration to cms4
adam-murray Aug 12, 2021
b9f822f
Began to implement versioning switch, added migration as part of mana…
adam-murray Aug 16, 2021
49e4bb3
Moved data migration to management command, added util for versioning…
adam-murray Aug 16, 2021
dceee9f
Added tests for config as well as util for versioning check
adam-murray Aug 16, 2021
7dfd721
Merge branch 'feature/versioned-snippets' into feature/snippet-data-m…
adam-murray Aug 16, 2021
56adbdb
Updated cms_config
adam-murray Aug 16, 2021
48e125f
Updated management command
adam-murray Aug 16, 2021
5e12a63
Added form, updated model and forms to improve versioned and unversio…
adam-murray Aug 16, 2021
fdcde12
Updated migration, removed unecessary plugin
adam-murray Aug 31, 2021
13547ae
Merged
adam-murray Aug 31, 2021
9b73d59
Removed additional copies of files
adam-murray Aug 31, 2021
680ce70
Split migration command into migration and command
adam-murray Sep 1, 2021
8dc7f91
Updates to migration
adam-murray Sep 2, 2021
6e937e8
Updates to migration
adam-murray Sep 2, 2021
2df658b
Update migration for review
adam-murray Sep 3, 2021
11a7d3e
Remove pdb
adam-murray Sep 3, 2021
d7c5dbb
Migration upgrade
adam-murray Sep 3, 2021
8898232
Remove plugin from migration 10, added version creation
adam-murray Sep 3, 2021
225b9f9
Implemented proper plugin migration
adam-murray Sep 6, 2021
500cf72
Removed management command
adam-murray Sep 6, 2021
2017d90
Migration 10 now handles lack of versioning gracefully.
adam-murray Sep 7, 2021
25e552e
Add snippet property for backwards compatibility
adam-murray Sep 7, 2021
59f82a8
Remove old foreign key from plugin, and rename new one
adam-murray Sep 7, 2021
25048ff
Cleaned up migration and models
adam-murray Sep 7, 2021
649c4af
Removed unecessary logging
adam-murray Sep 7, 2021
061ebc4
Merged with target changes
adam-murray Sep 7, 2021
bc8d60e
Remove redundent comment
adam-murray Sep 7, 2021
4103082
Update djangocms_snippet/migrations/0010_cms4_grouper_version_data_mi…
adam-murray Sep 7, 2021
ad25ec8
Update djangocms_snippet/migrations/0010_cms4_grouper_version_data_mi…
adam-murray Sep 7, 2021
929d9d6
Update djangocms_snippet/migrations/0011_cms4_plugin_data_migration.py
adam-murray Sep 7, 2021
8e624d9
Update djangocms_snippet/conf.py
adam-murray Sep 7, 2021
f7c848e
Update djangocms_snippet/migrations/0011_cms4_plugin_data_migration.py
adam-murray Sep 7, 2021
85f96f2
Fixed variable name spelling mistake
adam-murray Sep 7, 2021
669d34b
Merge branch 'feature/snippet-data-migration' of github.com:adam-murr…
adam-murray Sep 7, 2021
bea0a0a
Use util
adam-murray Sep 7, 2021
9808226
Updated linting in migrations, and versioning enabled check
adam-murray Sep 7, 2021
530e416
Added instructions for DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID…
adam-murray Sep 7, 2021
a3cdc9b
Added instructions for DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID…
adam-murray Sep 7, 2021
ce96a1f
Added instructions for DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID…
adam-murray Sep 7, 2021
c696c67
isort
adam-murray Sep 7, 2021
3e3b736
Removed unecessary plugin
adam-murray Sep 7, 2021
1aec683
Changed to version4 python version compatibility in test suite
adam-murray Sep 7, 2021
7050f88
merge
adam-murray Sep 7, 2021
53609d2
Updated to cms4 based test suite
adam-murray Sep 8, 2021
eac5cad
Merged
adam-murray Sep 8, 2021
8dfb6db
Removed redundent abstract model
adam-murray Sep 8, 2021
ff5d635
Fixed app config issue
adam-murray Sep 8, 2021
c2f62de
Removed unused management command
adam-murray Sep 8, 2021
ef314fb
Removed management command
adam-murray Sep 8, 2021
0ad68fe
Updates snippet tests for cms4
adam-murray Sep 8, 2021
f3943a3
linting
adam-murray Sep 8, 2021
a08485e
Removed unecessary published flag on page creation
adam-murray Sep 8, 2021
7ff44b1
Merged
adam-murray Sep 9, 2021
736b975
Push for testing
adam-murray Sep 9, 2021
9dd2563
Updates to tests
adam-murray Sep 9, 2021
4171e2e
Merged with versioned snippets
adam-murray Sep 9, 2021
96035a3
Added factories, fixed model tests and templatetag tests
adam-murray Sep 10, 2021
5b65538
Updated plugin tests
adam-murray Sep 10, 2021
aa62ced
Plugin tests now use factories
adam-murray Sep 10, 2021
9fba572
Linting
adam-murray Sep 10, 2021
aeaa52a
Linting
adam-murray Sep 10, 2021
bdf4eaa
Fixed old issue with migrations
adam-murray Sep 13, 2021
aa5a54c
Fixed old issue with migrations
adam-murray Sep 13, 2021
2d36a3b
Fixed spelling mistake
adam-murray Sep 13, 2021
a8f56f3
Updated test to no longer use factoris
adam-murray Sep 13, 2021
b87a0d6
Fixed rendering
adam-murray Sep 13, 2021
7375e5b
Fixed migration error
adam-murray Sep 13, 2021
03df8f7
Updated comments
adam-murray Sep 13, 2021
f895bf1
Migration linting
adam-murray Sep 14, 2021
e16c02c
Merge branch 'feature/snippet-data-migration' into feature/moderation…
adam-murray Sep 14, 2021
e4cf009
Made copy function test and started copy function
adam-murray Sep 14, 2021
79eebf4
Remove unique=True from snipept slug field
adam-murray Sep 14, 2021
6bf6557
Merge branch 'feature/snippet-data-migration' into feature/moderation…
adam-murray Sep 14, 2021
38c211d
Removed unique=True on name
adam-murray Sep 14, 2021
0cd495b
Enabled moderation, updates to cms_config
adam-murray Sep 14, 2021
247ae36
Updated config test
adam-murray Sep 14, 2021
ee07ad5
Update djangocms_snippet/models.py
adam-murray Sep 15, 2021
9b23fa8
Refactrogin
adam-murray Sep 15, 2021
7cbaaa3
Merged
adam-murray Sep 15, 2021
7cb6cc8
Linting
adam-murray Sep 15, 2021
b59a31d
Refactored test_plugin to closer to original
adam-murray Sep 15, 2021
3153940
Refactoring tests
adam-murray Sep 15, 2021
3d97dc8
Updated tests and migration to make grouper mandatory
adam-murray Sep 15, 2021
366739b
Updated models to even with migrations
adam-murray Sep 15, 2021
3853d19
Refactor
adam-murray Sep 15, 2021
e958a03
Linting
adam-murray Sep 15, 2021
d6b2a59
Merged with migration code
adam-murray Sep 15, 2021
c5c236b
Removed unused util
adam-murray Sep 15, 2021
dbfb808
Added migration and change for removing unique=True, allowing version…
adam-murray Sep 15, 2021
8e599f3
Added checks for whether moderation is enabled
adam-murray Sep 15, 2021
20ed1c8
Linting
adam-murray Sep 15, 2021
463fd7c
Linting
adam-murray Sep 15, 2021
1a7377a
Added additional test criteria
adam-murray Sep 16, 2021
1859b13
Fixed test
adam-murray Sep 16, 2021
2efcc9e
Merge branch 'feature/snippet-data-migration' into feature/moderation…
adam-murray Sep 16, 2021
ae215dc
merged with migration
adam-murray Sep 16, 2021
59dc101
Updated models to match migration
adam-murray Sep 16, 2021
691056c
Revert to default copy function, updated test
adam-murray Sep 17, 2021
229c915
Linting
adam-murray Sep 17, 2021
73dd9d8
Linting
adam-murray Sep 17, 2021
d0ba699
Remove duplicate variable declaration
adam-murray Sep 17, 2021
39f4f22
Additional test case for copy method
adam-murray Sep 17, 2021
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
16 changes: 15 additions & 1 deletion djangocms_snippet/cms_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@

from cms.app_base import CMSAppConfig

from .models import Snippet
from djangocms_snippet.models import Snippet


try:
from djangocms_moderation import __version__ # NOQA

djangocms_moderation_installed = True
except ImportError:
djangocms_moderation_installed = False


class SnippetCMSAppConfig(CMSAppConfig):
djangocms_versioning_enabled = getattr(
settings, 'DJANGOCMS_SNIPPET_VERSIONING_ENABLED', False
)
djangocms_moderation_enabled = getattr(
settings, 'DJANGOCMS_SNIPPET_MODERATION_ENABLED', False
)

if djangocms_moderation_enabled and djangocms_moderation_installed:
moderated_models = [Snippet]

if djangocms_versioning_enabled:
from djangocms_versioning.datastructures import (
Expand Down
23 changes: 23 additions & 0 deletions djangocms_snippet/migrations/0013_auto_20210915_0751.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.24 on 2021-09-15 07:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('djangocms_snippet', '0012_auto_20210915_0721'),
]

operations = [
migrations.AlterField(
model_name='snippet',
name='name',
field=models.CharField(max_length=255, verbose_name='Name'),
),
migrations.AlterField(
model_name='snippet',
name='slug',
field=models.SlugField(default='', max_length=255, verbose_name='Slug'),
),
]
2 changes: 0 additions & 2 deletions djangocms_snippet/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Snippet(models.Model):
name = models.CharField(
verbose_name=_('Name'),
max_length=255,
unique=True,
)
snippet_grouper = models.ForeignKey(
SnippetGrouper,
Expand All @@ -46,7 +45,6 @@ class Snippet(models.Model):
blank=False,
default='',
max_length=255,
unique=True,
)

def __str__(self):
Expand Down
1 change: 1 addition & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'LANGUAGE_CODE': 'en',
'ALLOWED_HOSTS': ['localhost'],
'DJANGOCMS_SNIPPET_VERSIONING_ENABLED': True,
'DJANGOCMS_SNIPPET_MODERATION_ENABLED': True,
}


Expand Down
30 changes: 30 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.apps import apps

from cms.test_utils.testcases import CMSTestCase

from djangocms_snippet.models import Snippet, SnippetGrouper

from .utils.factories import SnippetWithVersionFactory


class VersioningConfigTestCase(CMSTestCase):

def test_snippet_copy_method(self):
"""
App should use the default copy method, and return an identical model (apart from PK)
"""
snippet_cms_config = apps.get_app_config("djangocms_snippet").cms_config
old_snippet = SnippetWithVersionFactory(
name="snippet",
html="<p>Hello World</p>",
slug="snippet",
)

new_snippet = snippet_cms_config.versioning[0].copy_function(old_snippet)

self.assertNotEqual(old_snippet, new_snippet)
self.assertEqual(old_snippet.name, new_snippet.name)
self.assertEqual(old_snippet.html, new_snippet.html)
self.assertEqual(old_snippet.snippet_grouper, new_snippet.snippet_grouper)
self.assertEqual(1, SnippetGrouper.objects.count())
self.assertEqual(2, Snippet._base_manager.count())