From 9151e105ea64bd3104d02f4c52b8a9fa26d353b7 Mon Sep 17 00:00:00 2001 From: vipulnarang95 <61502917+vipulnarang95@users.noreply.github.com> Date: Tue, 12 May 2020 21:28:35 +0530 Subject: [PATCH 01/37] Feature/cms version 4 compatible (#51) * Update compatible with Django CMS version4 sitemap.py and cms_toolbars.py updated to support page menu and sitemap compatible with Django CMS version 4 Co-authored-by: Vipul, Narang --- .travis.yml | 15 +++---- cms_helper.py | 11 +++++ djangocms_page_sitemap/cms_toolbars.py | 14 ++---- .../migrations/0001_initial.py | 1 - djangocms_page_sitemap/sitemap.py | 43 ++++++++++++++++++- tests/base.py | 7 +-- tests/test_models.py | 15 ++----- tests/test_sitemap.py | 11 +---- tox.ini | 15 +++++-- 9 files changed, 79 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index 145e3e2..0d82458 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,9 @@ env: - TOXENV='pep8' - TOXENV='isort' - TOXENV='docs' - - DJANGO='django22' CMS='cms37' - - DJANGO='django21' CMS='cms37' - - DJANGO='django21' CMS='cms36' - - DJANGO='django111' CMS='cms37' - - DJANGO='django111' CMS='cms36' + - DJANGO='django111' CMS='cms40' FE=1 + - DJANGO='django21' CMS='cms40' FE=1 + - DJANGO='django22' CMS='cms40' FE=1 # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors @@ -57,10 +55,7 @@ matrix: env: TOXENV='isort' - python: 3.6 env: TOXENV='docs' - - - python: 2.7 - env: DJANGO='django22' CMS='cms37' - python: 2.7 - env: DJANGO='django21' CMS='cms37' + env: DJANGO='django22' CMS='cms40' FE=1 - python: 2.7 - env: DJANGO='django21' CMS='cms36' + env: DJANGO='django21' CMS='cms40' FE=1 diff --git a/cms_helper.py b/cms_helper.py index cd2a474..35d4008 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -5,6 +5,14 @@ import sys +class DisableMigrations(object): + def __contains__(self, item): + return True + + def __getitem__(self, item): + return None + + def gettext(s): return s @@ -23,6 +31,9 @@ def gettext(s): 'permissions': 10, }, 'ROOT_URLCONF': 'tests.test_utils.urls', + # FIXME: Django CMS migrtions with Django 2.2 produce an error when + # running tests, temporarily disabling migrations + 'MIGRATION_MODULES': DisableMigrations(), 'INSTALLED_APPS': [ 'django.contrib.sitemaps', ], diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py index f44693c..de076cf 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -from cms.api import get_page_draft -from cms.cms_toolbars import PAGE_MENU_THIRD_BREAK -from cms.toolbar.items import Break -from cms.toolbar_base import CMSToolbar +from cms.cms_toolbars import PlaceholderToolbar from cms.toolbar_pool import toolbar_pool from cms.utils.conf import get_cms_setting from cms.utils.permissions import has_page_permission @@ -17,10 +14,9 @@ @toolbar_pool.register -class PageSitemapPropertiesMeta(CMSToolbar): +class PageSitemapPropertiesMeta(PlaceholderToolbar): def populate(self): - # always use draft if we have a page - self.page = get_page_draft(self.request.current_page) + self.page = self.request.current_page if not self.page: # Nothing to do return @@ -44,8 +40,6 @@ def populate(self): except AttributeError: not_edit_mode = not self.toolbar.edit_mode_active current_page_menu = self.toolbar.get_or_create_menu('page') - position = current_page_menu.find_first( - Break, identifier=PAGE_MENU_THIRD_BREAK) - 1 # Page tags try: page_extension = PageSitemapProperties.objects.get(extended_object_id=self.page.pk) @@ -64,5 +58,5 @@ def populate(self): pass else: current_page_menu.add_modal_item( - PAGE_SITEMAP_MENU_TITLE, url=url, disabled=not_edit_mode, position=position + PAGE_SITEMAP_MENU_TITLE, url=url, disabled=not_edit_mode ) diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py index a560ff6..2334e64 100644 --- a/djangocms_page_sitemap/migrations/0001_initial.py +++ b/djangocms_page_sitemap/migrations/0001_initial.py @@ -8,7 +8,6 @@ class Migration(migrations.Migration): - dependencies = [ ('cms', '__first__'), ] diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py index 0dad866..c3c7766 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -1,7 +1,12 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals +from collections import defaultdict + +from cms.models import PageContent, PageUrl from cms.sitemaps import CMSSitemap +from cms.utils import get_current_site +from cms.utils.i18n import get_public_languages from django.core.cache import cache from .models import PageSitemapProperties @@ -14,10 +19,44 @@ class ExtendedSitemap(CMSSitemap): default_priority = CMSSitemap.priority def items(self): - return super(ExtendedSitemap, self).items().exclude( - page__pagesitemapproperties__include_in_sitemap=False + # FIXME:This method was created from this commit: + # https://github.com/divio/django-cms/blob/2894ae8bcf92092d947a097499c01ab2bbb0e6df/cms/sitemaps/cms_sitemap.py + site = get_current_site() + languages = get_public_languages(site_id=site.pk) + all_urls = ( + PageUrl + .objects + .get_for_site(site) + .select_related('page') + .filter(language__in=languages, path__isnull=False, page__login_required=False) + .order_by('page__node__path') + ) + excluded_titles_by_page = defaultdict(set) + # Added filter to add pages to excluded translation that have include_in_sitemap as False + excluded_translations = ( + PageContent + .objects + .filter( + language__in=languages, + page__node__site=site, + page__pagesitemapproperties__include_in_sitemap=False + ) + .values_list('page', 'language') ) + for page_id, language in excluded_translations: + excluded_titles_by_page[page_id].add(language) + + valid_urls = [] + + for page_url in all_urls: + excluded = excluded_titles_by_page.get(page_url.page_id, []) + + if page_url.language in excluded: + continue + valid_urls.append(page_url) + return valid_urls + def priority(self, title): ext_key = get_cache_key(title.page) properties = cache.get(ext_key) diff --git a/tests/base.py b/tests/base.py index 5989930..e19a185 100644 --- a/tests/base.py +++ b/tests/base.py @@ -35,15 +35,10 @@ def get_pages(self): create_title(language='fr', title='page un', page=page_1) create_title(language='it', title='pagina uno', page=page_1) create_title(language='fr', title='page trois', page=page_3) - for lang in self.languages: - page_1.publish(lang) - page_2.publish('en') - page_3.publish('en') - page_3.publish('fr') if hasattr(page_1, 'set_as_homepage'): page_1.set_as_homepage() - return page_1.get_draft_object(), page_2.get_draft_object(), page_3.get_draft_object() + return page_1, page_2, page_3 def get_request(self, page, lang): request = self.request_factory.get(page.get_path(lang)) diff --git a/tests/test_models.py b/tests/test_models.py index aff04f2..b753319 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -65,17 +65,15 @@ def test_robots_page_parameter(self): extension = PageSitemapProperties.objects.create( extended_object=page1, priority='0.2', changefreq='never' ) - page1.publish('en') extension.refresh_from_db() template = '{% load robots_index %}{% page_robots %}' expected = '' - context = {'request': self.get_page_request(page2.get_public_object(), AnonymousUser())} + context = {'request': self.get_page_request(page2, AnonymousUser())} self._test_robots_tag(template, context, expected) extension.noindex = True extension.save() - page1.publish('en') expected = '' self._test_robots_tag(template, context, expected) @@ -85,13 +83,11 @@ def test_robots_page_parameter(self): extension.noarchive = True extension.save() - page1.publish('en') expected = '' self._test_robots_tag(template, context, expected) extension.robots_extra = 'nodmoz' extension.save() - page1.publish('en') expected = '' self._test_robots_tag(template, context, expected) @@ -100,12 +96,11 @@ def test_robots_page_no_site(self): extension = PageSitemapProperties.objects.create( extended_object=page1, priority='0.2', changefreq='never' ) - page1.publish('en') extension.refresh_from_db() template = '{% load robots_index %}{% page_robots None "abc" %}' expected = '' - context = {'request': self.get_page_request(page2.get_public_object(), AnonymousUser())} + context = {'request': self.get_page_request(page2, AnonymousUser())} self._test_robots_tag(template, context, expected) def test_robots_page_no_page(self): @@ -113,12 +108,11 @@ def test_robots_page_no_page(self): extension = PageSitemapProperties.objects.create( extended_object=page1, priority='0.2', changefreq='never' ) - page1.publish('en') extension.refresh_from_db() template = '{% load robots_index %}{% page_robots "abc" %}' expected = '' - context = {'request': self.get_page_request(page2.get_public_object(), AnonymousUser())} + context = {'request': self.get_page_request(page2, AnonymousUser())} self._test_robots_tag(template, context, expected) def test_robots_page_other_site(self): @@ -127,10 +121,9 @@ def test_robots_page_other_site(self): extension = PageSitemapProperties.objects.create( extended_object=page1, priority='0.2', changefreq='never' ) - page1.publish('en') extension.refresh_from_db() template = '{%% load robots_index %%}{%% page_robots None %s %%}' % site_2.pk expected = '' - context = {'request': self.get_page_request(page2.get_public_object(), AnonymousUser())} + context = {'request': self.get_page_request(page2, AnonymousUser())} self._test_robots_tag(template, context, expected) diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index aa87b88..36ffac2 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -27,7 +27,6 @@ def test_sitemap_extended(self): PageSitemapProperties.objects.create( extended_object=page1, priority='0.2', changefreq='never' ) - page1.publish('it') sitemap = self.client.get('/sitemap.xml') self.assertContains(sitemap, test_string) @@ -38,10 +37,7 @@ def test_sitemap_exclude(self): ) sitemap = ExtendedSitemap() # unpublished since change, still in the sitemap - self.assertEqual(len(sitemap.items()), 6) - - page3.publish('en') - page3.publish('fr') + self.assertEqual(len(sitemap.items()), 4) sitemap = ExtendedSitemap() # published, then no longer in the sitemap self.assertEqual(len(sitemap.items()), 4) @@ -54,10 +50,6 @@ def test_sitemap_cache(self): PageSitemapProperties.objects.create( extended_object=page3, priority='0.8', changefreq='hourly' ) - page1.publish('fr') - page1 = page1.get_public_object() - page3.publish('fr') - page3 = page3.get_public_object() sitemap = ExtendedSitemap() self.assertEqual(len(sitemap.items()), 6) for item in sitemap.items(): @@ -77,3 +69,4 @@ def test_sitemap_cache(self): ext_key = get_cache_key(page3) page3.delete() self.assertEqual(cache.get(ext_key), None) + \ No newline at end of file diff --git a/tox.ini b/tox.ini index 1b8e1b8..7a59d8b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = docs,pep8,isort,py{37,36,35}-django{22}-cms{37},py{37,36,35}-django{21,111}-cms{37,36} +envlist = docs,pep8,isort,py{35,36,37}-django{111,21,22}-cms40,py{27}-django{111}-cms40 [testenv] commands = {env:COMMAND:python} setup.py test @@ -8,20 +8,26 @@ deps = django111: django-formtools>=2.1,<2.2 django21: Django>=2.1,<2.2 django22: Django>=2.2,<2.3 - cms36: https://github.com/divio/django-cms/archive/release/3.6.x.zip - cms37: https://github.com/divio/django-cms/archive/release/3.7.x.zip - cmsdev: https://github.com/divio/django-cms/archive/develop.zip + cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip -r{toxinidir}/requirements-test.txt +basepython = + py27: python2.7 + py35: python3.5 + py36: python3.6 + py37: python3.7 + [testenv:isort] commands = isort -c -rc deps = isort skip_install = true +basepython = python3.5 [testenv:pep8] commands = flake8 deps = flake8 skip_install = true +basepython = python3.5 [testenv:docs] changedir = docs @@ -32,3 +38,4 @@ deps = sphinx-rtd-theme -rrequirements-docs.txt skip_install = true +basepython = python3.5 From 81c5e9e2794f4647c7b9c93d3ef0a215e05b7599 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 15 May 2020 17:52:54 +0200 Subject: [PATCH 02/37] Relese 0.9.0a1 --- AUTHORS.rst | 1 + HISTORY.rst | 6 ++++++ djangocms_page_sitemap/__init__.py | 2 +- setup.py | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 9055d72..108dad2 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -13,3 +13,4 @@ Contributors * Anton Egorov * carderm * Jeroen Peters +* vipulnarang95 diff --git a/HISTORY.rst b/HISTORY.rst index cf3126e..46858ba 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,12 @@ History ------- + +0.9.0 (2020-05-15) +++++++++++++++++++ + +* Port to django CMS 4.0 + 0.8.0 (2020-01-12) ++++++++++++++++++ diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 99aa543..456c7a2 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -__version__ = '0.8.1dev1' # pragma: no cover +__version__ = '0.9.0dev2' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover diff --git a/setup.py b/setup.py index 3c6b4c9..fcb5ce4 100755 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ ], include_package_data=True, install_requires=[ - 'django-cms>=3.6', + 'django-cms>=4.0.0a1', ], license='BSD', zip_safe=False, From 2e7100d64c8400d4e9e8146bddaf2a60de21e9a3 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Tue, 19 May 2020 15:46:01 +0200 Subject: [PATCH 03/37] Fix django CMS requirements in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fcb5ce4..d7af0d2 100755 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ ], include_package_data=True, install_requires=[ - 'django-cms>=4.0.0a1', + 'django-cms>=4.0.0dev8', ], license='BSD', zip_safe=False, From a85999e400933ecef12b3341ef19b984a2a497ee Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Tue, 19 May 2020 15:52:17 +0200 Subject: [PATCH 04/37] Release 0.9.0dev3 --- HISTORY.rst | 2 +- djangocms_page_sitemap/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 46858ba..f133050 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,7 +4,7 @@ History ------- -0.9.0 (2020-05-15) +0.9.0 (unreleased) ++++++++++++++++++ * Port to django CMS 4.0 diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 456c7a2..18469d4 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -__version__ = '0.9.0dev2' # pragma: no cover +__version__ = '0.9.0dev3' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover From a208e1ee5a52ecb07618a4d24095a25aa41e4b23 Mon Sep 17 00:00:00 2001 From: NarenderRajuB Date: Sat, 8 Aug 2020 06:57:23 +0100 Subject: [PATCH 05/37] Updated lastmod() to return latest publish version modified date in cms4 (#58) * Updated lastmod() to return latest publish version modified date if versioning is enabled. Co-authored-by: narender81 --- djangocms_page_sitemap/sitemap.py | 19 ++++++++++++++++++- djangocms_page_sitemap/utils.py | 10 ++++++++++ tests/test_sitemap.py | 19 +++++++++++++++++-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py index c3c7766..8fe9c59 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -11,7 +11,7 @@ from .models import PageSitemapProperties from .settings import PAGE_SITEMAP_CACHE_DURATION, PAGE_SITEMAP_DEFAULT_CHANGEFREQ -from .utils import get_cache_key +from .utils import get_cache_key, is_versioning_enabled class ExtendedSitemap(CMSSitemap): @@ -80,3 +80,20 @@ def changefreq(self, title): return title.page.pagesitemapproperties.changefreq except PageSitemapProperties.DoesNotExist: return self.default_changefreq + + def lastmod(self, page_url): + # if versioning is enabled we return the latest version modified using the versioning + # modified date. if versioning is disabled we return the page changed_date + if is_versioning_enabled(): + site = get_current_site() + page_contents = PageContent.objects.filter( + page=page_url.page, + language=page_url.language, + page__node__site=site, + ).first() + + if page_contents: + published_version = page_contents.versions.first() + return published_version.modified + + return page_url.page.changed_date diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py index f68cf52..9380a41 100644 --- a/djangocms_page_sitemap/utils.py +++ b/djangocms_page_sitemap/utils.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, print_function, unicode_literals from cms.cache import _get_cache_key +from django.apps import apps def get_cache_key(page): @@ -13,3 +14,12 @@ def get_cache_key(page): except AttributeError: site_id = page.site_id return _get_cache_key('page_sitemap', page, 'default', site_id) + + +def is_versioning_enabled(): + from cms.models import PageContent + try: + app_config = apps.get_app_config('djangocms_versioning') + return app_config.cms_extension.is_content_model_versioned(PageContent) + except LookupError: + return False diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index 36ffac2..c09543d 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -2,13 +2,14 @@ from __future__ import absolute_import, print_function, unicode_literals from decimal import Decimal +from unittest import skipIf from django.core.cache import cache from django.utils.timezone import now from djangocms_page_sitemap.models import PageSitemapProperties from djangocms_page_sitemap.sitemap import ExtendedSitemap -from djangocms_page_sitemap.utils import get_cache_key +from djangocms_page_sitemap.utils import get_cache_key, is_versioning_enabled from .base import BaseTest @@ -69,4 +70,18 @@ def test_sitemap_cache(self): ext_key = get_cache_key(page3) page3.delete() self.assertEqual(cache.get(ext_key), None) - \ No newline at end of file + + @skipIf(not is_versioning_enabled(), 'This test can only run when versioning is installed') + def test_pageurl_lastmod_with_cms4_versioning(self): + # Check the latest version modified date for the page is checked for lastmod() + # if versioning is enabled, Currenly test is skipped , as this may require changes in testsuite + from cms.api import create_page, create_title + page_1 = create_page('page-one', 'page.html', language='en', created_by=self.user) + page_content = create_title(title='page un', language='en', page=page_1, created_by=self.user) + last_modified_date = '%s' % ( + page_content.get.versions.first().modified.strftime('%Y-%m-%d') + ) + expected_string = 'http://example.com%s%smonthly0.5' % (page_1.get_absolute_url(language='en'), last_modified_date) + sitemap = self.client.get('/sitemap.xml') + + self.assertContains(sitemap, expected_string) From 42d5a520719d756b259d76e5e35a92499d3e186c Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 8 Aug 2020 07:58:26 +0200 Subject: [PATCH 06/37] Release 0.9.0dev4 --- HISTORY.rst | 1 + djangocms_page_sitemap/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index f133050..b98f145 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,7 @@ History ++++++++++++++++++ * Port to django CMS 4.0 +* Fix djangocms-versioning integration 0.8.0 (2020-01-12) ++++++++++++++++++ diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 18469d4..7ecb4be 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -__version__ = '0.9.0dev3' # pragma: no cover +__version__ = '0.9.0dev4' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover From 07d00b855bd20854a824410e74c44199ff7bc401 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Wed, 2 Sep 2020 01:27:49 +0200 Subject: [PATCH 07/37] Release 0.9.0dev5 --- djangocms_page_sitemap/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 7ecb4be..51c7df3 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -__version__ = '0.9.0dev4' # pragma: no cover +__version__ = '0.9.0dev5' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover From 47026971ed5b50a2309b5d92d80af4049aac2660 Mon Sep 17 00:00:00 2001 From: Aiky30 Date: Fri, 25 Sep 2020 13:31:58 +0100 Subject: [PATCH 08/37] Use the correct toolbar for versioning and django-cms v4 (#59) * Use the page toolbar from the CMS as this doesn't add more buttons. It's also designed fro use just on the page too * Functioning toolbar with versioning enabled * Added versioning test to ensure that the toolbar duplicated button issue never occurs again * Remove limit on versioning being installed. The test suite should run the same regardless of versioning --- djangocms_page_sitemap/cms_toolbars.py | 16 +++++----- tests/base.py | 12 ++++---- tests/test_sitemap.py | 2 +- tests/test_toolbar.py | 42 ++++++++++++++++++++++++++ tox.ini | 30 +++++++++++++++--- 5 files changed, 83 insertions(+), 19 deletions(-) diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py index de076cf..129edb9 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -from cms.cms_toolbars import PlaceholderToolbar from cms.toolbar_pool import toolbar_pool from cms.utils.conf import get_cms_setting from cms.utils.permissions import has_page_permission @@ -10,11 +9,18 @@ from .models import PageSitemapProperties +# Handle versioned toolbar if it exists, otherwise just use the normal CMS toolbar +try: + from djangocms_versioning.cms_toolbars import VersioningPageToolbar as PageToolbar +except ImportError: + from cms.cms_toolbars import PageToolbar + + PAGE_SITEMAP_MENU_TITLE = _('Sitemap properties') @toolbar_pool.register -class PageSitemapPropertiesMeta(PlaceholderToolbar): +class PageSitemapPropertiesMeta(PageToolbar): def populate(self): self.page = self.request.current_page if not self.page: @@ -34,11 +40,7 @@ def populate(self): self.request.current_page.has_change_permission(self.request.user) ) if has_global_current_page_change_permission or can_change: - try: - # cms 3.4.5 compat - not_edit_mode = not self.toolbar.edit_mode - except AttributeError: - not_edit_mode = not self.toolbar.edit_mode_active + not_edit_mode = not self.toolbar.edit_mode_active current_page_menu = self.toolbar.get_or_create_menu('page') # Page tags try: diff --git a/tests/base.py b/tests/base.py index e19a185..7b860d2 100644 --- a/tests/base.py +++ b/tests/base.py @@ -29,12 +29,12 @@ def setUpClass(cls): def get_pages(self): from cms.api import create_page, create_title - page_1 = create_page('page one', 'page.html', language='en') - page_2 = create_page('page two', 'page.html', language='en') - page_3 = create_page('page three', 'page.html', language='en') - create_title(language='fr', title='page un', page=page_1) - create_title(language='it', title='pagina uno', page=page_1) - create_title(language='fr', title='page trois', page=page_3) + page_1 = create_page('page one', 'page.html', language='en', created_by=self.user) + page_2 = create_page('page two', 'page.html', language='en', created_by=self.user) + page_3 = create_page('page three', 'page.html', language='en', created_by=self.user) + create_title(language='fr', title='page un', page=page_1, created_by=self.user) + create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) + create_title(language='fr', title='page trois', page=page_3, created_by=self.user) if hasattr(page_1, 'set_as_homepage'): page_1.set_as_homepage() diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index c09543d..2e1ce58 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -79,7 +79,7 @@ def test_pageurl_lastmod_with_cms4_versioning(self): page_1 = create_page('page-one', 'page.html', language='en', created_by=self.user) page_content = create_title(title='page un', language='en', page=page_1, created_by=self.user) last_modified_date = '%s' % ( - page_content.get.versions.first().modified.strftime('%Y-%m-%d') + page_content.versions.first().modified.strftime('%Y-%m-%d') ) expected_string = 'http://example.com%s%smonthly0.5' % (page_1.get_absolute_url(language='en'), last_modified_date) sitemap = self.client.get('/sitemap.xml') diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index af132b2..e13c799 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals +from cms.api import create_page +from cms.test_utils.testcases import CMSTestCase from cms.toolbar.items import Menu, ModalItem +from cms.toolbar.utils import get_object_preview_url from django.contrib.auth.models import Permission, User from django.test.utils import override_settings from django.urls import reverse @@ -14,6 +17,21 @@ from .base import BaseTest +def find_toolbar_buttons(button_name, toolbar): + """ + Taken from: from djangocms_versioning.test_utils.test_helpers import find_toolbar_buttons + + CAVEAT: This test helper is not currently accesible due to the fact that it would then enforce + versioning test packages and factory boy on this test suite. + """ + found = [] + for button_list in toolbar.get_right_items(): + found = found + [ + button for button in button_list.buttons if button.name == button_name + ] + return found + + class ToolbarTest(BaseTest): def test_no_page(self): @@ -117,3 +135,27 @@ def test_toolbar_with_items(self): )[0].item self.assertTrue(meta_menu.url.startswith(reverse('admin:djangocms_page_sitemap_pagesitemapproperties_change', args=(page_ext.pk,)))) self.assertEqual(force_text(page_ext), force_text(_('Sitemap values for Page %s') % page1.pk)) + + +class VersioningToolbarTest(CMSTestCase): + + def test_toolbar_buttons_are_not_duplicated(self): + """ + The toolbar for djangocms-page-sitemap doesn't affect the toolbar buttons. + + This test Can be ran with or without versioning and should return the same result! + """ + user = self.get_superuser() + page_1 = create_page('page-one', 'page.html', language='en', created_by=user) + page_content = page_1.get_title_obj(language='en') + preview_endpoint = get_object_preview_url(page_content, language='en') + + with self.login_user_context(self.get_superuser()): + response = self.client.post(preview_endpoint) + + edit_button_list = find_toolbar_buttons("Edit", response.wsgi_request.toolbar) + create_button_list = find_toolbar_buttons("Create", response.wsgi_request.toolbar) + + # Only one edit and create button should exist + self.assertEqual(len(edit_button_list), 1) + self.assertEqual(len(create_button_list), 1) diff --git a/tox.ini b/tox.ini index 7a59d8b..62c446f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,44 @@ [tox] -envlist = docs,pep8,isort,py{35,36,37}-django{111,21,22}-cms40,py{27}-django{111}-cms40 +envlist = + docs + pep8 + isort + py{35,36,37}-django{111,21}-cms40 + py{35,36,37}-django22-cms40 + +skip_missing_interpreters=True [testenv] commands = {env:COMMAND:python} setup.py test + deps = + -r{toxinidir}/requirements-test.txt + + # Django 1.11 installation requirements django111: Django>=1.11,<2.0 - django111: django-formtools>=2.1,<2.2 + django111: django-formtools>=2.1<2.2 + django111: django-sekizai<2.0.0 + django111: djangocms_admin_style<2.0.0 + django111: django-classy-tags<2.0.0 + + # Django 2.1 installation requirements django21: Django>=2.1,<2.2 + django21: django-sekizai<2.0.0 + django21: djangocms_admin_style<2.0.0 + django21: django-classy-tags<2.0.0 + django22: Django>=2.2,<2.3 + cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip - -r{toxinidir}/requirements-test.txt + basepython = - py27: python2.7 py35: python3.5 py36: python3.6 py37: python3.7 [testenv:isort] -commands = isort -c -rc +commands = isort --recursive --check-only --diff {toxinidir} deps = isort skip_install = true basepython = python3.5 From 230558c1f671345ff863dfc348dda638b1e53509 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 25 Sep 2020 16:08:51 +0200 Subject: [PATCH 09/37] Release 0.9.0dev6 --- djangocms_page_sitemap/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 51c7df3..0392526 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -__version__ = '0.9.0dev5' # pragma: no cover +__version__ = '0.9.0dev6' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover From 98e141744293b641d031a46c6cd599afd0a6c10a Mon Sep 17 00:00:00 2001 From: NarenderRajuB Date: Fri, 20 Nov 2020 00:21:53 +0000 Subject: [PATCH 10/37] Feature/list published pagecontent if versioning enabled (#61) * Add filter to list only published pages in versioning is enabled/installed * Add test to check query performance Co-authored-by: narender81 --- djangocms_page_sitemap/sitemap.py | 42 ++++++++++++--------------- setup.py | 6 ++-- tests/base.py | 24 ++++++++++++++++ tests/test_sitemap.py | 48 ++++++++++++++++++++++++++----- tests/test_toolbar.py | 9 +++++- 5 files changed, 95 insertions(+), 34 deletions(-) diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py index 8fe9c59..b21c37d 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -8,6 +8,7 @@ from cms.utils import get_current_site from cms.utils.i18n import get_public_languages from django.core.cache import cache +from django.db.models import Prefetch from .models import PageSitemapProperties from .settings import PAGE_SITEMAP_CACHE_DURATION, PAGE_SITEMAP_DEFAULT_CHANGEFREQ @@ -23,38 +24,33 @@ def items(self): # https://github.com/divio/django-cms/blob/2894ae8bcf92092d947a097499c01ab2bbb0e6df/cms/sitemaps/cms_sitemap.py site = get_current_site() languages = get_public_languages(site_id=site.pk) + page_content_prefetch = Prefetch( + 'page__pagecontent_set', + queryset=PageContent.objects.filter( + language__in=languages, + ) + ) all_urls = ( PageUrl - .objects - .get_for_site(site) - .select_related('page') - .filter(language__in=languages, path__isnull=False, page__login_required=False) - .order_by('page__node__path') - ) - excluded_titles_by_page = defaultdict(set) - # Added filter to add pages to excluded translation that have include_in_sitemap as False - excluded_translations = ( - PageContent - .objects - .filter( + .objects + .get_for_site(site) + .prefetch_related(page_content_prefetch) + .filter( language__in=languages, + path__isnull=False, + page__login_required=False, page__node__site=site, - page__pagesitemapproperties__include_in_sitemap=False ) - .values_list('page', 'language') + .exclude(page__pagesitemapproperties__include_in_sitemap=False) + .order_by('page__node__path') ) - - for page_id, language in excluded_translations: - excluded_titles_by_page[page_id].add(language) - valid_urls = [] - for page_url in all_urls: - excluded = excluded_titles_by_page.get(page_url.page_id, []) + for page_content in page_url.page.pagecontent_set.all(): + if page_url.language == page_content.language: + valid_urls.append(page_url) + break - if page_url.language in excluded: - continue - valid_urls.append(page_url) return valid_urls def priority(self, title): diff --git a/setup.py b/setup.py index d7af0d2..c2fbabb 100755 --- a/setup.py +++ b/setup.py @@ -35,9 +35,6 @@ 'djangocms_page_sitemap', ], include_package_data=True, - install_requires=[ - 'django-cms>=4.0.0dev8', - ], license='BSD', zip_safe=False, keywords='djangocms-page-sitemap', @@ -60,4 +57,7 @@ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', ], + dependency_links=[ + "http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms-4.0.0", + ], ) diff --git a/tests/base.py b/tests/base.py index 7b860d2..5ec4382 100644 --- a/tests/base.py +++ b/tests/base.py @@ -7,6 +7,8 @@ from django.test import RequestFactory, TestCase from django.utils.six import StringIO +from djangocms_page_sitemap.utils import is_versioning_enabled + class BaseTest(TestCase): """ @@ -35,6 +37,28 @@ def get_pages(self): create_title(language='fr', title='page un', page=page_1, created_by=self.user) create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) create_title(language='fr', title='page trois', page=page_3, created_by=self.user) + page_content1 = create_title( + title='pagecontent1_en', + language='en', + page=page_1, + created_by=self.user + ) + page_content2 = create_title( + title='pagecontent2_en', + language='en', + page=page_2, + created_by=self.user + ) + page_content3 = create_title( + title='pagecontent3_en', + language='en', + page=page_3, + created_by=self.user + ) + if is_versioning_enabled(): + page_content1.versions.first().publish(self.user) + page_content2.versions.first().publish(self.user) + page_content3.versions.first().publish(self.user) if hasattr(page_1, 'set_as_homepage'): page_1.set_as_homepage() diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index 2e1ce58..1f229ea 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -4,6 +4,8 @@ from decimal import Decimal from unittest import skipIf +from cms.api import create_page, create_title +from cms.test_utils.util.fuzzy_int import FuzzyInt from django.core.cache import cache from django.utils.timezone import now @@ -17,22 +19,29 @@ class SitemapTest(BaseTest): def test_sitemap_base(self): - test_string = 'http://example.com/it/%smonthly0.5' % now().strftime('%Y-%m-%d') - self.get_pages() + page1, page2, page3 = self.get_pages() + sitemap = self.client.get('/sitemap.xml') + test_string = 'http://example.com/%s/%s' \ + 'monthly0.5' \ + % (page1.get_title_obj().language, now().strftime('%Y-%m-%d')) self.assertContains(sitemap, test_string) def test_sitemap_extended(self): - test_string = 'http://example.com/it/%snever0.2' % now().strftime('%Y-%m-%d') page1, page2, page3 = self.get_pages() PageSitemapProperties.objects.create( extended_object=page1, priority='0.2', changefreq='never' ) + + test_string = 'http://example.com/%s/%s' \ + 'never0.2' \ + % (page1.get_title_obj().language, now().strftime('%Y-%m-%d')) sitemap = self.client.get('/sitemap.xml') self.assertContains(sitemap, test_string) def test_sitemap_exclude(self): page1, page2, page3 = self.get_pages() + PageSitemapProperties.objects.create( extended_object=page3, priority='0.2', changefreq='never', include_in_sitemap=False ) @@ -45,14 +54,17 @@ def test_sitemap_exclude(self): def test_sitemap_cache(self): page1, page2, page3 = self.get_pages() + PageSitemapProperties.objects.create( extended_object=page1, priority='0.2', changefreq='never' ) PageSitemapProperties.objects.create( extended_object=page3, priority='0.8', changefreq='hourly' ) + sitemap = ExtendedSitemap() self.assertEqual(len(sitemap.items()), 6) + for item in sitemap.items(): if item.page.pk == page1.pk: self.assertEqual(sitemap.changefreq(item), 'never') @@ -74,14 +86,36 @@ def test_sitemap_cache(self): @skipIf(not is_versioning_enabled(), 'This test can only run when versioning is installed') def test_pageurl_lastmod_with_cms4_versioning(self): # Check the latest version modified date for the page is checked for lastmod() - # if versioning is enabled, Currenly test is skipped , as this may require changes in testsuite - from cms.api import create_page, create_title + # if versioning is enabled, Currenly test is skipped , as this require changes in testsuite page_1 = create_page('page-one', 'page.html', language='en', created_by=self.user) - page_content = create_title(title='page un', language='en', page=page_1, created_by=self.user) + page_content = create_title( + title='page un', + language='en', + page=page_1, + created_by=self.user + ) + if is_versioning_enabled(): + page_content.versions.first().publish(self.user) last_modified_date = '%s' % ( page_content.versions.first().modified.strftime('%Y-%m-%d') ) - expected_string = 'http://example.com%s%smonthly0.5' % (page_1.get_absolute_url(language='en'), last_modified_date) + expected_string = 'http://example.com%s%smonthly' \ + '0.5' \ + % (page_1.get_absolute_url(language='en'), last_modified_date) sitemap = self.client.get('/sitemap.xml') self.assertContains(sitemap, expected_string) + + def test_sitemap_items_query_performance(self): + page1, page2, page3 = self.get_pages() + + PageSitemapProperties.objects.create( + extended_object=page1, priority='0.2', changefreq='never' + ) + PageSitemapProperties.objects.create( + extended_object=page3, priority='0.8', changefreq='hourly' + ) + sitemap = ExtendedSitemap() + max_queries = 4 + with self.assertNumQueries(FuzzyInt(3, max_queries)): + self.assertEqual(len(sitemap.items()), 6) diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index e13c799..73866e4 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -13,6 +13,8 @@ from djangocms_page_sitemap.cms_toolbars import PAGE_SITEMAP_MENU_TITLE from djangocms_page_sitemap.models import PageSitemapProperties +from djangocms_page_sitemap.utils import is_versioning_enabled + from .base import BaseTest @@ -145,9 +147,14 @@ def test_toolbar_buttons_are_not_duplicated(self): This test Can be ran with or without versioning and should return the same result! """ + from cms.api import create_title + user = self.get_superuser() page_1 = create_page('page-one', 'page.html', language='en', created_by=user) - page_content = page_1.get_title_obj(language='en') + page_content = create_title(title='pagecontent1', language='en', page=page_1, + created_by=user) + if is_versioning_enabled(): + page_content.versions.first().publish(user) preview_endpoint = get_object_preview_url(page_content, language='en') with self.login_user_context(self.get_superuser()): From d13e2993c3c570986dbc1d69a20240ae080df9ad Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 20 Nov 2020 01:24:15 +0100 Subject: [PATCH 11/37] Release 0.9.0dev7 --- djangocms_page_sitemap/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 0392526..5b2c154 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -__version__ = '0.9.0dev6' # pragma: no cover +__version__ = '0.9.0dev7' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover From 9846374d93514756cbafaab7cd8f923e4e53631f Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 23 Nov 2020 11:34:03 +0100 Subject: [PATCH 12/37] Release 0.9.0.dev8 --- djangocms_page_sitemap/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 5b2c154..7a4e315 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -__version__ = '0.9.0dev7' # pragma: no cover +__version__ = '0.9.0.dev8' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover From e1efa53bfc908267989e418ad80de27a16660027 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 10:42:41 +0000 Subject: [PATCH 13/37] Initial port of tools changes --- .checkignore | 3 + .codeclimate.yml | 1 - .coveragerc | 2 +- .csslintrc | 2 + .editorconfig | 10 +- .github/ISSUE_TEMPLATE/---bug-report.md | 48 ++ .github/ISSUE_TEMPLATE/---feature-request.md | 42 ++ .github/pull_request_template.md | 18 + .github/workflows/lint.yml | 41 ++ .github/workflows/publish.yml | 38 ++ .github/workflows/test.yml | 61 +++ .gitignore | 523 ++++++++++++++++++- .pre-commit-config.yaml | 62 +++ .pyup.yml | 7 + .readthedocs.yaml | 19 + .travis.yml | 61 --- .tx/config | 1 - CONTRIBUTING.rst | 105 +++- HISTORY.rst | 52 +- LICENSE | 4 +- MANIFEST.in | 3 +- Makefile | 46 -- docs/Makefile | 2 +- docs/authors.rst | 2 +- docs/conf.py | 152 +++--- docs/contributing.rst | 2 +- docs/history.rst | 2 +- docs/index.rst | 2 +- docs/make.bat | 2 +- docs/readme.rst | 2 +- pyproject.toml | 30 ++ requirements-docs.txt | 2 - requirements-test.txt | 10 +- requirements.txt | 2 +- setup.cfg | 84 ++- setup.py | 64 +-- tasks.py | 140 +++++ 37 files changed, 1300 insertions(+), 347 deletions(-) create mode 100644 .checkignore create mode 100644 .csslintrc create mode 100644 .github/ISSUE_TEMPLATE/---bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/---feature-request.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .pyup.yml create mode 100644 .readthedocs.yaml delete mode 100644 .travis.yml delete mode 100644 Makefile create mode 100644 pyproject.toml delete mode 100644 requirements-docs.txt mode change 100755 => 100644 setup.py create mode 100644 tasks.py diff --git a/.checkignore b/.checkignore new file mode 100644 index 0000000..12e56c3 --- /dev/null +++ b/.checkignore @@ -0,0 +1,3 @@ +tests/* +docs/* +djangocms_page_sitemap/migrations/* diff --git a/.codeclimate.yml b/.codeclimate.yml index 1a50e5b..9fa0ebb 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -5,5 +5,4 @@ languages: Python: true exclude_paths: - 'djangocms_page_sitemap/migrations/*' - - 'djangocms_page_sitemap/south_migrations/*' - 'tests/*' diff --git a/.coveragerc b/.coveragerc index 8ee5bf3..0f28a09 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,7 +3,7 @@ branch = True source = djangocms_page_sitemap [report] -omit = ../*migrations*,../*tests* +omit = *migrations*,*tests*,*test_utils* # Regexes for lines to exclude from consideration exclude_lines = # Have to re-enable the standard pragma diff --git a/.csslintrc b/.csslintrc new file mode 100644 index 0000000..aacba95 --- /dev/null +++ b/.csslintrc @@ -0,0 +1,2 @@ +--exclude-exts=.min.css +--ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes diff --git a/.editorconfig b/.editorconfig index 56def90..d979ee9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,27 +8,27 @@ end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -max_line_length = 80 +max_line_length = 120 [*.md] trim_trailing_whitespace = false [*.rst] -max_line_length = 80 +max_line_length = 120 [*.py] -max_line_length = 100 +max_line_length = 120 [*.{scss,html}] indent_size = 2 indent_style = space max_line_length = 120 -[*.js] +[*.{js,vue,json}] indent_size = 2 max_line_length = 120 -[*.yml] +[*.{yml,yaml}] indent_size = 2 [Makefile] diff --git a/.github/ISSUE_TEMPLATE/---bug-report.md b/.github/ISSUE_TEMPLATE/---bug-report.md new file mode 100644 index 0000000..19d08d8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/---bug-report.md @@ -0,0 +1,48 @@ +--- +name: "\U0001F41B Bug report" +about: Create a report to help us improve +title: '' +labels: 'type: bug' +assignees: '' + +--- + + + +## Description + + + +## Steps to reproduce + + + +## Versions + + + +## Expected behaviour + + + +## Actual behaviour + + + +## Additional information + + diff --git a/.github/ISSUE_TEMPLATE/---feature-request.md b/.github/ISSUE_TEMPLATE/---feature-request.md new file mode 100644 index 0000000..5b74e5f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/---feature-request.md @@ -0,0 +1,42 @@ +--- +name: "\U0001F389 Feature request" +about: Share your idea, let's discuss it! +title: '' +labels: 'type: feature' +assignees: '' + +--- + + + +## Description + + + +## Use cases + + + +## Proposed solution + + + +## Alternatives + + + +## Additional information + + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..dcb9856 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,18 @@ +# Description + +Describe: + +* Content of the pull request +* Feature added / Problem fixed + +## References + +Provide any github issue fixed (as in ``Fix #XYZ``) + +# Checklist + +* [ ] I have read the [contribution guide](https://djangocms-page-sitemap.readthedocs.io/en/latest/contributing.html) +* [ ] Code lint checked via `inv lint` +* [ ] ``changes`` file included (see [docs](https://djangocms-page-sitemap.readthedocs.io/en/latest/contributing.html#pull-request-guidelines)) +* [ ] Usage documentation added in case of new features +* [ ] Tests added diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d03bb3c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,41 @@ +name: Code quality + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + strategy: + matrix: + python-version: [3.8] + toxenv: [pep8, isort, black, pypi-description, docs, towncrier] + steps: + - uses: actions/checkout@v2 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Cache pip + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.toxenv }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.toxenv }} + - name: Cache tox + uses: actions/cache@v1 + with: + path: .tox + key: ${{ runner.os }}-lint-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }} + restore-keys: | + ${{ runner.os }}-lint-${{ matrix.toxenv }}- + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools tox>=1.8 + - name: Test with tox + run: | + tox -e${{ matrix.toxenv }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..07b9e64 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: Upload Python Package + +on: + release: + types: [published,prereleased] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Cache pip + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.toxenv }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.toxenv }} + - name: Cache tox + uses: actions/cache@v1 + with: + path: .tox + key: ${{ runner.os }}-tox-release-${{ hashFiles('setup.cfg') }} + restore-keys: | + ${{ runner.os }}-tox-release- + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools tox>=1.8 + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + tox -erelease diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bac4618 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,61 @@ +name: Tox tests + +on: [push, pull_request] + +jobs: + test: + if: "!contains(github.event.head_commit.message, '[skip ci]')" + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.7, 3.6] + django: [31, 30, 22] + cms: [38, 37] + exclude: + - django: 31 + cms: 37 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Cache pip + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.toxenv }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.toxenv }} + - name: Cache tox + uses: actions/cache@v1 + with: + path: .tox + key: ${{ runner.os }}-tox-${{ format('{{py{0}-django{1}-cms{2}}}', matrix.python-version, matrix.django, matrix.cms) }}-${{ hashFiles('setup.cfg') }} + restore-keys: | + ${{ runner.os }}-tox-${{ format('{{py{0}-django{1}-cms{2}}}', matrix.python-version, matrix.django, matrix.cms) }}- + - name: Install dependencies + run: | + sudo apt-get install gettext + python -m pip install --upgrade pip tox>=3.5 + - name: Test with tox + env: + TOX_ENV: ${{ format('py-django{1}-cms{2}', matrix.python-version, matrix.django, matrix.cms) }} + COMMAND: coverage run + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_SERVICE_NAME: github + run: | + tox -e$TOX_ENV + .tox/$TOX_ENV/bin/coverage xml + .tox/$TOX_ENV/bin/coveralls + - uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests + file: ./coverage.xml + fail_ci_if_error: false + services: + redis: + image: redis + ports: + - 6379:6379 diff --git a/.gitignore b/.gitignore index f515e3b..1125109 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,525 @@ + +# Created by https://www.gitignore.io/api/vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode +# Edit at https://www.gitignore.io/?templates=vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode + +### Django ### +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files *.py[cod] +*$py.class # C extensions *.so -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -*.eggs +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ .installed.cfg -lib -lib64 +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec # Installer logs pip-log.txt +pip-delete-this-directory.txt # Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ .coverage -.tox +.coverage.* +.cache nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject # Mr Developer .mr.developer.cfg .project .pydevproject -# Complexity -output/*.html -output/*/index.html +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Node ### +# Logs +logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# rollup.js default build output + +# Uncomment the public line if your project uses Gatsby +# https://nextjs.org/blog/next-9-1#public-directory-support +# https://create-react-app.dev/docs/using-the-public-folder/#docsNav +# public + +# Storybook build outputs +.out +.storybook-out + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# Temporary folders +tmp/ +temp/ + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 +.idea/ + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/**/sonarlint/ + +# SonarQube Plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator/ + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# pyenv + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# celery beat schedule file + +# SageMath parsed files + +# Spyder project settings + +# Rope project settings + +# Mr Developer + +# mkdocs documentation + +# mypy + +# Pyre type checker + +### Sass ### +.sass-cache/ +*.css.map +*.sass.map +*.scss.map + +### SublimeText ### +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist + +# Auto-generated tag files +tags + +# Persistent undo +[._]*.un~ + +# Coc configuration directory +.vim + +### VirtualEnv ### +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +pyvenv.cfg +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +pip-selfcheck.json + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history + +### Vuejs ### +# Recommended template: Node.gitignore + +npm-debug.log +yarn-error.log + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode -# Sphinx -docs/_build *.sqlite +data diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..30dc5aa --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,62 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: "(.idea|node_modules|.tox)" +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-builtin-literals + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-toml + - id: fix-encoding-pragma + args: + - --remove + - repo: https://github.com/timothycrosley/isort + rev: "5.6.4" + hooks: + - id: isort + - repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 + additional_dependencies: + - flake8-broken-line + - flake8-bugbear + - flake8-builtins + - flake8-coding + - flake8-commas + - flake8-comprehensions + - flake8-eradicate + - flake8-quotes + - flake8-tidy-imports + - pep8-naming + - repo: https://github.com/econchick/interrogate + rev: 1.3.1 + hooks: + - id: interrogate + args: + - "-cpyproject.toml" + - "--quiet" + - repo: https://github.com/asottile/pyupgrade + rev: v2.7.3 + hooks: + - id: pyupgrade + args: + - --py3-plus + - repo: local + hooks: + - id: towncrier + name: towncrier + entry: inv towncrier-check + language: system + pass_filenames: false + always_run: true diff --git a/.pyup.yml b/.pyup.yml new file mode 100644 index 0000000..2809577 --- /dev/null +++ b/.pyup.yml @@ -0,0 +1,7 @@ +update: all +pin: False +branch: +schedule: "every day" +search: True +branch_prefix: pyup/ +close_prs: True diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..bbd8063 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,19 @@ +version: 2 + +sphinx: + configuration: docs/conf.py + fail_on_warning: false + +formats: + - epub + - pdf + +python: + version: 3.7 + install: + - requirements: requirements-test.txt + - method: pip + path: . + extra_requirements: + - docs + system_packages: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0d82458..0000000 --- a/.travis.yml +++ /dev/null @@ -1,61 +0,0 @@ -language: python -dist: xenial - -python: - - 3.7 - - 3.6 - - 3.5 - - 2.7 - -env: - matrix: - - TOXENV='pep8' - - TOXENV='isort' - - TOXENV='docs' - - DJANGO='django111' CMS='cms40' FE=1 - - DJANGO='django21' CMS='cms40' FE=1 - - DJANGO='django22' CMS='cms40' FE=1 - - -# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors -install: - - pip install -U setuptools tox>=1.8 coveralls - - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PYVER=py27; fi" - - "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PYVER=py35; fi" - - "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export PYVER=py36; fi" - - "if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then export PYVER=py37; fi" - - "if [[ ${DJANGO}z != 'z' ]]; then export TOXENV=$PYVER-$DJANGO-$CMS; fi" - -# command to run tests, e.g. python setup.py test -script: COMMAND='coverage run' tox -e$TOXENV - -before_install: - - pip install codecov -after_success: - - codecov - - coveralls - -matrix: - exclude: - - python: 2.7 - env: TOXENV='pep8' - - python: 2.7 - env: TOXENV='isort' - - python: 2.7 - env: TOXENV='docs' - - python: 3.5 - env: TOXENV='pep8' - - python: 3.5 - env: TOXENV='isort' - - python: 3.5 - env: TOXENV='docs' - - python: 3.6 - env: TOXENV='pep8' - - python: 3.6 - env: TOXENV='isort' - - python: 3.6 - env: TOXENV='docs' - - python: 2.7 - env: DJANGO='django22' CMS='cms40' FE=1 - - python: 2.7 - env: DJANGO='django21' CMS='cms40' FE=1 diff --git a/.tx/config b/.tx/config index de298f4..8520dcd 100644 --- a/.tx/config +++ b/.tx/config @@ -5,4 +5,3 @@ host = https://www.transifex.com file_filter = djangocms_page_sitemap/locale//LC_MESSAGES/django.po source_file = djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po source_lang = en - diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index c57411e..f2cc28b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -3,7 +3,7 @@ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every -little bit helps, and credit will always be given. +little bit helps, and credit will always be given. You can contribute in many ways: @@ -11,7 +11,7 @@ Types of Contributions ---------------------- Report Bugs -~~~~~~~~~~~ +=========== Report bugs at https://github.com/nephila/djangocms-page-sitemap/issues. @@ -22,26 +22,26 @@ If you are reporting a bug, please include: * Detailed steps to reproduce the bug. Fix Bugs -~~~~~~~~ +======== Look through the GitHub issues for bugs. Anything tagged with "bug" is open to whoever wants to implement it. Implement Features -~~~~~~~~~~~~~~~~~~ +================== Look through the GitHub issues for features. Anything tagged with "feature" is open to whoever wants to implement it. Write Documentation -~~~~~~~~~~~~~~~~~~~ +=================== -djangocms-page-sitemap could always use more documentation, whether as part of the +djangocms-page-sitemap could always use more documentation, whether as part of the official djangocms-page-sitemap docs, in docstrings, or even on the web in blog posts, articles, and such. Submit Feedback -~~~~~~~~~~~~~~~ +=============== The best way to send feedback is to file an issue at https://github.com/nephila/djangocms-page-sitemap/issues. @@ -52,8 +52,9 @@ If you are proposing a feature: * Remember that this is a volunteer-driven project, and that contributions are welcome :) +************ Get Started! ------------- +************ Ready to contribute? Here's how to set up `djangocms-page-sitemap` for local development. @@ -66,7 +67,8 @@ Ready to contribute? Here's how to set up `djangocms-page-sitemap` for local dev $ mkvirtualenv djangocms-page-sitemap $ cd djangocms-page-sitemap/ - $ python setup.py develop + $ pip install -r requirements-test.txt + $ pip install -e . 4. Create a branch for local development:: @@ -77,11 +79,9 @@ Now you can make your changes locally. 5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: - $ flake8 djangocms_page_sitemap tests - $ python setup.py test $ tox -To get flake8 and tox, just pip install them into your virtualenv. +To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub:: @@ -91,22 +91,75 @@ To get flake8 and tox, just pip install them into your virtualenv. 7. Submit a pull request through the GitHub website. -Pull Request Guidelines ------------------------ +Development tips +---------------- -Before you submit a pull request, check that it meets these guidelines: +This project allows you to use `pre-commit `_ to ensure an easy compliance +to the project code styles. -1. The pull request should include tests. -2. If the pull request adds functionality, the docs should be updated. Put - your new functionality into a function with a docstring, and add the - feature to the list in README.rst. -3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check - https://travis-ci.org/nephila/djangocms-page-sitemap/pull_requests - and make sure that the tests pass for all supported Python versions. +If you want to use it, install it globally (for example with ``pip3 install --user precommit``, +but check `installation instruction `_. +When first cloning the project ensure you install the git hooks by running ``pre-commit install``. -Tips ----- +From now on every commit will be checked against our code style. + +Check also the available tox environments with ``tox -l``: the ones not marked with a python version number are tools +to help you work on the project buy checking / formatting code style, running docs etc. + +Testing tips +------------ +You can test your project using any specific combination of python, django and django cms. -To run a subset of tests:: +For example ``tox -epy3.7-django30-cms37`` runs the tests on python 3.7, Django 3.0 and django CMS 3.7. + + +Pull Request Guidelines +======================= + +Before you submit a pull request, check that it meets these guidelines: - $ python -m unittest tests.test_djangocms_page_sitemap \ No newline at end of file +#. Pull request must be named with the following naming scheme: + + ``/(-)-description`` + + See below for available types. + +#. The pull request should include tests. +#. If the pull request adds functionality, the docs should be updated. + Documentation must be added in ``docs`` directory, and must include usage + information for the end user. + In case of public API method, add extended docstrings with full parameters + description and usage example. +#. Add a changes file in ``changes`` directory describing the contribution in + one line. It will be added automatically to the history file upon release. + File must be named as ``.`` with type being: + + * ``.feature``: For new features. + * ``.bugfix``: For bug fixes. + * ``.doc``: For documentation improvement. + * ``.removal``: For deprecation or removal of public API. + * ``.misc``: For general issues. + + Check `towncrier`_ documentation for more details. + +#. The pull request should work for all python / django / django CMS versions + declared in tox.ini. + Check the CI and make sure that the tests pass for all supported versions. + +Release a version +================= + +#. Update authors file +#. Merge ``develop`` on ``master`` branch +#. Bump release via task: ``inv tag-release (major|minor|patch)`` +#. Update changelog via towncrier: ``towncrier --yes`` +#. Commit changelog with ``git commit --amend`` to merge with bumpversion commit +#. Create tag ``git tag `` +#. Push tag to github +#. Publish the release from the tags page +#. If pipeline succeeds, push ``master`` +#. Merge ``master`` back on ``develop`` +#. Bump developement version via task: ``inv tag-dev -l (major|minor|patch)`` +#. Push ``develop`` + +.. _towncrier: https://pypi.org/project/towncrier/#news-fragments diff --git a/HISTORY.rst b/HISTORY.rst index b98f145..4e0f054 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,22 +1,32 @@ .. :changelog: +******* History -------- +******* +.. towncrier release notes start -0.9.0 (unreleased) -++++++++++++++++++ +1.0.0 (2020-12-21) +================== -* Port to django CMS 4.0 -* Fix djangocms-versioning integration +Features +-------- + +- Add support for django-app-enabler (#63) +- Update tooling and drop Python 2 / Django < 2.2 compatibility (#10208) + +0.8.1 (2020-05-02) +================== + +* Enable django CMS 3.7.2 on python 3 0.8.0 (2020-01-12) -++++++++++++++++++ +================== * Relicense under BSD license 0.7.0 (2019-08-22) -++++++++++++++++++ +================== * Add compatibility with Django 2.2 * Drop compatibility with Django < 1.11 @@ -24,36 +34,36 @@ History * Move to django-app-helper 0.6.0 (2019-07-13) -++++++++++++++++++ +================== * Drop compatibility with Django < 1.11 * Drop compatibility with Python 3 < 3.5 0.5.4 (2019-07-13) -++++++++++++++++++ +================== * Fix error when page_robots is executed outside a request * Fix tox for older environments 0.5.3 (2019-03-09) -++++++++++++++++++ +================== * Add Django 2.0, 2.1 support * Add django CMS 3.6 support * Apply workaround to avoid triggering ``Page.site_id`` deprecation warning 0.5.2 (2018-04-07) -++++++++++++++++++ +================== * Make robots_extra not required 0.5.1 (2018-02-27) -++++++++++++++++++ +================== * Fix error in migration dependencies 0.5.0 (2018-02-22) -++++++++++++++++++ +================== * Add Django 1.11 support * Add django CMS 3.5 support @@ -61,45 +71,45 @@ History * Add support for noindex, noarchive robots meta tag 0.4.3 (2019-07-13) -++++++++++++++++++ +================== * Fix error when page_robots is executed outside a request * Fix tox for older environments 0.4.2 (2019-04-08) -++++++++++++++++++ +================== * Add support for noindex, noarchive robots meta tag 0.4.1 (2016-12-02) -++++++++++++++++++ +================== * Add Django 1.10 support 0.4.0 (2016-10-26) -++++++++++++++++++ +================== * Drop compatibility with django CMS 3.1 and below, Django 1.7 and below 0.3.1 (2015-10-18) -++++++++++++++++++ +================== * Improve defaults 0.3.0 (2015-10-18) -++++++++++++++++++ +================== * Add Python 3.5 * Add option to exclude page from sitemap 0.2.0 (2015-08-15) -++++++++++++++++++ +================== * Update to support django CMS 3.1 * Drop support for Django 1.4, 1.5 * Add support for Django 1.8 0.1.0 (2014-08-26) -++++++++++++++++++ +================== * Initial version. diff --git a/LICENSE b/LICENSE index ea1677b..87312ae 100644 --- a/LICENSE +++ b/LICENSE @@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification, * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -* Neither the name of djangocms-page-meta nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +* Neither the name of djangocms-page-sitemap nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in index baadc97..3c9876f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,4 +3,5 @@ include CONTRIBUTING.rst include HISTORY.rst include LICENSE include README.rst -recursive-include djangocms_page_sitemap *.html *.png *.gif *js *.css *jpg *jpeg *svg *py \ No newline at end of file +include requirements.txt +recursive-include djangocms_page_sitemap *.html *.png *.gif *js *jpg *jpeg *svg *py *po *mo *css diff --git a/Makefile b/Makefile deleted file mode 100644 index a60f029..0000000 --- a/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -.PHONY: clean-pyc clean-build docs - -help: - @echo "clean-build - remove build artifacts" - @echo "clean-pyc - remove Python file artifacts" - @echo "lint - check style with flake8" - @echo "test - run tests quickly with the default Python" - @echo "test-all - run tests on every Python version with tox" - @echo "coverage - check code coverage quickly with the default Python" - @echo "release - package and upload a release" - @echo "sdist - package" - -clean: clean-build clean-pyc - -clean-build: - python setup.py clean --all - rm -fr build/ - rm -fr dist/ - rm -fr *.egg-info - -clean-pyc: - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - -lint: - tox -epep8,isort - -test: - python setup.py test - -test-all: - tox - -coverage: - coverage erase - coverage run setup.py test - coverage report -m - -release: clean - python setup.py clean --all sdist bdist_wheel - twine upload dist/* - -sdist: clean - python setup.py sdist - ls -l dist diff --git a/docs/Makefile b/docs/Makefile index 1005e26..0e35bee 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -174,4 +174,4 @@ xml: pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo - @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." \ No newline at end of file + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/authors.rst b/docs/authors.rst index 94292d0..e122f91 100644 --- a/docs/authors.rst +++ b/docs/authors.rst @@ -1 +1 @@ -.. include:: ../AUTHORS.rst \ No newline at end of file +.. include:: ../AUTHORS.rst diff --git a/docs/conf.py b/docs/conf.py index 8907b6c..6ab7aa7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # complexity documentation build configuration file, created by # sphinx-quickstart on Tue Jul 9 22:26:36 2013. @@ -11,45 +10,46 @@ # All configuration values have a default; values that are commented out # serve to show the default. +# fmt: off import os import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) cwd = os.getcwd() parent = os.path.dirname(cwd) sys.path.append(parent) -import djangocms_page_sitemap # isort:skip - +import djangocms_page_sitemap # isort:skip # noqa +# fmt: on # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] +extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'djangocms-page-sitemap' -copyright = u'2014, Iacopo Spalletti' +project = "djangocms-page-sitemap" +copyright = "2014, Iacopo Spalletti" # noqa # A001 # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -62,71 +62,71 @@ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = "default" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -135,88 +135,91 @@ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'djangocms-page-sitemapdoc' +htmlhelp_basename = "djangocms-page-sitemapdoc" # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'djangocms-page-sitemap.tex', u'djangocms-page-sitemap Documentation', - u'Iacopo Spalletti', 'manual'), + ( + "index", + "djangocms-page-sitemap.tex", + "djangocms-page-sitemap Documentation", + "Iacopo Spalletti", + "manual", + ), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- @@ -224,12 +227,17 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'djangocms-page-sitemap', u'djangocms-page-sitemap Documentation', - [u'Iacopo Spalletti'], 1) + ( + "index", + "djangocms-page-sitemap", + "djangocms-page-sitemap Documentation", + ["Iacopo Spalletti"], + 1, + ) ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ @@ -238,19 +246,25 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'djangocms-page-sitemap', u'djangocms-page-sitemap Documentation', - u'Iacopo Spalletti', 'djangocms-page-sitemap', 'One line description of project.', - 'Miscellaneous'), + ( + "index", + "djangocms-page-sitemap", + "djangocms-page-sitemap Documentation", + "Iacopo Spalletti", + "djangocms-page-sitemap", + "One line description of project.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False diff --git a/docs/contributing.rst b/docs/contributing.rst index 3bdd7dc..e582053 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -1 +1 @@ -.. include:: ../CONTRIBUTING.rst \ No newline at end of file +.. include:: ../CONTRIBUTING.rst diff --git a/docs/history.rst b/docs/history.rst index bec23d8..2506499 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -1 +1 @@ -.. include:: ../HISTORY.rst \ No newline at end of file +.. include:: ../HISTORY.rst diff --git a/docs/index.rst b/docs/index.rst index 64f1a54..03c879f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,4 +14,4 @@ Contents: readme contributing authors - history \ No newline at end of file + history diff --git a/docs/make.bat b/docs/make.bat index 2b44764..2df9a8c 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -239,4 +239,4 @@ if "%1" == "pseudoxml" ( goto end ) -:end \ No newline at end of file +:end diff --git a/docs/readme.rst b/docs/readme.rst index 6b2b3ec..72a3355 100644 --- a/docs/readme.rst +++ b/docs/readme.rst @@ -1 +1 @@ -.. include:: ../README.rst \ No newline at end of file +.. include:: ../README.rst diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f1ec81a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,30 @@ +[build-system] +requires = ["setuptools>=40.6.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 119 +target-version = ["py36"] +include = 'djangocms_page_sitemap/*py' + +[tool.towncrier] +package = "djangocms_page_sitemap" +directory = "changes" +filename = "HISTORY.rst" +title_format = "{version} ({project_date})" + +[tool.interrogate] +ignore-init-method = true +ignore-init-module = true +ignore-magic = false +ignore-semiprivate = false +ignore-private = false +ignore-module = true +ignore-nested-functions = true +fail-under = 0 +exclude = ["docs", ".tox"] +ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"] +verbose = 0 +quiet = false +whitelist-regex = [] +color = true diff --git a/requirements-docs.txt b/requirements-docs.txt deleted file mode 100644 index 57ccf60..0000000 --- a/requirements-docs.txt +++ /dev/null @@ -1,2 +0,0 @@ --r requirements-test.txt -Django<3.0 diff --git a/requirements-test.txt b/requirements-test.txt index 9e809d5..4f6ebe2 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,5 +1,5 @@ -coverage<5.0 -coveralls -flake8>=2.1.0 -tox>=2.0 -django-app-helper +-e .[docs] +coverage>5 +coveralls>2 +mock>=1.0.1 +django-app-helper>=2.0.0 diff --git a/requirements.txt b/requirements.txt index ecf975e..d6e1198 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ --e . \ No newline at end of file +-e . diff --git a/setup.cfg b/setup.cfg index 6bd9ba4..84a0f85 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,20 +1,72 @@ -[flake8] -exclude = *.egg-info,*.eggs,.git,.settings,.tox,build,dist,docs,requirements,tmp,*migrations*,*south_migrations*,tests,data -ignore = E305, W504 -max-line-length = 99 +[bumpversion] +current_version = 1.0.0 +parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) +serialize = + {major}.{minor}.{patch}.{release}{relver} + {major}.{minor}.{patch} +commit = True +tag = True +sign_tags = True +tag_name = {new_version} +message = Release {new_version} + +[bumpversion:part:release] +optional_value = gamma +values = + dev + a + b + rc + gamma + +[bumpversion:file:djangocms_page_sitemap/__init__.py] [metadata] -license-file = LICENSE +name = djangocms-page-sitemap +version = attr: djangocms_page_sitemap.__version__ +url = https://github.com/nephila/djangocms-page-sitemap +project_urls = + Documentation = https://djangocms-page-sitemap.readthedocs.io/ +author = Iacopo Spalletti +author_email = i.spalletti@nephila.it +description = django CMS page extension to handle sitemap customization +long_description = file: README.rst, HISTORY.rst +long_description_content_type = text/x-rst +license = BSD +license_file = LICENSE +keywords = django cms, sitemap, django-app-enabler addon +classifiers = + Development Status :: 5 - Production/Stable + Framework :: Django + Intended Audience :: Developers + License :: OSI Approved :: BSD License + Natural Language :: English + Framework :: Django + Framework :: Django :: 2.2 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 -[wheel] -universal = 1 +[options] +include_package_data = True +install_requires = + django-cms>=3.6 +setup_requires = + setuptools +packages = djangocms_page_sitemap +python_requires = >=3.6 +zip_safe = False +test_suite = cms_helper.run + +[options.package_data] +* = *.txt, *.rst +djangcms_page_sitemap = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po -[isort] -line_length = 99 -skip = migrations, south_migrations -combine_as_imports = true -default_section = THIRDPARTY -include_trailing_comma = true -known_first_party = djangocms_page_sitemap -multi_line_output = 5 -not_skip = __init__.py +[options.extras_require] +docs = + django<3.1 + +[upload] +repository = https://upload.pypi.org/legacy/ + +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index c2fbabb..b908cbe --- a/setup.py +++ b/setup.py @@ -1,63 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +import setuptools -import os -import sys - -import djangocms_page_sitemap - -try: - from setuptools import setup -except ImportError: - from distutils.core import setup - -version = djangocms_page_sitemap.__version__ - -if sys.argv[-1] == 'publish': - os.system('python setup.py sdist upload') - print("You probably want to also tag the version now:") - print(" git tag -a %s -m 'version %s'" % (version, version)) - print(" git push --tags") - sys.exit() - -readme = open('README.rst').read() -history = open('HISTORY.rst').read().replace('.. :changelog:', '') - -setup( - name='djangocms-page-sitemap', - version=version, - description="""django CMS page extension to handle sitemap customization""", - long_description=readme + '\n\n' + history, - author='Iacopo Spalletti', - author_email='i.spalletti@nephila.it', - url='https://github.com/nephila/djangocms-page-sitemap', - packages=[ - 'djangocms_page_sitemap', - ], - include_package_data=True, - license='BSD', - zip_safe=False, - keywords='djangocms-page-sitemap', - test_suite='cms_helper.run', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Framework :: Django', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Framework :: Django', - 'Framework :: Django :: 1.11', - 'Framework :: Django :: 2.0', - 'Framework :: Django :: 2.1', - 'Framework :: Django :: 2.2', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - ], - dependency_links=[ - "http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms-4.0.0", - ], -) +setuptools.setup() diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..82261dd --- /dev/null +++ b/tasks.py @@ -0,0 +1,140 @@ +import io +import os +import re +import sys +from glob import glob + +from invoke import task + +DOCS_PORT = os.environ.get("DOCS_PORT", 8000) +#: branch prefixes for which some checks are skipped +SPECIAL_BRANCHES = ("master", "develop", "release") + + +@task +def clean(c): + """ Remove artifacts and binary files. """ + c.run("python setup.py clean --all") + patterns = ["build", "dist"] + patterns.extend(glob("*.egg*")) + patterns.append("docs/_build") + patterns.append("**/*.pyc") + for pattern in patterns: + c.run("rm -rf {}".format(pattern)) + + +@task +def lint(c): + """ Run linting tox environments. """ + c.run("tox -epep8,isort,black,pypi-description") + + +@task # NOQA +def format(c): # NOQA + """ Run code formatting tasks. """ + c.run("tox -eblacken,isort_format") + + +@task +def towncrier_check(c): # NOQA + """ Check towncrier files. """ + output = io.StringIO() + c.run("git branch --contains HEAD", out_stream=output) + skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"] + # cleanup branch names by removing PR-only names in local, remote and disconnected branches to ensure the current + # (i.e. user defined) branch name is used + branches = list( + filter( + lambda x: x and all(not x.startswith(part) for part in skipped_branch_prefix), + ( + branch.replace("origin/", "").replace("remotes/", "").strip("* (") + for branch in output.getvalue().split("\n") + ), + ) + ) + print("Candidate branches", ", ".join(output.getvalue().split("\n"))) + if not branches: + # if no branch name matches, we are in one of the excluded branches above, so we just exit + print("Skip check, branch excluded by configuration") + return + branch = branches[0] + towncrier_file = None + for branch in branches: + if any(branch.startswith(prefix) for prefix in SPECIAL_BRANCHES): + sys.exit(0) + try: + parts = re.search(r"(?P\w+)/\D*(?P\d+)\D*", branch).groups() + towncrier_file = os.path.join("changes", "{1}.{0}".format(*parts)) + if not os.path.exists(towncrier_file) or os.path.getsize(towncrier_file) == 0: + print( + "=========================\n" + "Current tree does not contain the towncrier file {} or file is empty\n" + "please check CONTRIBUTING documentation.\n" + "=========================" + "".format(towncrier_file) + ) + sys.exit(2) + else: + break + except AttributeError: + pass + if not towncrier_file: + print( + "=========================\n" + "Branch {} does not respect the '/(-)-description' format\n" + "=========================\n" + "".format(branch) + ) + sys.exit(1) + + +@task +def test(c): + """ Run test in local environment. """ + c.run("python setup.py test") + + +@task +def test_all(c): + """ Run all tox environments. """ + c.run("tox") + + +@task +def coverage(c): + """ Run test with coverage in local environment. """ + c.run("coverage erase") + c.run("run setup.py test") + c.run("report -m") + + +@task +def tag_release(c, level): + """ Tag release version. """ + c.run("bumpversion --list %s --no-tag" % level) + + +@task +def tag_dev(c, level="patch"): + """ Tag development version. """ + c.run("bumpversion --list %s --message='Bump develop version [ci skip]' --no-tag" % level) + + +@task(pre=[clean]) +def docbuild(c): + """ Build documentation. """ + os.chdir("docs") + build_dir = os.environ.get("BUILD_DIR", "_build/html") + c.run("python -msphinx -W -b html -d _build/doctrees . %s" % build_dir) + + +@task(docbuild) +def docserve(c): + """ Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000). """ + from livereload import Server + + server = Server() + server.watch("docs/conf.py", lambda: docbuild(c)) + server.watch("CONTRIBUTING.rst", lambda: docbuild(c)) + server.watch("docs/*.rst", lambda: docbuild(c)) + server.serve(port=DOCS_PORT, root="_build/html") From bda90b6fb13fbdebbd05ea741e2562f14ca01d6b Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 10:49:04 +0000 Subject: [PATCH 14/37] Updated the history --- HISTORY.rst | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 4e0f054..77bdfcc 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,19 +6,16 @@ History .. towncrier release notes start -1.0.0 (2020-12-21) -================== - -Features --------- +(unreleased) +============ -- Add support for django-app-enabler (#63) -- Update tooling and drop Python 2 / Django < 2.2 compatibility (#10208) +- Update tooling -0.8.1 (2020-05-02) -================== +0.9.0.dev8 (2020-11-23) +======================= -* Enable django CMS 3.7.2 on python 3 +* Port to django CMS 4.0 +* Fix djangocms-versioning integration 0.8.0 (2020-01-12) ================== From 0ff3e573b5c72db4915fa237e7f411b88e8b2d36 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 10:55:30 +0000 Subject: [PATCH 15/37] Update the test suite to cms4 --- tox.ini | 178 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 137 insertions(+), 41 deletions(-) diff --git a/tox.ini b/tox.ini index 62c446f..2432732 100644 --- a/tox.ini +++ b/tox.ini @@ -1,61 +1,157 @@ [tox] envlist = + black + blacken docs - pep8 isort - py{35,36,37}-django{111,21}-cms40 - py{35,36,37}-django22-cms40 - -skip_missing_interpreters=True + isort_format + pep8 + pypi-description + towncrier + py{39,38,37}-django{32}-cms{40} + py{38,37,36}-django{22}-cms{40} [testenv] -commands = {env:COMMAND:python} setup.py test - +commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} deps = - -r{toxinidir}/requirements-test.txt - - # Django 1.11 installation requirements - django111: Django>=1.11,<2.0 - django111: django-formtools>=2.1<2.2 - django111: django-sekizai<2.0.0 - django111: djangocms_admin_style<2.0.0 - django111: django-classy-tags<2.0.0 - - # Django 2.1 installation requirements - django21: Django>=2.1,<2.2 - django21: django-sekizai<2.0.0 - django21: djangocms_admin_style<2.0.0 - django21: django-classy-tags<2.0.0 - - django22: Django>=2.2,<2.3 - + django22: Django>=2.2,<3.0 + django32: Django>=3.2,<3.3 cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip + -r {toxinidir}/requirements-test.txt +passenv = + COMMAND + PYTEST_* - -basepython = - py35: python3.5 - py36: python3.6 - py37: python3.7 +[testenv:pep8] +commands = + {envpython} -m flake8 + {envpython} -minterrogate -c pyproject.toml djangocms_page_sitemap tests +deps = + interrogate + flake8 + flake8-broken-line + flake8-bugbear + flake8-builtins + flake8-coding + flake8-commas + flake8-comprehensions + flake8-eradicate + flake8-quotes + flake8-tidy-imports + pep8-naming +skip_install = true [testenv:isort] -commands = isort --recursive --check-only --diff {toxinidir} -deps = isort +commands = + {envpython} -m isort -c --df djangocms_page_sitemap tests +deps = isort>5,<6 skip_install = true -basepython = python3.5 -[testenv:pep8] -commands = flake8 -deps = flake8 +[testenv:isort_format] +commands = + {envpython} -m isort djangocms_page_sitemap tests +deps = {[testenv:isort]deps} +skip_install = true + +[testenv:black] +commands = + {envpython} -m black --check --diff . +deps = black +skip_install = true + +[testenv:blacken] +commands = + {envpython} -m black . +deps = {[testenv:black]deps} skip_install = true -basepython = python3.5 [testenv:docs] -changedir = docs -commands= - sphinx-build -W -b html -d {envtmpdir}/doctrees . {toxinidir}/docs/_build/html +commands = + {envpython} -m invoke docbuild deps = + invoke sphinx sphinx-rtd-theme - -rrequirements-docs.txt + sphinx-autobuild + livereload~=2.6 + -requirements-test.txt +skip_install = true + +[testenv:towncrier] +commands = + {envpython} -m invoke towncrier-check +deps = + invoke +skip_install = true + +[testenv:pypi-description] +commands = + {envpython} -m invoke clean + {envpython} -m check_manifest + {envpython} -m pep517.build . + {envpython} -m twine check dist/* +deps = + invoke + check-manifest + pep517 + twine +skip_install = true + +[testenv:release] +commands = + {envpython} -m invoke clean + {envpython} -m check_manifest + {envpython} -m pep517.build . + {envpython} -m twine upload {posargs} dist/* +deps = {[testenv:pypi-description]deps} +passenv = + TWINE_* skip_install = true -basepython = python3.5 + +[flake8] +exclude = *.egg-info,.git,.settings,.tox,build,dist,docs,requirements,tmp,*migrations*,tests,data +ignore = E800, W503, C812, C813, C815, C818, C819, C408 +max-line-length = 119 +# flake8-quotes +inline-quotes = double +# flake8-coding +no-accept-encodings = True +# flake8-tidy-imports +banned-modules = __future__ = this project supports python3 only + +[isort] +combine_as_imports = true +default_section = THIRDPARTY +force_grid_wrap = 0 +include_trailing_comma = true +known_first_party = djangocms_page_sitemap +line_length = 119 +multi_line_output = 3 +skip = data, .tox +use_parentheses = True + +[check-manifest] +ignore = + .* + *.ini + *.toml + *.json + *.txt + *.yml + *.yaml + .tx/** + changes/** + docs/** + cms_helper.py + aldryn_config.py + tasks.py + tests/** + *.mo +ignore-bad-ideas = + *.mo + +[pytest] +DJANGO_SETTINGS_MODULE = cms_helper +python_files = test_*.py +traceback = short +addopts = --reuse-db From 5b9a7d10c291a0bc50afe171e2fbe726b73ead1f Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 11:06:54 +0000 Subject: [PATCH 16/37] Bring the github workflows in line with the tox configuration --- .github/workflows/test.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bac4618..7a29250 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,12 +8,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.7, 3.6] - django: [31, 30, 22] - cms: [38, 37] - exclude: - - django: 31 - cms: 37 + python-version: [39, 38, 37] + django: [32, 22] + cms: [40] + steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From 5634acd61372e8ff9b36fa70cf5bfb83fca68016 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 11:10:38 +0000 Subject: [PATCH 17/37] Fix mismatch of python / django versions in tox and GH actions --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 2432732..21c93cc 100644 --- a/tox.ini +++ b/tox.ini @@ -8,8 +8,7 @@ envlist = pep8 pypi-description towncrier - py{39,38,37}-django{32}-cms{40} - py{38,37,36}-django{22}-cms{40} + py{39,38,37}-django{32,22}-cms{40} [testenv] commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} From 15302a1d96ee0cd60b9bdce7926f8e1cc60f7d73 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 15:16:41 +0000 Subject: [PATCH 18/37] Fix various mismatch issues --- .github/workflows/test.yml | 2 +- setup.cfg | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7a29250..1f298c8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [39, 38, 37] + python-version: [3.9, 3.8, 3.7] django: [32, 22] cms: [40] diff --git a/setup.cfg b/setup.cfg index 84a0f85..d01f83f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.0 +current_version = 0.9.0.dev8 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) serialize = {major}.{minor}.{patch}.{release}{relver} @@ -43,17 +43,19 @@ classifiers = Natural Language :: English Framework :: Django Framework :: Django :: 2.2 - Programming Language :: Python :: 3.6 + Framework :: Django :: 3.2 Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 [options] include_package_data = True install_requires = - django-cms>=3.6 + django-cms>=3.7 setup_requires = setuptools packages = djangocms_page_sitemap -python_requires = >=3.6 +python_requires = >=3.7 zip_safe = False test_suite = cms_helper.run From 0258afda9a6c6da21b2768b09f8e960f450ef342 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 15:20:41 +0000 Subject: [PATCH 19/37] Removed all py2 # -*- coding: utf-8 -*- --- djangocms_page_sitemap/__init__.py | 2 +- djangocms_page_sitemap/admin.py | 2 +- djangocms_page_sitemap/cms_toolbars.py | 2 +- djangocms_page_sitemap/migrations/0001_initial.py | 2 +- djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 2 +- djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py | 2 +- djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py | 2 +- djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py | 2 +- djangocms_page_sitemap/models.py | 2 +- djangocms_page_sitemap/settings.py | 2 +- djangocms_page_sitemap/sitemap.py | 2 +- djangocms_page_sitemap/sitemap_urls.py | 2 +- djangocms_page_sitemap/templatetags/__init__.py | 2 +- djangocms_page_sitemap/templatetags/robots_index.py | 2 +- djangocms_page_sitemap/utils.py | 2 +- tests/__init__.py | 2 +- tests/base.py | 2 +- tests/test_models.py | 2 +- tests/test_sitemap.py | 2 +- tests/test_toolbar.py | 2 +- tests/test_utils/__init__.py | 2 +- tests/test_utils/urls.py | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 7a4e315..59eeade 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals __version__ = '0.9.0.dev8' # pragma: no cover diff --git a/djangocms_page_sitemap/admin.py b/djangocms_page_sitemap/admin.py index 05e9937..3ecd26c 100644 --- a/djangocms_page_sitemap/admin.py +++ b/djangocms_page_sitemap/admin.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from cms.extensions import PageExtensionAdmin diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py index 129edb9..50afdfd 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from cms.toolbar_pool import toolbar_pool diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py index 2334e64..bf8ee0b 100644 --- a/djangocms_page_sitemap/migrations/0001_initial.py +++ b/djangocms_page_sitemap/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import unicode_literals import django.core.validators diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py index b0ff842..4f12d95 100644 --- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import unicode_literals from django.db import migrations, models diff --git a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py index 564f1f2..2228cd8 100644 --- a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py +++ b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import unicode_literals import django.core.validators diff --git a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py index 762a83e..7f1ed4b 100644 --- a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py +++ b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # Generated by Django 1.10.8 on 2018-02-02 09:44 from __future__ import unicode_literals diff --git a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py index fda955a..1d70bc7 100644 --- a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py +++ b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # Generated by Django 1.11.10 on 2018-03-24 09:50 from __future__ import unicode_literals diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index f2597fc..0fc648b 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from cms.extensions import PageExtension, extension_pool diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py index 406886f..41b6cfc 100644 --- a/djangocms_page_sitemap/settings.py +++ b/djangocms_page_sitemap/settings.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from cms.sitemaps import CMSSitemap diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py index b21c37d..b10704f 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from collections import defaultdict diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py index cf65490..528ef50 100644 --- a/djangocms_page_sitemap/sitemap_urls.py +++ b/djangocms_page_sitemap/sitemap_urls.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from django.conf.urls import url diff --git a/djangocms_page_sitemap/templatetags/__init__.py b/djangocms_page_sitemap/templatetags/__init__.py index 40a96af..8b13789 100644 --- a/djangocms_page_sitemap/templatetags/__init__.py +++ b/djangocms_page_sitemap/templatetags/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- + diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py index 8a3c47c..56357f0 100644 --- a/djangocms_page_sitemap/templatetags/robots_index.py +++ b/djangocms_page_sitemap/templatetags/robots_index.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from classytags.arguments import Argument diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py index 9380a41..68d96a4 100644 --- a/djangocms_page_sitemap/utils.py +++ b/djangocms_page_sitemap/utils.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from cms.cache import _get_cache_key diff --git a/tests/__init__.py b/tests/__init__.py index 40a96af..8b13789 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- + diff --git a/tests/base.py b/tests/base.py index 5ec4382..a00b496 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from cms.utils.i18n import get_language_list diff --git a/tests/test_models.py b/tests/test_models.py index b753319..1953aa4 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from django import template diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index 1f229ea..bedb11a 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from decimal import Decimal diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index 73866e4..c947930 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from cms.api import create_page diff --git a/tests/test_utils/__init__.py b/tests/test_utils/__init__.py index 40a96af..8b13789 100644 --- a/tests/test_utils/__init__.py +++ b/tests/test_utils/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- + diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py index 97cf06a..8b6b6ef 100644 --- a/tests/test_utils/urls.py +++ b/tests/test_utils/urls.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + from __future__ import absolute_import, print_function, unicode_literals from cms.utils.conf import get_cms_setting From 8bdbe1754a9a397ee321ba5739ca4d4e0ce3d24e Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 15:26:52 +0000 Subject: [PATCH 20/37] Use a dj 3.2 compatible version --- HISTORY.rst | 4 +++- tox.ini | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 77bdfcc..9ff65de 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,7 +9,9 @@ History (unreleased) ============ -- Update tooling +* Update tooling and ci test suite to Github Actions +* Add compatibility with Django 3.2 +* Drop compatibility with Django < 2.2 0.9.0.dev8 (2020-11-23) ======================= diff --git a/tox.ini b/tox.ini index 21c93cc..44a23f1 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,8 @@ commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posar deps = django22: Django>=2.2,<3.0 django32: Django>=3.2,<3.3 - cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip + cms40: https://github.com/Aiky30/django-cms/archive/feature/cms-4-django-32-support.zip + #cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip -r {toxinidir}/requirements-test.txt passenv = COMMAND From d6254030162e109e57a17751a338a3cb4cd07147 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 15:31:13 +0000 Subject: [PATCH 21/37] Removed all __future__ imports --- djangocms_page_sitemap/__init__.py | 3 --- djangocms_page_sitemap/admin.py | 3 --- djangocms_page_sitemap/cms_toolbars.py | 3 --- djangocms_page_sitemap/migrations/0001_initial.py | 3 --- djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 3 --- djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py | 3 --- djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py | 3 --- djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py | 3 --- djangocms_page_sitemap/models.py | 3 --- djangocms_page_sitemap/settings.py | 3 --- djangocms_page_sitemap/sitemap.py | 5 ----- djangocms_page_sitemap/sitemap_urls.py | 3 --- djangocms_page_sitemap/templatetags/robots_index.py | 3 --- djangocms_page_sitemap/utils.py | 3 --- tests/base.py | 4 +--- tests/test_models.py | 3 --- tests/test_sitemap.py | 3 --- tests/test_toolbar.py | 3 --- tests/test_utils/urls.py | 3 --- 19 files changed, 1 insertion(+), 59 deletions(-) diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 59eeade..7aa1eeb 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,2 @@ - -from __future__ import absolute_import, print_function, unicode_literals - __version__ = '0.9.0.dev8' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover diff --git a/djangocms_page_sitemap/admin.py b/djangocms_page_sitemap/admin.py index 3ecd26c..3f468f3 100644 --- a/djangocms_page_sitemap/admin.py +++ b/djangocms_page_sitemap/admin.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from cms.extensions import PageExtensionAdmin from django.contrib import admin diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py index 50afdfd..9705eb4 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from cms.toolbar_pool import toolbar_pool from cms.utils.conf import get_cms_setting from cms.utils.permissions import has_page_permission diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py index bf8ee0b..29ad25a 100644 --- a/djangocms_page_sitemap/migrations/0001_initial.py +++ b/djangocms_page_sitemap/migrations/0001_initial.py @@ -1,6 +1,3 @@ - -from __future__ import unicode_literals - import django.core.validators from django.db import models, migrations diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py index 4f12d95..0e2e8a7 100644 --- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py @@ -1,6 +1,3 @@ - -from __future__ import unicode_literals - from django.db import migrations, models from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST diff --git a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py index 2228cd8..f463f2f 100644 --- a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py +++ b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py @@ -1,6 +1,3 @@ - -from __future__ import unicode_literals - import django.core.validators from django.db import migrations, models diff --git a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py index 7f1ed4b..af89883 100644 --- a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py +++ b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py @@ -1,7 +1,4 @@ - # Generated by Django 1.10.8 on 2018-02-02 09:44 -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py index 1d70bc7..2e0d79f 100644 --- a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py +++ b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py @@ -1,7 +1,4 @@ - # Generated by Django 1.11.10 on 2018-03-24 09:50 -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index 0fc648b..8882288 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from cms.extensions import PageExtension, extension_pool from cms.models import Page from cms.utils.compat.dj import python_2_unicode_compatible diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py index 41b6cfc..ca95dbd 100644 --- a/djangocms_page_sitemap/settings.py +++ b/djangocms_page_sitemap/settings.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from cms.sitemaps import CMSSitemap from cms.utils.conf import get_cms_setting from django.conf import settings diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py index b10704f..8fd33ef 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -1,8 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - -from collections import defaultdict - from cms.models import PageContent, PageUrl from cms.sitemaps import CMSSitemap from cms.utils import get_current_site diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py index 528ef50..b591de1 100644 --- a/djangocms_page_sitemap/sitemap_urls.py +++ b/djangocms_page_sitemap/sitemap_urls.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from django.conf.urls import url from django.contrib.sitemaps.views import sitemap diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py index 56357f0..8aa03a9 100644 --- a/djangocms_page_sitemap/templatetags/robots_index.py +++ b/djangocms_page_sitemap/templatetags/robots_index.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from classytags.arguments import Argument from classytags.core import Options, Tag from cms.templatetags.cms_tags import _get_page_by_untyped_arg diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py index 68d96a4..539253d 100644 --- a/djangocms_page_sitemap/utils.py +++ b/djangocms_page_sitemap/utils.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from cms.cache import _get_cache_key from django.apps import apps diff --git a/tests/base.py b/tests/base.py index a00b496..2213f9c 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,11 +1,9 @@ - -from __future__ import absolute_import, print_function, unicode_literals +from io import StringIO from cms.utils.i18n import get_language_list from django.contrib.auth.models import User from django.http import SimpleCookie from django.test import RequestFactory, TestCase -from django.utils.six import StringIO from djangocms_page_sitemap.utils import is_versioning_enabled diff --git a/tests/test_models.py b/tests/test_models.py index 1953aa4..3f6f7bb 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from django import template from django.contrib.auth.models import AnonymousUser from django.contrib.sites.models import Site diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index bedb11a..b32512d 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from decimal import Decimal from unittest import skipIf diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index c947930..f0e5c9b 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from cms.api import create_page from cms.test_utils.testcases import CMSTestCase from cms.toolbar.items import Menu, ModalItem diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py index 8b6b6ef..a9c2894 100644 --- a/tests/test_utils/urls.py +++ b/tests/test_utils/urls.py @@ -1,6 +1,3 @@ - -from __future__ import absolute_import, print_function, unicode_literals - from cms.utils.conf import get_cms_setting from django.conf import settings from django.conf.urls import include, url From 9b1cd1adf1fbd2dc22f9b39faaa5d75c8708c446 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 15:40:58 +0000 Subject: [PATCH 22/37] Removed @python_2_unicode_compatible --- djangocms_page_sitemap/models.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index 8882288..50611dc 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -1,6 +1,5 @@ from cms.extensions import PageExtension, extension_pool from cms.models import Page -from cms.utils.compat.dj import python_2_unicode_compatible from django.core.cache import cache from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models @@ -13,7 +12,6 @@ @extension_pool.register -@python_2_unicode_compatible class PageSitemapProperties(PageExtension): changefreq = models.CharField( _('Change frequency'), max_length=20, default='monthly', From 4ce98ca34b0dc914b81654116371a63c3739ee7a Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 09:18:42 +0000 Subject: [PATCH 23/37] Update django limitation from 3.3 to 4.0 --- setup.cfg | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index d01f83f..0a5b76e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -65,7 +65,7 @@ djangcms_page_sitemap = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po [options.extras_require] docs = - django<3.1 + django<4.0 [upload] repository = https://upload.pypi.org/legacy/ diff --git a/tox.ini b/tox.ini index 44a23f1..87b31bf 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ envlist = commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} deps = django22: Django>=2.2,<3.0 - django32: Django>=3.2,<3.3 + django32: Django>=3.2,<4.0 cms40: https://github.com/Aiky30/django-cms/archive/feature/cms-4-django-32-support.zip #cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip -r {toxinidir}/requirements-test.txt From dd1bb823839bfc46d357d617c2d650ddd4140f6a Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 09:35:02 +0000 Subject: [PATCH 24/37] Fix isort failures --- djangocms_page_sitemap/migrations/0001_initial.py | 2 +- djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 1 + tests/test_toolbar.py | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py index 29ad25a..6d9f90a 100644 --- a/djangocms_page_sitemap/migrations/0001_initial.py +++ b/djangocms_page_sitemap/migrations/0001_initial.py @@ -1,5 +1,5 @@ import django.core.validators -from django.db import models, migrations +from django.db import migrations, models from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py index 0e2e8a7..dd47306 100644 --- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py @@ -1,4 +1,5 @@ from django.db import migrations, models + from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index f0e5c9b..ee9f953 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -12,7 +12,6 @@ from djangocms_page_sitemap.models import PageSitemapProperties from djangocms_page_sitemap.utils import is_versioning_enabled - from .base import BaseTest From 812a0f0a61ab2bc29ab3f8208a14335834360889 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 09:36:44 +0000 Subject: [PATCH 25/37] Fix installation dependancies --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 87b31bf..b58f0d7 100644 --- a/tox.ini +++ b/tox.ini @@ -74,7 +74,7 @@ deps = sphinx-rtd-theme sphinx-autobuild livereload~=2.6 - -requirements-test.txt + -r requirements-test.txt skip_install = true [testenv:towncrier] From 591df6231d76a11629bca4b6c4a6a2336b3d2d9c Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 09:58:14 +0000 Subject: [PATCH 26/37] fixed lint failures --- aldryn_config.py | 24 +++---- cms_helper.py | 71 ++++++++++--------- djangocms_page_sitemap/__init__.py | 4 +- djangocms_page_sitemap/cms_toolbars.py | 12 ++-- djangocms_page_sitemap/models.py | 20 +++--- djangocms_page_sitemap/settings.py | 20 +++--- djangocms_page_sitemap/sitemap.py | 4 +- djangocms_page_sitemap/sitemap_urls.py | 4 +- .../templatetags/robots_index.py | 18 ++--- djangocms_page_sitemap/utils.py | 4 +- 10 files changed, 91 insertions(+), 90 deletions(-) diff --git a/aldryn_config.py b/aldryn_config.py index 66499b1..e8d0bb0 100644 --- a/aldryn_config.py +++ b/aldryn_config.py @@ -5,28 +5,28 @@ from aldryn_client import forms PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST = { - 'always': 'always', - 'hourly': 'hourly', - 'daily': 'daily', - 'weekly': 'weekly', - 'monthly': 'monthly', - 'yearly': 'yearly', - 'never': 'never', + "always": "always", + "hourly": "hourly", + "daily": "daily", + "weekly": "weekly", + "monthly": "monthly", + "yearly": "yearly", + "never": "never", } class Form(forms.BaseForm): PAGE_SITEMAP_DEFAULT_CHANGEFREQ = forms.SelectField( - 'Default changefrequency (default: django CMS value -monthly-)', + "Default changefrequency (default: django CMS value -monthly-)", choices=PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST.items(), ) PAGE_SITEMAP_CACHE_DURATION = forms.CharField( - 'Cache duration (default: same as django CMS menu cache)', + "Cache duration (default: same as django CMS menu cache)", required=False ) def to_settings(self, data, settings): - settings['PAGE_SITEMAP_DEFAULT_CHANGEFREQ'] = data['PAGE_SITEMAP_DEFAULT_CHANGEFREQ'] - settings['PAGE_SITEMAP_CACHE_DURATION'] = data['PAGE_SITEMAP_CACHE_DURATION'] - settings['ADDON_URLS'].insert(0, 'djangocms_page_sitemap.sitemap_urls') + settings["PAGE_SITEMAP_DEFAULT_CHANGEFREQ"] = data["PAGE_SITEMAP_DEFAULT_CHANGEFREQ"] + settings["PAGE_SITEMAP_CACHE_DURATION"] = data["PAGE_SITEMAP_CACHE_DURATION"] + settings["ADDON_URLS"].insert(0, "djangocms_page_sitemap.sitemap_urls") return settings diff --git a/cms_helper.py b/cms_helper.py index 35d4008..0d61a7f 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -16,54 +16,55 @@ def __getitem__(self, item): def gettext(s): return s + HELPER_SETTINGS = { - 'NOSE_ARGS': [ - '-s', + "NOSE_ARGS": [ + "-s", ], - 'CACHES': { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + "CACHES": { + "default": { + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", } }, - 'CMS_CACHE_DURATIONS': { - 'menus': 10, - 'content': 10, - 'permissions': 10, + "CMS_CACHE_DURATIONS": { + "menus": 10, + "content": 10, + "permissions": 10, }, - 'ROOT_URLCONF': 'tests.test_utils.urls', + "ROOT_URLCONF": "tests.test_utils.urls", # FIXME: Django CMS migrtions with Django 2.2 produce an error when # running tests, temporarily disabling migrations - 'MIGRATION_MODULES': DisableMigrations(), - 'INSTALLED_APPS': [ - 'django.contrib.sitemaps', + "MIGRATION_MODULES": DisableMigrations(), + "INSTALLED_APPS": [ + "django.contrib.sitemaps", ], - 'LANGUAGE_CODE': 'en', - 'TIME_ZONE': 'UTC', - 'LANGUAGES': ( - ('en', gettext('English')), - ('fr', gettext('French')), - ('it', gettext('Italiano')), + "LANGUAGE_CODE": "en", + "TIME_ZONE": "UTC", + "LANGUAGES": ( + ("en", gettext("English")), + ("fr", gettext("French")), + ("it", gettext("Italiano")), ), - 'CMS_LANGUAGES': { + "CMS_LANGUAGES": { 1: [ { - 'code': 'en', - 'name': gettext('English'), - 'public': True, + "code": "en", + "name": gettext("English"), + "public": True, }, { - 'code': 'it', - 'name': gettext('Italiano'), - 'public': True, + "code": "it", + "name": gettext("Italiano"), + "public": True, }, { - 'code': 'fr', - 'name': gettext('French'), - 'public': True, + "code": "fr", + "name": gettext("French"), + "public": True, }, ], - 'default': { - 'hide_untranslated': False, + "default": { + "hide_untranslated": False, }, }, @@ -72,17 +73,17 @@ def gettext(s): def run(): from app_helper import runner - runner.cms('djangocms_page_sitemap') + runner.cms("djangocms_page_sitemap") def setup(): from app_helper import runner - runner.setup('djangocms_page_sitemap', sys.modules[__name__], use_cms=True) + runner.setup("djangocms_page_sitemap", sys.modules[__name__], use_cms=True) -if __name__ == '__main__': +if __name__ == "__main__": run() -if __name__ == 'cms_helper': +if __name__ == "cms_helper": # this is needed to run cms_helper in pycharm setup() diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 7aa1eeb..466ef04 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,2 +1,2 @@ -__version__ = '0.9.0.dev8' # pragma: no cover -__author__ = 'Iacopo Spalletti ' # pragma: no cover +__version__ = "0.9.0.dev8" # pragma: no cover +__author__ = "Iacopo Spalletti " # pragma: no cover diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py index 9705eb4..498e745 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -13,7 +13,7 @@ from cms.cms_toolbars import PageToolbar -PAGE_SITEMAP_MENU_TITLE = _('Sitemap properties') +PAGE_SITEMAP_MENU_TITLE = _("Sitemap properties") @toolbar_pool.register @@ -25,9 +25,9 @@ def populate(self): return # check global permissions if CMS_PERMISSIONS is active - if get_cms_setting('PERMISSION'): + if get_cms_setting("PERMISSION"): has_global_current_page_change_permission = has_page_permission( - self.request.user, self.request.current_page, 'change' + self.request.user, self.request.current_page, "change" ) else: has_global_current_page_change_permission = False @@ -38,7 +38,7 @@ def populate(self): ) if has_global_current_page_change_permission or can_change: not_edit_mode = not self.toolbar.edit_mode_active - current_page_menu = self.toolbar.get_or_create_menu('page') + current_page_menu = self.toolbar.get_or_create_menu("page") # Page tags try: page_extension = PageSitemapProperties.objects.get(extended_object_id=self.page.pk) @@ -46,11 +46,11 @@ def populate(self): page_extension = None try: if page_extension: - url = reverse('admin:djangocms_page_sitemap_pagesitemapproperties_change', + url = reverse("admin:djangocms_page_sitemap_pagesitemapproperties_change", args=(page_extension.pk,)) else: url = "%s?extended_object=%s" % ( - reverse('admin:djangocms_page_sitemap_pagesitemapproperties_add'), + reverse("admin:djangocms_page_sitemap_pagesitemapproperties_add"), self.page.pk) except NoReverseMatch: # pragma: no cover # not in urls diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index 50611dc..83bc1e0 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -14,29 +14,29 @@ @extension_pool.register class PageSitemapProperties(PageExtension): changefreq = models.CharField( - _('Change frequency'), max_length=20, default='monthly', + _("Change frequency"), max_length=20, default="monthly", choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items() ) priority = models.DecimalField( - _('Priority'), decimal_places=1, max_digits=2, default=0.5, + _("Priority"), decimal_places=1, max_digits=2, default=0.5, validators=[MinValueValidator(0), MaxValueValidator(1)] ) - include_in_sitemap = models.BooleanField(_('Include in sitemap'), default=True) + include_in_sitemap = models.BooleanField(_("Include in sitemap"), default=True) noindex = models.BooleanField( - _('Mark as no index'), default=False, - help_text=_('Add meta tag robots with value noindex') + _("Mark as no index"), default=False, + help_text=_("Add meta tag robots with value noindex") ) noarchive = models.BooleanField( - _('Mark as no archive'), default=False, - help_text=_('Add meta tag robots with value noarchive') + _("Mark as no archive"), default=False, + help_text=_("Add meta tag robots with value noarchive") ) robots_extra = models.CharField( - _('Extra robots value'), default='', max_length=200, blank=True, - help_text=_('Extra values for robots meta tag') + _("Extra robots value"), default='', max_length=200, blank=True, + help_text=_("Extra values for robots meta tag") ) def __str__(self): - return _('Sitemap values for Page %s') % self.extended_object.pk + return _("Sitemap values for Page %s") % self.extended_object.pk # Cache cleanup when deleting pages / editing page extensions diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py index ca95dbd..5d3dca0 100644 --- a/djangocms_page_sitemap/settings.py +++ b/djangocms_page_sitemap/settings.py @@ -4,18 +4,18 @@ from django.utils.translation import ugettext_lazy as _ PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST = { - 'always': _('always'), - 'hourly': _('hourly'), - 'daily': _('daily'), - 'weekly': _('weekly'), - 'monthly': _('monthly'), - 'yearly': _('yearly'), - 'never': _('never'), + "always": _("always"), + "hourly": _("hourly"), + "daily": _("daily"), + "weekly": _("weekly"), + "monthly": _("monthly"), + "yearly": _("yearly"), + "never": _("never"), } PAGE_SITEMAP_CHANGEFREQ_LIST = getattr( - settings, 'PAGE_SITEMAP_CHANGEFREQ_LIST', PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST + settings, "PAGE_SITEMAP_CHANGEFREQ_LIST", PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST ) PAGE_SITEMAP_DEFAULT_CHANGEFREQ = getattr( - settings, 'PAGE_SITEMAP_DEFAULT_CHANGEFREQ', CMSSitemap.changefreq + settings, "PAGE_SITEMAP_DEFAULT_CHANGEFREQ", CMSSitemap.changefreq ) -PAGE_SITEMAP_CACHE_DURATION = get_cms_setting('CACHE_DURATIONS')['menus'] +PAGE_SITEMAP_CACHE_DURATION = get_cms_setting("CACHE_DURATIONS")["menus"] diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py index 8fd33ef..796a217 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -20,7 +20,7 @@ def items(self): site = get_current_site() languages = get_public_languages(site_id=site.pk) page_content_prefetch = Prefetch( - 'page__pagecontent_set', + "page__pagecontent_set", queryset=PageContent.objects.filter( language__in=languages, ) @@ -37,7 +37,7 @@ def items(self): page__node__site=site, ) .exclude(page__pagesitemapproperties__include_in_sitemap=False) - .order_by('page__node__path') + .order_by("page__node__path") ) valid_urls = [] for page_url in all_urls: diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py index b591de1..0225a6f 100644 --- a/djangocms_page_sitemap/sitemap_urls.py +++ b/djangocms_page_sitemap/sitemap_urls.py @@ -1,8 +1,8 @@ -from django.conf.urls import url from django.contrib.sitemaps.views import sitemap +from django.urls import re_path from .sitemap import ExtendedSitemap urlpatterns = [ - url(r'^sitemap\.xml$', sitemap, {'sitemaps': {'cmspages': ExtendedSitemap}}), + re_path(r"^sitemap\.xml$", sitemap, {"sitemaps": {"cmspages": ExtendedSitemap}}), ] diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py index 8aa03a9..8115534 100644 --- a/djangocms_page_sitemap/templatetags/robots_index.py +++ b/djangocms_page_sitemap/templatetags/robots_index.py @@ -8,19 +8,19 @@ register = template.Library() -@register.tag(name='page_robots') +@register.tag(name="page_robots") class PageRobots(Tag): """ Generates the robots meta tag according to the extension attributes """ - name = 'page_robots' + name = "page_robots" options = Options( - Argument('page', required=False), - Argument('site_id', required=False), + Argument("page", required=False), + Argument("site_id", required=False), ) def render_tag(self, context, page, site_id): - request = context.get('request') + request = context.get("request") if not request: return '' if not site_id: @@ -37,11 +37,11 @@ def render_tag(self, context, page, site_id): return '' try: if page.pagesitemapproperties.noindex: - content.append('noindex') + content.append("noindex") if page.pagesitemapproperties.noarchive: - content.append('noarchive') + content.append("noarchive") if page.pagesitemapproperties.robots_extra: content.append(page.pagesitemapproperties.robots_extra) - return '' % ','.join(content) + return "" % ','.join(content) except ObjectDoesNotExist: - return '' + return "" diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py index 539253d..ecbc700 100644 --- a/djangocms_page_sitemap/utils.py +++ b/djangocms_page_sitemap/utils.py @@ -10,13 +10,13 @@ def get_cache_key(page): site_id = page.node.site_id except AttributeError: site_id = page.site_id - return _get_cache_key('page_sitemap', page, 'default', site_id) + return _get_cache_key("page_sitemap", page, "default", site_id) def is_versioning_enabled(): from cms.models import PageContent try: - app_config = apps.get_app_config('djangocms_versioning') + app_config = apps.get_app_config("djangocms_versioning") return app_config.cms_extension.is_content_model_versioned(PageContent) except LookupError: return False From a54ae9a06731938c88ea4f9d5b8fba7eca234431 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 10:00:27 +0000 Subject: [PATCH 27/37] Fix missing secret key for the test suite --- cms_helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cms_helper.py b/cms_helper.py index 0d61a7f..7fbacd6 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -18,6 +18,7 @@ def gettext(s): HELPER_SETTINGS = { + "SECRET_KEY": "djangocms-page-sitemap-test-suite-key", "NOSE_ARGS": [ "-s", ], From f0a17c52a60b03fd234626b7b207d16764625cc4 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 10:16:54 +0000 Subject: [PATCH 28/37] Fixed failing tests --- tests/base.py | 21 +++------------------ tests/test_toolbar.py | 6 +++--- tests/test_utils/urls.py | 13 +++++++------ 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/tests/base.py b/tests/base.py index 2213f9c..aaaf6f1 100644 --- a/tests/base.py +++ b/tests/base.py @@ -35,24 +35,9 @@ def get_pages(self): create_title(language='fr', title='page un', page=page_1, created_by=self.user) create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) create_title(language='fr', title='page trois', page=page_3, created_by=self.user) - page_content1 = create_title( - title='pagecontent1_en', - language='en', - page=page_1, - created_by=self.user - ) - page_content2 = create_title( - title='pagecontent2_en', - language='en', - page=page_2, - created_by=self.user - ) - page_content3 = create_title( - title='pagecontent3_en', - language='en', - page=page_3, - created_by=self.user - ) + page_content1 = page_1.get_title_obj("en") + page_content2 = page_2.get_title_obj("en") + page_content3 = page_3.get_title_obj("en") if is_versioning_enabled(): page_content1.versions.first().publish(self.user) page_content2.versions.first().publish(self.user) diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index ee9f953..d1cd7eb 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -6,7 +6,7 @@ from django.test.utils import override_settings from django.urls import reverse from django.utils.encoding import force_text -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from djangocms_page_sitemap.cms_toolbars import PAGE_SITEMAP_MENU_TITLE from djangocms_page_sitemap.models import PageSitemapProperties @@ -147,8 +147,8 @@ def test_toolbar_buttons_are_not_duplicated(self): user = self.get_superuser() page_1 = create_page('page-one', 'page.html', language='en', created_by=user) - page_content = create_title(title='pagecontent1', language='en', page=page_1, - created_by=user) + page_content = page_1.get_title_obj("en") + if is_versioning_enabled(): page_content.versions.first().publish(user) preview_endpoint = get_object_preview_url(page_content, language='en') diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py index a9c2894..2f4a837 100644 --- a/tests/test_utils/urls.py +++ b/tests/test_utils/urls.py @@ -1,26 +1,27 @@ from cms.utils.conf import get_cms_setting from django.conf import settings -from django.conf.urls import include, url from django.conf.urls.i18n import i18n_patterns from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views.static import serve +from django.urls import include, re_path from djangocms_page_sitemap import sitemap_urls + admin.autodiscover() urlpatterns = [ - url(r'^media/(?P.*)$', serve, + re_path(r'^media/(?P.*)$', serve, {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), - url(r'^media/cms/(?P.*)$', serve, + re_path(r'^media/cms/(?P.*)$', serve, {'document_root': get_cms_setting('MEDIA_ROOT'), 'show_indexes': True}), - url(r'^', include(sitemap_urls)), + re_path(r'^', include(sitemap_urls)), ] urlpatterns += staticfiles_urlpatterns() urlpatterns += i18n_patterns( - url(r'^admin/', admin.site.urls), - url(r'^', include('cms.urls')), + re_path(r'^admin/', admin.site.urls), + re_path(r'^', include('cms.urls')), ) From 2d4c09e44b70ce875a091620c398d5c2c77838bb Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 10:18:26 +0000 Subject: [PATCH 29/37] Fix deprecation notices --- djangocms_page_sitemap/models.py | 2 +- tests/base.py | 2 +- tests/test_toolbar.py | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index 83bc1e0..ee15911 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -5,7 +5,7 @@ from django.db import models from django.db.models.signals import post_save, pre_delete from django.dispatch import receiver -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from .settings import PAGE_SITEMAP_CHANGEFREQ_LIST from .utils import get_cache_key diff --git a/tests/base.py b/tests/base.py index aaaf6f1..abf4c2e 100644 --- a/tests/base.py +++ b/tests/base.py @@ -71,7 +71,7 @@ def get_page_request(self, page, user, path=None, edit=False, lang_code='en'): else: request.GET = {'edit_off': None} request.current_page = page - mid = ToolbarMiddleware() + mid = ToolbarMiddleware(request) mid.process_request(request) return request diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index d1cd7eb..764b9dd 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -5,7 +5,7 @@ from django.contrib.auth.models import Permission, User from django.test.utils import override_settings from django.urls import reverse -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from djangocms_page_sitemap.cms_toolbars import PAGE_SITEMAP_MENU_TITLE @@ -70,11 +70,11 @@ def test_perm(self): page_menu = toolbar.menus['page'] try: self.assertEqual( - len(page_menu.find_items(ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 + len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 ) except AssertionError: self.assertEqual( - len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 + len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 ) @override_settings(CMS_PERMISSION=True) @@ -104,11 +104,11 @@ def test_toolbar(self): page_menu = toolbar.menus['page'] try: self.assertEqual( - len(page_menu.find_items(ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 + len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 ) except AssertionError: self.assertEqual( - len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 + len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 ) def test_toolbar_with_items(self): @@ -125,14 +125,14 @@ def test_toolbar_with_items(self): page_menu = toolbar.menus['page'] try: meta_menu = page_menu.find_items( - ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE) + ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE) )[0].item except IndexError: meta_menu = page_menu.find_items( - ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE) + ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE) )[0].item self.assertTrue(meta_menu.url.startswith(reverse('admin:djangocms_page_sitemap_pagesitemapproperties_change', args=(page_ext.pk,)))) - self.assertEqual(force_text(page_ext), force_text(_('Sitemap values for Page %s') % page1.pk)) + self.assertEqual(force_str(page_ext), force_str(_('Sitemap values for Page %s') % page1.pk)) class VersioningToolbarTest(CMSTestCase): From 774ff10c7d0d20cdecc37b247e307c65ae375bcd Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 10:33:48 +0000 Subject: [PATCH 30/37] Replace changelog entry with towncrier configuraton --- HISTORY.rst | 7 ------- tasks.py | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 9ff65de..61e02c1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,13 +6,6 @@ History .. towncrier release notes start -(unreleased) -============ - -* Update tooling and ci test suite to Github Actions -* Add compatibility with Django 3.2 -* Drop compatibility with Django < 2.2 - 0.9.0.dev8 (2020-11-23) ======================= diff --git a/tasks.py b/tasks.py index 82261dd..02be157 100644 --- a/tasks.py +++ b/tasks.py @@ -8,7 +8,7 @@ DOCS_PORT = os.environ.get("DOCS_PORT", 8000) #: branch prefixes for which some checks are skipped -SPECIAL_BRANCHES = ("master", "develop", "release") +SPECIAL_BRANCHES = ("master", "develop", "release", "support/4.0.x") @task From 2dfb2fc223200062d2c8fcd8808b315dcf390a75 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 11:35:45 +0000 Subject: [PATCH 31/37] Fixed versioning tests --- changes/910.feature | 3 +++ cms_helper.py | 1 + tests/base.py | 16 ++++++++++------ tests/test_toolbar.py | 5 ++--- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 changes/910.feature diff --git a/changes/910.feature b/changes/910.feature new file mode 100644 index 0000000..9d140fd --- /dev/null +++ b/changes/910.feature @@ -0,0 +1,3 @@ +* Update tooling and ci test suite to Github Actions +* Add compatibility with Django 3.2 +* Drop compatibility with Django < 2.2 diff --git a/cms_helper.py b/cms_helper.py index 7fbacd6..9a78054 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -38,6 +38,7 @@ def gettext(s): "MIGRATION_MODULES": DisableMigrations(), "INSTALLED_APPS": [ "django.contrib.sitemaps", + 'djangocms_versioning', ], "LANGUAGE_CODE": "en", "TIME_ZONE": "UTC", diff --git a/tests/base.py b/tests/base.py index abf4c2e..4f92837 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,5 +1,6 @@ from io import StringIO +from cms.models import PageContent from cms.utils.i18n import get_language_list from django.contrib.auth.models import User from django.http import SimpleCookie @@ -32,16 +33,19 @@ def get_pages(self): page_1 = create_page('page one', 'page.html', language='en', created_by=self.user) page_2 = create_page('page two', 'page.html', language='en', created_by=self.user) page_3 = create_page('page three', 'page.html', language='en', created_by=self.user) - create_title(language='fr', title='page un', page=page_1, created_by=self.user) - create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) - create_title(language='fr', title='page trois', page=page_3, created_by=self.user) - page_content1 = page_1.get_title_obj("en") - page_content2 = page_2.get_title_obj("en") - page_content3 = page_3.get_title_obj("en") + page_1_content_fr = create_title(language='fr', title='page un', page=page_1, created_by=self.user) + page_1_content_it = create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) + page_3_content_fr = create_title(language='fr', title='page trois', page=page_3, created_by=self.user) + page_content1 = PageContent._original_manager.get(page=page_1, language="en") + page_content2 = PageContent._original_manager.get(page=page_2, language="en") + page_content3 = PageContent._original_manager.get(page=page_3, language="en") if is_versioning_enabled(): page_content1.versions.first().publish(self.user) page_content2.versions.first().publish(self.user) page_content3.versions.first().publish(self.user) + page_1_content_fr.versions.first().publish(self.user) + page_1_content_it.versions.first().publish(self.user) + page_3_content_fr.versions.first().publish(self.user) if hasattr(page_1, 'set_as_homepage'): page_1.set_as_homepage() diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index 764b9dd..4a58273 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -1,4 +1,5 @@ from cms.api import create_page +from cms.models import PageContent from cms.test_utils.testcases import CMSTestCase from cms.toolbar.items import Menu, ModalItem from cms.toolbar.utils import get_object_preview_url @@ -143,11 +144,9 @@ def test_toolbar_buttons_are_not_duplicated(self): This test Can be ran with or without versioning and should return the same result! """ - from cms.api import create_title - user = self.get_superuser() page_1 = create_page('page-one', 'page.html', language='en', created_by=user) - page_content = page_1.get_title_obj("en") + page_content = PageContent._original_manager.get(page=page_1, language="en") if is_versioning_enabled(): page_content.versions.first().publish(user) From acc9942b4f9fd11e29164da5bcad2dd3c543ee58 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 22 Dec 2021 12:05:19 +0000 Subject: [PATCH 32/37] Requirements added --- requirements-test.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements-test.txt b/requirements-test.txt index 4f6ebe2..51fb298 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -3,3 +3,5 @@ coverage>5 coveralls>2 mock>=1.0.1 django-app-helper>=2.0.0 + +https://github.com/Aiky30/djangocms-versioning/tarball/feature/django-32-compat#egg=djangocms-versioning From e8a0b70427841dcce69e42d96c355d04e7b0c19d Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 12 May 2023 22:31:31 +0200 Subject: [PATCH 33/37] Fix merge --- .bumpversion.cfg | 25 + .github/dependabot.yml | 11 + .github/workflows/codeql.yml | 76 + .github/workflows/logger.yml | 11 + .pre-commit-config.yaml | 43 +- .readthedocs.yaml => .readthedocs.yml | 6 +- 70.patch | 4154 +++++++++++++++++ README.rst | 124 +- addon.json | 7 +- aldryn_config.py | 6 +- changes/.directory | 0 cms_helper.py | 26 +- djangocms_page_sitemap/__init__.py | 4 +- djangocms_page_sitemap/addon.json | 12 + djangocms_page_sitemap/cms_toolbars.py | 22 +- .../locale/ar/LC_MESSAGES/django.mo | Bin 1210 -> 1169 bytes .../locale/ar/LC_MESSAGES/django.po | 2 +- .../locale/de/LC_MESSAGES/django.mo | Bin 1051 -> 1010 bytes .../locale/de/LC_MESSAGES/django.po | 2 +- .../locale/en/LC_MESSAGES/django.mo | Bin 378 -> 1458 bytes .../locale/en/LC_MESSAGES/django.po | 4 +- .../locale/es/LC_MESSAGES/django.mo | Bin 493 -> 452 bytes .../locale/es/LC_MESSAGES/django.po | 4 +- .../locale/it/LC_MESSAGES/django.mo | Bin 1070 -> 1029 bytes .../locale/it/LC_MESSAGES/django.po | 6 +- .../locale/lt/LC_MESSAGES/django.mo | Bin 1159 -> 1118 bytes .../locale/lt/LC_MESSAGES/django.po | 2 +- .../locale/pt_BR/LC_MESSAGES/django.mo | Bin 510 -> 469 bytes .../locale/pt_BR/LC_MESSAGES/django.po | 4 +- .../locale/ru/LC_MESSAGES/django.mo | Bin 1342 -> 1301 bytes .../locale/ru/LC_MESSAGES/django.po | 2 +- .../locale/tr/LC_MESSAGES/django.mo | Bin 492 -> 451 bytes .../locale/tr/LC_MESSAGES/django.po | 4 +- .../migrations/0001_initial.py | 54 +- .../migrations/0002_auto_20151018_1451.py | 19 +- .../migrations/0003_auto_20151018_1612.py | 29 +- .../migrations/0004_auto_20180202_1044.py | 35 +- .../migrations/0005_auto_20180324_1050.py | 16 +- djangocms_page_sitemap/models.py | 23 +- djangocms_page_sitemap/settings.py | 10 +- djangocms_page_sitemap/sitemap.py | 26 +- .../templatetags/__init__.py | 1 - .../templatetags/robots_index.py | 7 +- djangocms_page_sitemap/utils.py | 1 + tasks.py | 32 +- tests/__init__.py | 1 - tests/base.py | 45 +- tests/test_models.py | 82 +- tests/test_sitemap.py | 77 +- tests/test_toolbar.py | 95 +- tests/test_utils/__init__.py | 1 - tests/test_utils/urls.py | 28 +- 52 files changed, 4766 insertions(+), 373 deletions(-) create mode 100644 .bumpversion.cfg create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/logger.yml rename .readthedocs.yaml => .readthedocs.yml (82%) create mode 100644 70.patch mode change 100644 => 120000 addon.json create mode 100644 changes/.directory create mode 100644 djangocms_page_sitemap/addon.json diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..9805615 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,25 @@ +[bumpversion] +current_version = 1.2.0 +parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) +serialize = + {major}.{minor}.{patch}.{release}{relver} + {major}.{minor}.{patch} +commit = True +tag = False +sign_tags = True +tag_name = {new_version} +message = Release {new_version} + +[bumpversion:part:release] +optional_value = gamma +values = + dev + a + b + rc + gamma + +[bumpversion:part:relver] +first_value = 1 + +[bumpversion:file:djangocms_page_sitemap/__init__.py] diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6fdae41 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + ignore: + - dependency-name: coverage + versions: + - ">= 5.0.a, < 5.1" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..0310222 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '37 3 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: 'ubuntu-latest' + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/logger.yml b/.github/workflows/logger.yml new file mode 100644 index 0000000..7b47896 --- /dev/null +++ b/.github/workflows/logger.yml @@ -0,0 +1,11 @@ +name: Event Logger +on: push + +jobs: + log-github-event-goodies: + name: "LOG Everything on GitHub Event" + runs-on: ubuntu-latest + steps: + - name: Logging + run: | + echo '${{toJSON(github.event)}}' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30dc5aa..d24df8c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,9 +3,10 @@ exclude: "(.idea|node_modules|.tox)" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.3.0 + rev: v4.4.0 hooks: - id: trailing-whitespace + exclude: ".+cfg" - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files @@ -16,42 +17,29 @@ repos: - id: fix-encoding-pragma args: - --remove - - repo: https://github.com/timothycrosley/isort - rev: "5.6.4" + - repo: https://github.com/PyCQA/isort + rev: "5.12.0" hooks: - id: isort - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 23.3.0 hooks: - id: black - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.262' hooks: - - id: flake8 - additional_dependencies: - - flake8-broken-line - - flake8-bugbear - - flake8-builtins - - flake8-coding - - flake8-commas - - flake8-comprehensions - - flake8-eradicate - - flake8-quotes - - flake8-tidy-imports - - pep8-naming - - repo: https://github.com/econchick/interrogate - rev: 1.3.1 - hooks: - - id: interrogate - args: - - "-cpyproject.toml" - - "--quiet" + - id: ruff - repo: https://github.com/asottile/pyupgrade - rev: v2.7.3 + rev: v3.3.2 hooks: - id: pyupgrade args: - --py3-plus + - repo: https://github.com/adamchainz/django-upgrade + rev: "1.13.0" + hooks: + - id: django-upgrade + args: [--target-version, "3.2"] - repo: local hooks: - id: towncrier @@ -60,3 +48,6 @@ repos: language: system pass_filenames: false always_run: true +ci: + skip: + - towncrier diff --git a/.readthedocs.yaml b/.readthedocs.yml similarity index 82% rename from .readthedocs.yaml rename to .readthedocs.yml index bbd8063..0086f8a 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yml @@ -1,5 +1,10 @@ version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.10" + sphinx: configuration: docs/conf.py fail_on_warning: false @@ -9,7 +14,6 @@ formats: - pdf python: - version: 3.7 install: - requirements: requirements-test.txt - method: pip diff --git a/70.patch b/70.patch new file mode 100644 index 0000000..297d2a9 --- /dev/null +++ b/70.patch @@ -0,0 +1,4154 @@ +From e1efa53bfc908267989e418ad80de27a16660027 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 10:42:41 +0000 +Subject: [PATCH 01/20] Initial port of tools changes + +--- + .checkignore | 3 + + .codeclimate.yml | 1 - + .coveragerc | 2 +- + .csslintrc | 2 + + .editorconfig | 10 +- + .github/ISSUE_TEMPLATE/---bug-report.md | 48 ++ + .github/ISSUE_TEMPLATE/---feature-request.md | 42 ++ + .github/pull_request_template.md | 18 + + .github/workflows/lint.yml | 41 ++ + .github/workflows/publish.yml | 38 ++ + .github/workflows/test.yml | 61 +++ + .gitignore | 523 ++++++++++++++++++- + .pre-commit-config.yaml | 62 +++ + .pyup.yml | 7 + + .readthedocs.yaml | 19 + + .travis.yml | 61 --- + .tx/config | 1 - + CONTRIBUTING.rst | 105 +++- + HISTORY.rst | 52 +- + LICENSE | 4 +- + MANIFEST.in | 3 +- + Makefile | 46 -- + docs/Makefile | 2 +- + docs/authors.rst | 2 +- + docs/conf.py | 152 +++--- + docs/contributing.rst | 2 +- + docs/history.rst | 2 +- + docs/index.rst | 2 +- + docs/make.bat | 2 +- + docs/readme.rst | 2 +- + pyproject.toml | 30 ++ + requirements-docs.txt | 2 - + requirements-test.txt | 10 +- + requirements.txt | 2 +- + setup.cfg | 84 ++- + setup.py | 64 +-- + tasks.py | 140 +++++ + 37 files changed, 1300 insertions(+), 347 deletions(-) + create mode 100644 .checkignore + create mode 100644 .csslintrc + create mode 100644 .github/ISSUE_TEMPLATE/---bug-report.md + create mode 100644 .github/ISSUE_TEMPLATE/---feature-request.md + create mode 100644 .github/pull_request_template.md + create mode 100644 .github/workflows/lint.yml + create mode 100644 .github/workflows/publish.yml + create mode 100644 .github/workflows/test.yml + create mode 100644 .pre-commit-config.yaml + create mode 100644 .pyup.yml + create mode 100644 .readthedocs.yaml + delete mode 100644 .travis.yml + delete mode 100644 Makefile + create mode 100644 pyproject.toml + delete mode 100644 requirements-docs.txt + mode change 100755 => 100644 setup.py + create mode 100644 tasks.py + +diff --git a/.checkignore b/.checkignore +new file mode 100644 +index 0000000..12e56c3 +--- /dev/null ++++ b/.checkignore +@@ -0,0 +1,3 @@ ++tests/* ++docs/* ++djangocms_page_sitemap/migrations/* +diff --git a/.codeclimate.yml b/.codeclimate.yml +index 1a50e5b..9fa0ebb 100644 +--- a/.codeclimate.yml ++++ b/.codeclimate.yml +@@ -5,5 +5,4 @@ languages: + Python: true + exclude_paths: + - 'djangocms_page_sitemap/migrations/*' +- - 'djangocms_page_sitemap/south_migrations/*' + - 'tests/*' +diff --git a/.coveragerc b/.coveragerc +index 8ee5bf3..0f28a09 100644 +--- a/.coveragerc ++++ b/.coveragerc +@@ -3,7 +3,7 @@ branch = True + source = djangocms_page_sitemap + + [report] +-omit = ../*migrations*,../*tests* ++omit = *migrations*,*tests*,*test_utils* + # Regexes for lines to exclude from consideration + exclude_lines = + # Have to re-enable the standard pragma +diff --git a/.csslintrc b/.csslintrc +new file mode 100644 +index 0000000..aacba95 +--- /dev/null ++++ b/.csslintrc +@@ -0,0 +1,2 @@ ++--exclude-exts=.min.css ++--ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes +diff --git a/.editorconfig b/.editorconfig +index 56def90..d979ee9 100644 +--- a/.editorconfig ++++ b/.editorconfig +@@ -8,27 +8,27 @@ end_of_line = lf + charset = utf-8 + trim_trailing_whitespace = true + insert_final_newline = true +-max_line_length = 80 ++max_line_length = 120 + + [*.md] + trim_trailing_whitespace = false + + [*.rst] +-max_line_length = 80 ++max_line_length = 120 + + [*.py] +-max_line_length = 100 ++max_line_length = 120 + + [*.{scss,html}] + indent_size = 2 + indent_style = space + max_line_length = 120 + +-[*.js] ++[*.{js,vue,json}] + indent_size = 2 + max_line_length = 120 + +-[*.yml] ++[*.{yml,yaml}] + indent_size = 2 + + [Makefile] +diff --git a/.github/ISSUE_TEMPLATE/---bug-report.md b/.github/ISSUE_TEMPLATE/---bug-report.md +new file mode 100644 +index 0000000..19d08d8 +--- /dev/null ++++ b/.github/ISSUE_TEMPLATE/---bug-report.md +@@ -0,0 +1,48 @@ ++--- ++name: "\U0001F41B Bug report" ++about: Create a report to help us improve ++title: '' ++labels: 'type: bug' ++assignees: '' ++ ++--- ++ ++ ++ ++## Description ++ ++ ++ ++## Steps to reproduce ++ ++ ++ ++## Versions ++ ++ ++ ++## Expected behaviour ++ ++ ++ ++## Actual behaviour ++ ++ ++ ++## Additional information ++ ++ +diff --git a/.github/ISSUE_TEMPLATE/---feature-request.md b/.github/ISSUE_TEMPLATE/---feature-request.md +new file mode 100644 +index 0000000..5b74e5f +--- /dev/null ++++ b/.github/ISSUE_TEMPLATE/---feature-request.md +@@ -0,0 +1,42 @@ ++--- ++name: "\U0001F389 Feature request" ++about: Share your idea, let's discuss it! ++title: '' ++labels: 'type: feature' ++assignees: '' ++ ++--- ++ ++ ++ ++## Description ++ ++ ++ ++## Use cases ++ ++ ++ ++## Proposed solution ++ ++ ++ ++## Alternatives ++ ++ ++ ++## Additional information ++ ++ +diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md +new file mode 100644 +index 0000000..dcb9856 +--- /dev/null ++++ b/.github/pull_request_template.md +@@ -0,0 +1,18 @@ ++# Description ++ ++Describe: ++ ++* Content of the pull request ++* Feature added / Problem fixed ++ ++## References ++ ++Provide any github issue fixed (as in ``Fix #XYZ``) ++ ++# Checklist ++ ++* [ ] I have read the [contribution guide](https://djangocms-page-sitemap.readthedocs.io/en/latest/contributing.html) ++* [ ] Code lint checked via `inv lint` ++* [ ] ``changes`` file included (see [docs](https://djangocms-page-sitemap.readthedocs.io/en/latest/contributing.html#pull-request-guidelines)) ++* [ ] Usage documentation added in case of new features ++* [ ] Tests added +diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml +new file mode 100644 +index 0000000..d03bb3c +--- /dev/null ++++ b/.github/workflows/lint.yml +@@ -0,0 +1,41 @@ ++name: Code quality ++ ++on: [push, pull_request] ++ ++jobs: ++ lint: ++ runs-on: ubuntu-latest ++ if: "!contains(github.event.head_commit.message, '[skip ci]')" ++ strategy: ++ matrix: ++ python-version: [3.8] ++ toxenv: [pep8, isort, black, pypi-description, docs, towncrier] ++ steps: ++ - uses: actions/checkout@v2 ++ with: ++ repository: ${{ github.event.pull_request.head.repo.full_name }} ++ ref: ${{ github.event.pull_request.head.ref }} ++ - name: Set up Python ${{ matrix.python-version }} ++ uses: actions/setup-python@v2 ++ with: ++ python-version: ${{ matrix.python-version }} ++ - name: Cache pip ++ uses: actions/cache@v1 ++ with: ++ path: ~/.cache/pip ++ key: ${{ runner.os }}-pip-${{ matrix.toxenv }} ++ restore-keys: | ++ ${{ runner.os }}-pip-${{ matrix.toxenv }} ++ - name: Cache tox ++ uses: actions/cache@v1 ++ with: ++ path: .tox ++ key: ${{ runner.os }}-lint-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }} ++ restore-keys: | ++ ${{ runner.os }}-lint-${{ matrix.toxenv }}- ++ - name: Install dependencies ++ run: | ++ python -m pip install --upgrade pip setuptools tox>=1.8 ++ - name: Test with tox ++ run: | ++ tox -e${{ matrix.toxenv }} +diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml +new file mode 100644 +index 0000000..07b9e64 +--- /dev/null ++++ b/.github/workflows/publish.yml +@@ -0,0 +1,38 @@ ++name: Upload Python Package ++ ++on: ++ release: ++ types: [published,prereleased] ++ ++jobs: ++ deploy: ++ runs-on: ubuntu-latest ++ steps: ++ - uses: actions/checkout@v2 ++ - name: Set up Python ++ uses: actions/setup-python@v2 ++ with: ++ python-version: '3.x' ++ - name: Cache pip ++ uses: actions/cache@v1 ++ with: ++ path: ~/.cache/pip ++ key: ${{ runner.os }}-pip-${{ matrix.toxenv }} ++ restore-keys: | ++ ${{ runner.os }}-pip-${{ matrix.toxenv }} ++ - name: Cache tox ++ uses: actions/cache@v1 ++ with: ++ path: .tox ++ key: ${{ runner.os }}-tox-release-${{ hashFiles('setup.cfg') }} ++ restore-keys: | ++ ${{ runner.os }}-tox-release- ++ - name: Install dependencies ++ run: | ++ python -m pip install --upgrade pip setuptools tox>=1.8 ++ - name: Build and publish ++ env: ++ TWINE_USERNAME: __token__ ++ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} ++ run: | ++ tox -erelease +diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml +new file mode 100644 +index 0000000..bac4618 +--- /dev/null ++++ b/.github/workflows/test.yml +@@ -0,0 +1,61 @@ ++name: Tox tests ++ ++on: [push, pull_request] ++ ++jobs: ++ test: ++ if: "!contains(github.event.head_commit.message, '[skip ci]')" ++ runs-on: ubuntu-latest ++ strategy: ++ matrix: ++ python-version: [3.8, 3.7, 3.6] ++ django: [31, 30, 22] ++ cms: [38, 37] ++ exclude: ++ - django: 31 ++ cms: 37 ++ steps: ++ - uses: actions/checkout@v2 ++ - name: Set up Python ${{ matrix.python-version }} ++ uses: actions/setup-python@v2 ++ with: ++ python-version: ${{ matrix.python-version }} ++ - name: Cache pip ++ uses: actions/cache@v1 ++ with: ++ path: ~/.cache/pip ++ key: ${{ runner.os }}-pip-${{ matrix.toxenv }} ++ restore-keys: | ++ ${{ runner.os }}-pip-${{ matrix.toxenv }} ++ - name: Cache tox ++ uses: actions/cache@v1 ++ with: ++ path: .tox ++ key: ${{ runner.os }}-tox-${{ format('{{py{0}-django{1}-cms{2}}}', matrix.python-version, matrix.django, matrix.cms) }}-${{ hashFiles('setup.cfg') }} ++ restore-keys: | ++ ${{ runner.os }}-tox-${{ format('{{py{0}-django{1}-cms{2}}}', matrix.python-version, matrix.django, matrix.cms) }}- ++ - name: Install dependencies ++ run: | ++ sudo apt-get install gettext ++ python -m pip install --upgrade pip tox>=3.5 ++ - name: Test with tox ++ env: ++ TOX_ENV: ${{ format('py-django{1}-cms{2}', matrix.python-version, matrix.django, matrix.cms) }} ++ COMMAND: coverage run ++ COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} ++ COVERALLS_SERVICE_NAME: github ++ run: | ++ tox -e$TOX_ENV ++ .tox/$TOX_ENV/bin/coverage xml ++ .tox/$TOX_ENV/bin/coveralls ++ - uses: codecov/codecov-action@v1 ++ with: ++ token: ${{ secrets.CODECOV_TOKEN }} ++ flags: unittests ++ file: ./coverage.xml ++ fail_ci_if_error: false ++ services: ++ redis: ++ image: redis ++ ports: ++ - 6379:6379 +diff --git a/.gitignore b/.gitignore +index f515e3b..1125109 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -1,42 +1,525 @@ ++ ++# Created by https://www.gitignore.io/api/vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode ++# Edit at https://www.gitignore.io/?templates=vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode ++ ++### Django ### ++*.log ++*.pot ++*.pyc ++__pycache__/ ++local_settings.py ++db.sqlite3 ++db.sqlite3-journal ++media ++ ++# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ ++# in your Git repository. Update and uncomment the following line accordingly. ++# /staticfiles/ ++ ++### Django.Python Stack ### ++# Byte-compiled / optimized / DLL files + *.py[cod] ++*$py.class + + # C extensions + *.so + +-# Packages +-*.egg +-*.egg-info +-dist +-build +-eggs +-parts +-bin +-var +-sdist +-develop-eggs +-*.eggs ++# Distribution / packaging ++.Python ++build/ ++develop-eggs/ ++dist/ ++downloads/ ++eggs/ ++.eggs/ ++lib/ ++lib64/ ++parts/ ++sdist/ ++var/ ++wheels/ ++pip-wheel-metadata/ ++share/python-wheels/ ++*.egg-info/ + .installed.cfg +-lib +-lib64 ++*.egg ++MANIFEST ++ ++# PyInstaller ++# Usually these files are written by a python script from a template ++# before PyInstaller builds the exe, so as to inject date/other infos into it. ++*.manifest ++*.spec + + # Installer logs + pip-log.txt ++pip-delete-this-directory.txt + + # Unit test / coverage reports ++htmlcov/ ++.tox/ ++.nox/ + .coverage +-.tox ++.coverage.* ++.cache + nosetests.xml ++coverage.xml ++*.cover ++.hypothesis/ ++.pytest_cache/ ++ ++# Translations ++*.mo ++ ++# Scrapy stuff: ++.scrapy ++ ++# Sphinx documentation ++docs/_build/ ++ ++# PyBuilder ++target/ ++ ++# pyenv ++.python-version ++ ++# pipenv ++# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. ++# However, in case of collaboration, if having platform-specific dependencies or dependencies ++# having no cross-platform support, pipenv may install dependencies that don't work, or not ++# install all needed dependencies. ++#Pipfile.lock ++ ++# celery beat schedule file ++celerybeat-schedule ++ ++# SageMath parsed files ++*.sage.py ++ ++# Spyder project settings ++.spyderproject ++.spyproject ++ ++# Rope project settings ++.ropeproject + + # Mr Developer + .mr.developer.cfg + .project + .pydevproject + +-# Complexity +-output/*.html +-output/*/index.html ++# mkdocs documentation ++/site ++ ++# mypy ++.mypy_cache/ ++.dmypy.json ++dmypy.json ++ ++# Pyre type checker ++.pyre/ ++ ++### Linux ### ++*~ ++ ++# temporary files which can be created if a process still has a handle open of a deleted file ++.fuse_hidden* ++ ++# KDE directory preferences ++.directory ++ ++# Linux trash folder which might appear on any partition or disk ++.Trash-* ++ ++# .nfs files are created when an open file is removed but is still being accessed ++.nfs* ++ ++### macOS ### ++# General ++.DS_Store ++.AppleDouble ++.LSOverride ++ ++# Icon must end with two \r ++Icon ++ ++# Thumbnails ++._* ++ ++# Files that might appear in the root of a volume ++.DocumentRevisions-V100 ++.fseventsd ++.Spotlight-V100 ++.TemporaryItems ++.Trashes ++.VolumeIcon.icns ++.com.apple.timemachine.donotpresent ++ ++# Directories potentially created on remote AFP share ++.AppleDB ++.AppleDesktop ++Network Trash Folder ++Temporary Items ++.apdisk ++ ++### Node ### ++# Logs ++logs ++npm-debug.log* ++yarn-debug.log* ++yarn-error.log* ++lerna-debug.log* ++ ++# Diagnostic reports (https://nodejs.org/api/report.html) ++report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json ++ ++# Runtime data ++pids ++*.pid ++*.seed ++*.pid.lock ++ ++# Directory for instrumented libs generated by jscoverage/JSCover ++lib-cov ++ ++# Coverage directory used by tools like istanbul ++coverage ++*.lcov ++ ++# nyc test coverage ++.nyc_output ++ ++# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) ++.grunt ++ ++# Bower dependency directory (https://bower.io/) ++bower_components ++ ++# node-waf configuration ++.lock-wscript ++ ++# Compiled binary addons (https://nodejs.org/api/addons.html) ++build/Release ++ ++# Dependency directories ++node_modules/ ++jspm_packages/ ++ ++# TypeScript v1 declaration files ++typings/ ++ ++# TypeScript cache ++*.tsbuildinfo ++ ++# Optional npm cache directory ++.npm ++ ++# Optional eslint cache ++.eslintcache ++ ++# Optional REPL history ++.node_repl_history ++ ++# Output of 'npm pack' ++*.tgz ++ ++# Yarn Integrity file ++.yarn-integrity ++ ++# dotenv environment variables file ++.env ++.env.test ++ ++# parcel-bundler cache (https://parceljs.org/) ++ ++# next.js build output ++.next ++ ++# nuxt.js build output ++.nuxt ++ ++# rollup.js default build output ++ ++# Uncomment the public line if your project uses Gatsby ++# https://nextjs.org/blog/next-9-1#public-directory-support ++# https://create-react-app.dev/docs/using-the-public-folder/#docsNav ++# public ++ ++# Storybook build outputs ++.out ++.storybook-out ++ ++# vuepress build output ++.vuepress/dist ++ ++# Serverless directories ++.serverless/ ++ ++# FuseBox cache ++.fusebox/ ++ ++# DynamoDB Local files ++.dynamodb/ ++ ++# Temporary folders ++tmp/ ++temp/ ++ ++### PyCharm ### ++# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm ++# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 ++.idea/ ++ ++# User-specific stuff ++.idea/**/workspace.xml ++.idea/**/tasks.xml ++.idea/**/usage.statistics.xml ++.idea/**/dictionaries ++.idea/**/shelf ++ ++# Generated files ++.idea/**/contentModel.xml ++ ++# Sensitive or high-churn files ++.idea/**/dataSources/ ++.idea/**/dataSources.ids ++.idea/**/dataSources.local.xml ++.idea/**/sqlDataSources.xml ++.idea/**/dynamic.xml ++.idea/**/uiDesigner.xml ++.idea/**/dbnavigator.xml ++ ++# Gradle ++.idea/**/gradle.xml ++.idea/**/libraries ++ ++# Gradle and Maven with auto-import ++# When using Gradle or Maven with auto-import, you should exclude module files, ++# since they will be recreated, and may cause churn. Uncomment if using ++# auto-import. ++# .idea/modules.xml ++# .idea/*.iml ++# .idea/modules ++# *.iml ++# *.ipr ++ ++# CMake ++cmake-build-*/ ++ ++# Mongo Explorer plugin ++.idea/**/mongoSettings.xml ++ ++# File-based project format ++*.iws ++ ++# IntelliJ ++out/ ++ ++# mpeltonen/sbt-idea plugin ++.idea_modules/ ++ ++# JIRA plugin ++atlassian-ide-plugin.xml ++ ++# Cursive Clojure plugin ++.idea/replstate.xml ++ ++# Crashlytics plugin (for Android Studio and IntelliJ) ++com_crashlytics_export_strings.xml ++crashlytics.properties ++crashlytics-build.properties ++fabric.properties ++ ++# Editor-based Rest Client ++.idea/httpRequests ++ ++# Android studio 3.1+ serialized cache file ++.idea/caches/build_file_checksums.ser ++ ++### PyCharm Patch ### ++# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 ++ ++# *.iml ++# modules.xml ++# .idea/misc.xml ++# *.ipr ++ ++# Sonarlint plugin ++.idea/**/sonarlint/ ++ ++# SonarQube Plugin ++.idea/**/sonarIssues.xml ++ ++# Markdown Navigator plugin ++.idea/**/markdown-navigator.xml ++.idea/**/markdown-navigator/ ++ ++### Python ### ++# Byte-compiled / optimized / DLL files ++ ++# C extensions ++ ++# Distribution / packaging ++ ++# PyInstaller ++# Usually these files are written by a python script from a template ++# before PyInstaller builds the exe, so as to inject date/other infos into it. ++ ++# Installer logs ++ ++# Unit test / coverage reports ++ ++# Translations ++ ++# Scrapy stuff: ++ ++# Sphinx documentation ++ ++# PyBuilder ++ ++# pyenv ++ ++# pipenv ++# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. ++# However, in case of collaboration, if having platform-specific dependencies or dependencies ++# having no cross-platform support, pipenv may install dependencies that don't work, or not ++# install all needed dependencies. ++ ++# celery beat schedule file ++ ++# SageMath parsed files ++ ++# Spyder project settings ++ ++# Rope project settings ++ ++# Mr Developer ++ ++# mkdocs documentation ++ ++# mypy ++ ++# Pyre type checker ++ ++### Sass ### ++.sass-cache/ ++*.css.map ++*.sass.map ++*.scss.map ++ ++### SublimeText ### ++# Cache files for Sublime Text ++*.tmlanguage.cache ++*.tmPreferences.cache ++*.stTheme.cache ++ ++# Workspace files are user-specific ++*.sublime-workspace ++ ++# Project files should be checked into the repository, unless a significant ++# proportion of contributors will probably not be using Sublime Text ++# *.sublime-project ++ ++# SFTP configuration file ++sftp-config.json ++ ++# Package control specific files ++Package Control.last-run ++Package Control.ca-list ++Package Control.ca-bundle ++Package Control.system-ca-bundle ++Package Control.cache/ ++Package Control.ca-certs/ ++Package Control.merged-ca-bundle ++Package Control.user-ca-bundle ++oscrypto-ca-bundle.crt ++bh_unicode_properties.cache ++ ++# Sublime-github package stores a github token in this file ++# https://packagecontrol.io/packages/sublime-github ++GitHub.sublime-settings ++ ++### Vim ### ++# Swap ++[._]*.s[a-v][a-z] ++[._]*.sw[a-p] ++[._]s[a-rt-v][a-z] ++[._]ss[a-gi-z] ++[._]sw[a-p] ++ ++# Session ++Session.vim ++Sessionx.vim ++ ++# Temporary ++.netrwhist ++ ++# Auto-generated tag files ++tags ++ ++# Persistent undo ++[._]*.un~ ++ ++# Coc configuration directory ++.vim ++ ++### VirtualEnv ### ++# Virtualenv ++# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ ++pyvenv.cfg ++.venv ++env/ ++venv/ ++ENV/ ++env.bak/ ++venv.bak/ ++pip-selfcheck.json ++ ++### VisualStudioCode ### ++.vscode/* ++!.vscode/settings.json ++!.vscode/tasks.json ++!.vscode/launch.json ++!.vscode/extensions.json ++ ++### VisualStudioCode Patch ### ++# Ignore all local history of files ++.history ++ ++### Vuejs ### ++# Recommended template: Node.gitignore ++ ++npm-debug.log ++yarn-error.log ++ ++### Windows ### ++# Windows thumbnail cache files ++Thumbs.db ++Thumbs.db:encryptable ++ehthumbs.db ++ehthumbs_vista.db ++ ++# Dump file ++*.stackdump ++ ++# Folder config file ++[Dd]esktop.ini ++ ++# Recycle Bin used on file shares ++$RECYCLE.BIN/ ++ ++# Windows Installer files ++*.cab ++*.msi ++*.msix ++*.msm ++*.msp ++ ++# Windows shortcuts ++*.lnk ++ ++# End of https://www.gitignore.io/api/vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode + +-# Sphinx +-docs/_build + + *.sqlite ++data +diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml +new file mode 100644 +index 0000000..30dc5aa +--- /dev/null ++++ b/.pre-commit-config.yaml +@@ -0,0 +1,62 @@ ++# See https://pre-commit.com for more information ++# See https://pre-commit.com/hooks.html for more hooks ++exclude: "(.idea|node_modules|.tox)" ++repos: ++ - repo: https://github.com/pre-commit/pre-commit-hooks ++ rev: v3.3.0 ++ hooks: ++ - id: trailing-whitespace ++ - id: end-of-file-fixer ++ - id: check-yaml ++ - id: check-added-large-files ++ - id: check-builtin-literals ++ - id: check-executables-have-shebangs ++ - id: check-merge-conflict ++ - id: check-toml ++ - id: fix-encoding-pragma ++ args: ++ - --remove ++ - repo: https://github.com/timothycrosley/isort ++ rev: "5.6.4" ++ hooks: ++ - id: isort ++ - repo: https://github.com/psf/black ++ rev: 20.8b1 ++ hooks: ++ - id: black ++ - repo: https://gitlab.com/pycqa/flake8 ++ rev: 3.8.4 ++ hooks: ++ - id: flake8 ++ additional_dependencies: ++ - flake8-broken-line ++ - flake8-bugbear ++ - flake8-builtins ++ - flake8-coding ++ - flake8-commas ++ - flake8-comprehensions ++ - flake8-eradicate ++ - flake8-quotes ++ - flake8-tidy-imports ++ - pep8-naming ++ - repo: https://github.com/econchick/interrogate ++ rev: 1.3.1 ++ hooks: ++ - id: interrogate ++ args: ++ - "-cpyproject.toml" ++ - "--quiet" ++ - repo: https://github.com/asottile/pyupgrade ++ rev: v2.7.3 ++ hooks: ++ - id: pyupgrade ++ args: ++ - --py3-plus ++ - repo: local ++ hooks: ++ - id: towncrier ++ name: towncrier ++ entry: inv towncrier-check ++ language: system ++ pass_filenames: false ++ always_run: true +diff --git a/.pyup.yml b/.pyup.yml +new file mode 100644 +index 0000000..2809577 +--- /dev/null ++++ b/.pyup.yml +@@ -0,0 +1,7 @@ ++update: all ++pin: False ++branch: ++schedule: "every day" ++search: True ++branch_prefix: pyup/ ++close_prs: True +diff --git a/.readthedocs.yaml b/.readthedocs.yaml +new file mode 100644 +index 0000000..bbd8063 +--- /dev/null ++++ b/.readthedocs.yaml +@@ -0,0 +1,19 @@ ++version: 2 ++ ++sphinx: ++ configuration: docs/conf.py ++ fail_on_warning: false ++ ++formats: ++ - epub ++ - pdf ++ ++python: ++ version: 3.7 ++ install: ++ - requirements: requirements-test.txt ++ - method: pip ++ path: . ++ extra_requirements: ++ - docs ++ system_packages: false +diff --git a/.travis.yml b/.travis.yml +deleted file mode 100644 +index 0d82458..0000000 +--- a/.travis.yml ++++ /dev/null +@@ -1,61 +0,0 @@ +-language: python +-dist: xenial +- +-python: +- - 3.7 +- - 3.6 +- - 3.5 +- - 2.7 +- +-env: +- matrix: +- - TOXENV='pep8' +- - TOXENV='isort' +- - TOXENV='docs' +- - DJANGO='django111' CMS='cms40' FE=1 +- - DJANGO='django21' CMS='cms40' FE=1 +- - DJANGO='django22' CMS='cms40' FE=1 +- +- +-# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors +-install: +- - pip install -U setuptools tox>=1.8 coveralls +- - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PYVER=py27; fi" +- - "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PYVER=py35; fi" +- - "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export PYVER=py36; fi" +- - "if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then export PYVER=py37; fi" +- - "if [[ ${DJANGO}z != 'z' ]]; then export TOXENV=$PYVER-$DJANGO-$CMS; fi" +- +-# command to run tests, e.g. python setup.py test +-script: COMMAND='coverage run' tox -e$TOXENV +- +-before_install: +- - pip install codecov +-after_success: +- - codecov +- - coveralls +- +-matrix: +- exclude: +- - python: 2.7 +- env: TOXENV='pep8' +- - python: 2.7 +- env: TOXENV='isort' +- - python: 2.7 +- env: TOXENV='docs' +- - python: 3.5 +- env: TOXENV='pep8' +- - python: 3.5 +- env: TOXENV='isort' +- - python: 3.5 +- env: TOXENV='docs' +- - python: 3.6 +- env: TOXENV='pep8' +- - python: 3.6 +- env: TOXENV='isort' +- - python: 3.6 +- env: TOXENV='docs' +- - python: 2.7 +- env: DJANGO='django22' CMS='cms40' FE=1 +- - python: 2.7 +- env: DJANGO='django21' CMS='cms40' FE=1 +diff --git a/.tx/config b/.tx/config +index de298f4..8520dcd 100644 +--- a/.tx/config ++++ b/.tx/config +@@ -5,4 +5,3 @@ host = https://www.transifex.com + file_filter = djangocms_page_sitemap/locale//LC_MESSAGES/django.po + source_file = djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po + source_lang = en +- +diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst +index c57411e..f2cc28b 100644 +--- a/CONTRIBUTING.rst ++++ b/CONTRIBUTING.rst +@@ -3,7 +3,7 @@ Contributing + ============ + + Contributions are welcome, and they are greatly appreciated! Every +-little bit helps, and credit will always be given. ++little bit helps, and credit will always be given. + + You can contribute in many ways: + +@@ -11,7 +11,7 @@ Types of Contributions + ---------------------- + + Report Bugs +-~~~~~~~~~~~ ++=========== + + Report bugs at https://github.com/nephila/djangocms-page-sitemap/issues. + +@@ -22,26 +22,26 @@ If you are reporting a bug, please include: + * Detailed steps to reproduce the bug. + + Fix Bugs +-~~~~~~~~ ++======== + + Look through the GitHub issues for bugs. Anything tagged with "bug" + is open to whoever wants to implement it. + + Implement Features +-~~~~~~~~~~~~~~~~~~ ++================== + + Look through the GitHub issues for features. Anything tagged with "feature" + is open to whoever wants to implement it. + + Write Documentation +-~~~~~~~~~~~~~~~~~~~ ++=================== + +-djangocms-page-sitemap could always use more documentation, whether as part of the ++djangocms-page-sitemap could always use more documentation, whether as part of the + official djangocms-page-sitemap docs, in docstrings, or even on the web in blog posts, + articles, and such. + + Submit Feedback +-~~~~~~~~~~~~~~~ ++=============== + + The best way to send feedback is to file an issue at https://github.com/nephila/djangocms-page-sitemap/issues. + +@@ -52,8 +52,9 @@ If you are proposing a feature: + * Remember that this is a volunteer-driven project, and that contributions + are welcome :) + ++************ + Get Started! +------------- ++************ + + Ready to contribute? Here's how to set up `djangocms-page-sitemap` for local development. + +@@ -66,7 +67,8 @@ Ready to contribute? Here's how to set up `djangocms-page-sitemap` for local dev + + $ mkvirtualenv djangocms-page-sitemap + $ cd djangocms-page-sitemap/ +- $ python setup.py develop ++ $ pip install -r requirements-test.txt ++ $ pip install -e . + + 4. Create a branch for local development:: + +@@ -77,11 +79,9 @@ Now you can make your changes locally. + 5. When you're done making changes, check that your changes pass flake8 and the + tests, including testing other Python versions with tox:: + +- $ flake8 djangocms_page_sitemap tests +- $ python setup.py test + $ tox + +-To get flake8 and tox, just pip install them into your virtualenv. ++To get flake8 and tox, just pip install them into your virtualenv. + + 6. Commit your changes and push your branch to GitHub:: + +@@ -91,22 +91,75 @@ To get flake8 and tox, just pip install them into your virtualenv. + + 7. Submit a pull request through the GitHub website. + +-Pull Request Guidelines +------------------------ ++Development tips ++---------------- + +-Before you submit a pull request, check that it meets these guidelines: ++This project allows you to use `pre-commit `_ to ensure an easy compliance ++to the project code styles. + +-1. The pull request should include tests. +-2. If the pull request adds functionality, the docs should be updated. Put +- your new functionality into a function with a docstring, and add the +- feature to the list in README.rst. +-3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check +- https://travis-ci.org/nephila/djangocms-page-sitemap/pull_requests +- and make sure that the tests pass for all supported Python versions. ++If you want to use it, install it globally (for example with ``pip3 install --user precommit``, ++but check `installation instruction `_. ++When first cloning the project ensure you install the git hooks by running ``pre-commit install``. + +-Tips +----- ++From now on every commit will be checked against our code style. ++ ++Check also the available tox environments with ``tox -l``: the ones not marked with a python version number are tools ++to help you work on the project buy checking / formatting code style, running docs etc. ++ ++Testing tips ++------------ ++You can test your project using any specific combination of python, django and django cms. + +-To run a subset of tests:: ++For example ``tox -epy3.7-django30-cms37`` runs the tests on python 3.7, Django 3.0 and django CMS 3.7. ++ ++ ++Pull Request Guidelines ++======================= ++ ++Before you submit a pull request, check that it meets these guidelines: + +- $ python -m unittest tests.test_djangocms_page_sitemap +\ No newline at end of file ++#. Pull request must be named with the following naming scheme: ++ ++ ``/(-)-description`` ++ ++ See below for available types. ++ ++#. The pull request should include tests. ++#. If the pull request adds functionality, the docs should be updated. ++ Documentation must be added in ``docs`` directory, and must include usage ++ information for the end user. ++ In case of public API method, add extended docstrings with full parameters ++ description and usage example. ++#. Add a changes file in ``changes`` directory describing the contribution in ++ one line. It will be added automatically to the history file upon release. ++ File must be named as ``.`` with type being: ++ ++ * ``.feature``: For new features. ++ * ``.bugfix``: For bug fixes. ++ * ``.doc``: For documentation improvement. ++ * ``.removal``: For deprecation or removal of public API. ++ * ``.misc``: For general issues. ++ ++ Check `towncrier`_ documentation for more details. ++ ++#. The pull request should work for all python / django / django CMS versions ++ declared in tox.ini. ++ Check the CI and make sure that the tests pass for all supported versions. ++ ++Release a version ++================= ++ ++#. Update authors file ++#. Merge ``develop`` on ``master`` branch ++#. Bump release via task: ``inv tag-release (major|minor|patch)`` ++#. Update changelog via towncrier: ``towncrier --yes`` ++#. Commit changelog with ``git commit --amend`` to merge with bumpversion commit ++#. Create tag ``git tag `` ++#. Push tag to github ++#. Publish the release from the tags page ++#. If pipeline succeeds, push ``master`` ++#. Merge ``master`` back on ``develop`` ++#. Bump developement version via task: ``inv tag-dev -l (major|minor|patch)`` ++#. Push ``develop`` ++ ++.. _towncrier: https://pypi.org/project/towncrier/#news-fragments +diff --git a/HISTORY.rst b/HISTORY.rst +index b98f145..4e0f054 100644 +--- a/HISTORY.rst ++++ b/HISTORY.rst +@@ -1,22 +1,32 @@ + .. :changelog: + ++******* + History +-------- ++******* + ++.. towncrier release notes start + +-0.9.0 (unreleased) +-++++++++++++++++++ ++1.0.0 (2020-12-21) ++================== + +-* Port to django CMS 4.0 +-* Fix djangocms-versioning integration ++Features ++-------- ++ ++- Add support for django-app-enabler (#63) ++- Update tooling and drop Python 2 / Django < 2.2 compatibility (#10208) ++ ++0.8.1 (2020-05-02) ++================== ++ ++* Enable django CMS 3.7.2 on python 3 + + 0.8.0 (2020-01-12) +-++++++++++++++++++ ++================== + + * Relicense under BSD license + + 0.7.0 (2019-08-22) +-++++++++++++++++++ ++================== + + * Add compatibility with Django 2.2 + * Drop compatibility with Django < 1.11 +@@ -24,36 +34,36 @@ History + * Move to django-app-helper + + 0.6.0 (2019-07-13) +-++++++++++++++++++ ++================== + + * Drop compatibility with Django < 1.11 + * Drop compatibility with Python 3 < 3.5 + + 0.5.4 (2019-07-13) +-++++++++++++++++++ ++================== + + * Fix error when page_robots is executed outside a request + * Fix tox for older environments + + 0.5.3 (2019-03-09) +-++++++++++++++++++ ++================== + + * Add Django 2.0, 2.1 support + * Add django CMS 3.6 support + * Apply workaround to avoid triggering ``Page.site_id`` deprecation warning + + 0.5.2 (2018-04-07) +-++++++++++++++++++ ++================== + + * Make robots_extra not required + + 0.5.1 (2018-02-27) +-++++++++++++++++++ ++================== + + * Fix error in migration dependencies + + 0.5.0 (2018-02-22) +-++++++++++++++++++ ++================== + + * Add Django 1.11 support + * Add django CMS 3.5 support +@@ -61,45 +71,45 @@ History + * Add support for noindex, noarchive robots meta tag + + 0.4.3 (2019-07-13) +-++++++++++++++++++ ++================== + + * Fix error when page_robots is executed outside a request + * Fix tox for older environments + + 0.4.2 (2019-04-08) +-++++++++++++++++++ ++================== + + * Add support for noindex, noarchive robots meta tag + + 0.4.1 (2016-12-02) +-++++++++++++++++++ ++================== + + * Add Django 1.10 support + + 0.4.0 (2016-10-26) +-++++++++++++++++++ ++================== + + * Drop compatibility with django CMS 3.1 and below, Django 1.7 and below + + 0.3.1 (2015-10-18) +-++++++++++++++++++ ++================== + + * Improve defaults + + 0.3.0 (2015-10-18) +-++++++++++++++++++ ++================== + + * Add Python 3.5 + * Add option to exclude page from sitemap + + 0.2.0 (2015-08-15) +-++++++++++++++++++ ++================== + + * Update to support django CMS 3.1 + * Drop support for Django 1.4, 1.5 + * Add support for Django 1.8 + + 0.1.0 (2014-08-26) +-++++++++++++++++++ ++================== + + * Initial version. +diff --git a/LICENSE b/LICENSE +index ea1677b..87312ae 100644 +--- a/LICENSE ++++ b/LICENSE +@@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification, + + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +-* Neither the name of djangocms-page-meta nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. ++* Neither the name of djangocms-page-sitemap nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +\ No newline at end of file ++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +diff --git a/MANIFEST.in b/MANIFEST.in +index baadc97..3c9876f 100644 +--- a/MANIFEST.in ++++ b/MANIFEST.in +@@ -3,4 +3,5 @@ include CONTRIBUTING.rst + include HISTORY.rst + include LICENSE + include README.rst +-recursive-include djangocms_page_sitemap *.html *.png *.gif *js *.css *jpg *jpeg *svg *py +\ No newline at end of file ++include requirements.txt ++recursive-include djangocms_page_sitemap *.html *.png *.gif *js *jpg *jpeg *svg *py *po *mo *css +diff --git a/Makefile b/Makefile +deleted file mode 100644 +index a60f029..0000000 +--- a/Makefile ++++ /dev/null +@@ -1,46 +0,0 @@ +-.PHONY: clean-pyc clean-build docs +- +-help: +- @echo "clean-build - remove build artifacts" +- @echo "clean-pyc - remove Python file artifacts" +- @echo "lint - check style with flake8" +- @echo "test - run tests quickly with the default Python" +- @echo "test-all - run tests on every Python version with tox" +- @echo "coverage - check code coverage quickly with the default Python" +- @echo "release - package and upload a release" +- @echo "sdist - package" +- +-clean: clean-build clean-pyc +- +-clean-build: +- python setup.py clean --all +- rm -fr build/ +- rm -fr dist/ +- rm -fr *.egg-info +- +-clean-pyc: +- find . -name '*.pyc' -exec rm -f {} + +- find . -name '*.pyo' -exec rm -f {} + +- find . -name '*~' -exec rm -f {} + +- +-lint: +- tox -epep8,isort +- +-test: +- python setup.py test +- +-test-all: +- tox +- +-coverage: +- coverage erase +- coverage run setup.py test +- coverage report -m +- +-release: clean +- python setup.py clean --all sdist bdist_wheel +- twine upload dist/* +- +-sdist: clean +- python setup.py sdist +- ls -l dist +diff --git a/docs/Makefile b/docs/Makefile +index 1005e26..0e35bee 100644 +--- a/docs/Makefile ++++ b/docs/Makefile +@@ -174,4 +174,4 @@ xml: + pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo +- @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." +\ No newline at end of file ++ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." +diff --git a/docs/authors.rst b/docs/authors.rst +index 94292d0..e122f91 100644 +--- a/docs/authors.rst ++++ b/docs/authors.rst +@@ -1 +1 @@ +-.. include:: ../AUTHORS.rst +\ No newline at end of file ++.. include:: ../AUTHORS.rst +diff --git a/docs/conf.py b/docs/conf.py +index 8907b6c..6ab7aa7 100644 +--- a/docs/conf.py ++++ b/docs/conf.py +@@ -1,4 +1,3 @@ +-# -*- coding: utf-8 -*- + # + # complexity documentation build configuration file, created by + # sphinx-quickstart on Tue Jul 9 22:26:36 2013. +@@ -11,45 +10,46 @@ + # All configuration values have a default; values that are commented out + # serve to show the default. + ++# fmt: off + import os + import sys + + # If extensions (or modules to document with autodoc) are in another directory, + # add these directories to sys.path here. If the directory is relative to the + # documentation root, use os.path.abspath to make it absolute, like shown here. +-#sys.path.insert(0, os.path.abspath('.')) ++# sys.path.insert(0, os.path.abspath('.')) + + cwd = os.getcwd() + parent = os.path.dirname(cwd) + sys.path.append(parent) + +-import djangocms_page_sitemap # isort:skip +- ++import djangocms_page_sitemap # isort:skip # noqa ++# fmt: on + + # -- General configuration ----------------------------------------------------- + + # If your documentation needs a minimal Sphinx version, state it here. +-#needs_sphinx = '1.0' ++# needs_sphinx = '1.0' + + # Add any Sphinx extension module names here, as strings. They can be extensions + # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] ++extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"] + + # Add any paths that contain templates here, relative to this directory. +-templates_path = ['_templates'] ++templates_path = ["_templates"] + + # The suffix of source filenames. +-source_suffix = '.rst' ++source_suffix = ".rst" + + # The encoding of source files. +-#source_encoding = 'utf-8-sig' ++# source_encoding = 'utf-8-sig' + + # The master toctree document. +-master_doc = 'index' ++master_doc = "index" + + # General information about the project. +-project = u'djangocms-page-sitemap' +-copyright = u'2014, Iacopo Spalletti' ++project = "djangocms-page-sitemap" ++copyright = "2014, Iacopo Spalletti" # noqa # A001 + + # The version info for the project you're documenting, acts as replacement for + # |version| and |release|, also used in various other places throughout the +@@ -62,71 +62,71 @@ + + # The language for content autogenerated by Sphinx. Refer to documentation + # for a list of supported languages. +-#language = None ++# language = None + + # There are two options for replacing |today|: either, you set today to some + # non-false value, then it is used: +-#today = '' ++# today = '' + # Else, today_fmt is used as the format for a strftime call. +-#today_fmt = '%B %d, %Y' ++# today_fmt = '%B %d, %Y' + + # List of patterns, relative to source directory, that match files and + # directories to ignore when looking for source files. +-exclude_patterns = ['_build'] ++exclude_patterns = ["_build"] + + # The reST default role (used for this markup: `text`) to use for all documents. +-#default_role = None ++# default_role = None + + # If true, '()' will be appended to :func: etc. cross-reference text. +-#add_function_parentheses = True ++# add_function_parentheses = True + + # If true, the current module name will be prepended to all description + # unit titles (such as .. function::). +-#add_module_names = True ++# add_module_names = True + + # If true, sectionauthor and moduleauthor directives will be shown in the + # output. They are ignored by default. +-#show_authors = False ++# show_authors = False + + # The name of the Pygments (syntax highlighting) style to use. +-pygments_style = 'sphinx' ++pygments_style = "sphinx" + + # A list of ignored prefixes for module index sorting. +-#modindex_common_prefix = [] ++# modindex_common_prefix = [] + + # If true, keep warnings as "system message" paragraphs in the built documents. +-#keep_warnings = False ++# keep_warnings = False + + + # -- Options for HTML output --------------------------------------------------- + + # The theme to use for HTML and HTML Help pages. See the documentation for + # a list of builtin themes. +-html_theme = 'default' ++html_theme = "default" + + # Theme options are theme-specific and customize the look and feel of a theme + # further. For a list of options available for each theme, see the + # documentation. +-#html_theme_options = {} ++# html_theme_options = {} + + # Add any paths that contain custom themes here, relative to this directory. +-#html_theme_path = [] ++# html_theme_path = [] + + # The name for this set of Sphinx documents. If None, it defaults to + # " v documentation". +-#html_title = None ++# html_title = None + + # A shorter title for the navigation bar. Default is the same as html_title. +-#html_short_title = None ++# html_short_title = None + + # The name of an image file (relative to this directory) to place at the top + # of the sidebar. +-#html_logo = None ++# html_logo = None + + # The name of an image file (within the static path) to use as favicon of the + # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 + # pixels large. +-#html_favicon = None ++# html_favicon = None + + # Add any paths that contain custom static files (such as style sheets) here, + # relative to this directory. They are copied after the builtin static files, +@@ -135,88 +135,91 @@ + + # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, + # using the given strftime format. +-#html_last_updated_fmt = '%b %d, %Y' ++# html_last_updated_fmt = '%b %d, %Y' + + # If true, SmartyPants will be used to convert quotes and dashes to + # typographically correct entities. +-#html_use_smartypants = True ++# html_use_smartypants = True + + # Custom sidebar templates, maps document names to template names. +-#html_sidebars = {} ++# html_sidebars = {} + + # Additional templates that should be rendered to pages, maps page names to + # template names. +-#html_additional_pages = {} ++# html_additional_pages = {} + + # If false, no module index is generated. +-#html_domain_indices = True ++# html_domain_indices = True + + # If false, no index is generated. +-#html_use_index = True ++# html_use_index = True + + # If true, the index is split into individual pages for each letter. +-#html_split_index = False ++# html_split_index = False + + # If true, links to the reST sources are added to the pages. +-#html_show_sourcelink = True ++# html_show_sourcelink = True + + # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +-#html_show_sphinx = True ++# html_show_sphinx = True + + # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +-#html_show_copyright = True ++# html_show_copyright = True + + # If true, an OpenSearch description file will be output, and all pages will + # contain a tag referring to it. The value of this option must be the + # base URL from which the finished HTML is served. +-#html_use_opensearch = '' ++# html_use_opensearch = '' + + # This is the file name suffix for HTML files (e.g. ".xhtml"). +-#html_file_suffix = None ++# html_file_suffix = None + + # Output file base name for HTML help builder. +-htmlhelp_basename = 'djangocms-page-sitemapdoc' ++htmlhelp_basename = "djangocms-page-sitemapdoc" + + + # -- Options for LaTeX output -------------------------------------------------- + + latex_elements = { +-# The paper size ('letterpaper' or 'a4paper'). +-#'papersize': 'letterpaper', +- +-# The font size ('10pt', '11pt' or '12pt'). +-#'pointsize': '10pt', +- +-# Additional stuff for the LaTeX preamble. +-#'preamble': '', ++ # The paper size ('letterpaper' or 'a4paper'). ++ # 'papersize': 'letterpaper', ++ # The font size ('10pt', '11pt' or '12pt'). ++ # 'pointsize': '10pt', ++ # Additional stuff for the LaTeX preamble. ++ # 'preamble': '', + } + + # Grouping the document tree into LaTeX files. List of tuples + # (source start file, target name, title, author, documentclass [howto/manual]). + latex_documents = [ +- ('index', 'djangocms-page-sitemap.tex', u'djangocms-page-sitemap Documentation', +- u'Iacopo Spalletti', 'manual'), ++ ( ++ "index", ++ "djangocms-page-sitemap.tex", ++ "djangocms-page-sitemap Documentation", ++ "Iacopo Spalletti", ++ "manual", ++ ), + ] + + # The name of an image file (relative to this directory) to place at the top of + # the title page. +-#latex_logo = None ++# latex_logo = None + + # For "manual" documents, if this is true, then toplevel headings are parts, + # not chapters. +-#latex_use_parts = False ++# latex_use_parts = False + + # If true, show page references after internal links. +-#latex_show_pagerefs = False ++# latex_show_pagerefs = False + + # If true, show URL addresses after external links. +-#latex_show_urls = False ++# latex_show_urls = False + + # Documents to append as an appendix to all manuals. +-#latex_appendices = [] ++# latex_appendices = [] + + # If false, no module index is generated. +-#latex_domain_indices = True ++# latex_domain_indices = True + + + # -- Options for manual page output -------------------------------------------- +@@ -224,12 +227,17 @@ + # One entry per manual page. List of tuples + # (source start file, name, description, authors, manual section). + man_pages = [ +- ('index', 'djangocms-page-sitemap', u'djangocms-page-sitemap Documentation', +- [u'Iacopo Spalletti'], 1) ++ ( ++ "index", ++ "djangocms-page-sitemap", ++ "djangocms-page-sitemap Documentation", ++ ["Iacopo Spalletti"], ++ 1, ++ ) + ] + + # If true, show URL addresses after external links. +-#man_show_urls = False ++# man_show_urls = False + + + # -- Options for Texinfo output ------------------------------------------------ +@@ -238,19 +246,25 @@ + # (source start file, target name, title, author, + # dir menu entry, description, category) + texinfo_documents = [ +- ('index', 'djangocms-page-sitemap', u'djangocms-page-sitemap Documentation', +- u'Iacopo Spalletti', 'djangocms-page-sitemap', 'One line description of project.', +- 'Miscellaneous'), ++ ( ++ "index", ++ "djangocms-page-sitemap", ++ "djangocms-page-sitemap Documentation", ++ "Iacopo Spalletti", ++ "djangocms-page-sitemap", ++ "One line description of project.", ++ "Miscellaneous", ++ ), + ] + + # Documents to append as an appendix to all manuals. +-#texinfo_appendices = [] ++# texinfo_appendices = [] + + # If false, no module index is generated. +-#texinfo_domain_indices = True ++# texinfo_domain_indices = True + + # How to display URL addresses: 'footnote', 'no', or 'inline'. +-#texinfo_show_urls = 'footnote' ++# texinfo_show_urls = 'footnote' + + # If true, do not generate a @detailmenu in the "Top" node's menu. +-#texinfo_no_detailmenu = False ++# texinfo_no_detailmenu = False +diff --git a/docs/contributing.rst b/docs/contributing.rst +index 3bdd7dc..e582053 100644 +--- a/docs/contributing.rst ++++ b/docs/contributing.rst +@@ -1 +1 @@ +-.. include:: ../CONTRIBUTING.rst +\ No newline at end of file ++.. include:: ../CONTRIBUTING.rst +diff --git a/docs/history.rst b/docs/history.rst +index bec23d8..2506499 100644 +--- a/docs/history.rst ++++ b/docs/history.rst +@@ -1 +1 @@ +-.. include:: ../HISTORY.rst +\ No newline at end of file ++.. include:: ../HISTORY.rst +diff --git a/docs/index.rst b/docs/index.rst +index 64f1a54..03c879f 100644 +--- a/docs/index.rst ++++ b/docs/index.rst +@@ -14,4 +14,4 @@ Contents: + readme + contributing + authors +- history +\ No newline at end of file ++ history +diff --git a/docs/make.bat b/docs/make.bat +index 2b44764..2df9a8c 100644 +--- a/docs/make.bat ++++ b/docs/make.bat +@@ -239,4 +239,4 @@ if "%1" == "pseudoxml" ( + goto end + ) + +-:end +\ No newline at end of file ++:end +diff --git a/docs/readme.rst b/docs/readme.rst +index 6b2b3ec..72a3355 100644 +--- a/docs/readme.rst ++++ b/docs/readme.rst +@@ -1 +1 @@ +-.. include:: ../README.rst +\ No newline at end of file ++.. include:: ../README.rst +diff --git a/pyproject.toml b/pyproject.toml +new file mode 100644 +index 0000000..f1ec81a +--- /dev/null ++++ b/pyproject.toml +@@ -0,0 +1,30 @@ ++[build-system] ++requires = ["setuptools>=40.6.0", "wheel"] ++build-backend = "setuptools.build_meta" ++ ++[tool.black] ++line-length = 119 ++target-version = ["py36"] ++include = 'djangocms_page_sitemap/*py' ++ ++[tool.towncrier] ++package = "djangocms_page_sitemap" ++directory = "changes" ++filename = "HISTORY.rst" ++title_format = "{version} ({project_date})" ++ ++[tool.interrogate] ++ignore-init-method = true ++ignore-init-module = true ++ignore-magic = false ++ignore-semiprivate = false ++ignore-private = false ++ignore-module = true ++ignore-nested-functions = true ++fail-under = 0 ++exclude = ["docs", ".tox"] ++ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"] ++verbose = 0 ++quiet = false ++whitelist-regex = [] ++color = true +diff --git a/requirements-docs.txt b/requirements-docs.txt +deleted file mode 100644 +index 57ccf60..0000000 +--- a/requirements-docs.txt ++++ /dev/null +@@ -1,2 +0,0 @@ +--r requirements-test.txt +-Django<3.0 +diff --git a/requirements-test.txt b/requirements-test.txt +index 9e809d5..4f6ebe2 100644 +--- a/requirements-test.txt ++++ b/requirements-test.txt +@@ -1,5 +1,5 @@ +-coverage<5.0 +-coveralls +-flake8>=2.1.0 +-tox>=2.0 +-django-app-helper ++-e .[docs] ++coverage>5 ++coveralls>2 ++mock>=1.0.1 ++django-app-helper>=2.0.0 +diff --git a/requirements.txt b/requirements.txt +index ecf975e..d6e1198 100644 +--- a/requirements.txt ++++ b/requirements.txt +@@ -1 +1 @@ +--e . +\ No newline at end of file ++-e . +diff --git a/setup.cfg b/setup.cfg +index 6bd9ba4..84a0f85 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -1,20 +1,72 @@ +-[flake8] +-exclude = *.egg-info,*.eggs,.git,.settings,.tox,build,dist,docs,requirements,tmp,*migrations*,*south_migrations*,tests,data +-ignore = E305, W504 +-max-line-length = 99 ++[bumpversion] ++current_version = 1.0.0 ++parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) ++serialize = ++ {major}.{minor}.{patch}.{release}{relver} ++ {major}.{minor}.{patch} ++commit = True ++tag = True ++sign_tags = True ++tag_name = {new_version} ++message = Release {new_version} ++ ++[bumpversion:part:release] ++optional_value = gamma ++values = ++ dev ++ a ++ b ++ rc ++ gamma ++ ++[bumpversion:file:djangocms_page_sitemap/__init__.py] + + [metadata] +-license-file = LICENSE ++name = djangocms-page-sitemap ++version = attr: djangocms_page_sitemap.__version__ ++url = https://github.com/nephila/djangocms-page-sitemap ++project_urls = ++ Documentation = https://djangocms-page-sitemap.readthedocs.io/ ++author = Iacopo Spalletti ++author_email = i.spalletti@nephila.it ++description = django CMS page extension to handle sitemap customization ++long_description = file: README.rst, HISTORY.rst ++long_description_content_type = text/x-rst ++license = BSD ++license_file = LICENSE ++keywords = django cms, sitemap, django-app-enabler addon ++classifiers = ++ Development Status :: 5 - Production/Stable ++ Framework :: Django ++ Intended Audience :: Developers ++ License :: OSI Approved :: BSD License ++ Natural Language :: English ++ Framework :: Django ++ Framework :: Django :: 2.2 ++ Programming Language :: Python :: 3.6 ++ Programming Language :: Python :: 3.7 + +-[wheel] +-universal = 1 ++[options] ++include_package_data = True ++install_requires = ++ django-cms>=3.6 ++setup_requires = ++ setuptools ++packages = djangocms_page_sitemap ++python_requires = >=3.6 ++zip_safe = False ++test_suite = cms_helper.run ++ ++[options.package_data] ++* = *.txt, *.rst ++djangcms_page_sitemap = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po + +-[isort] +-line_length = 99 +-skip = migrations, south_migrations +-combine_as_imports = true +-default_section = THIRDPARTY +-include_trailing_comma = true +-known_first_party = djangocms_page_sitemap +-multi_line_output = 5 +-not_skip = __init__.py ++[options.extras_require] ++docs = ++ django<3.1 ++ ++[upload] ++repository = https://upload.pypi.org/legacy/ ++ ++[bdist_wheel] ++universal = 1 +diff --git a/setup.py b/setup.py +old mode 100755 +new mode 100644 +index c2fbabb..b908cbe +--- a/setup.py ++++ b/setup.py +@@ -1,63 +1,3 @@ +-#!/usr/bin/env python +-# -*- coding: utf-8 -*- ++import setuptools + +-import os +-import sys +- +-import djangocms_page_sitemap +- +-try: +- from setuptools import setup +-except ImportError: +- from distutils.core import setup +- +-version = djangocms_page_sitemap.__version__ +- +-if sys.argv[-1] == 'publish': +- os.system('python setup.py sdist upload') +- print("You probably want to also tag the version now:") +- print(" git tag -a %s -m 'version %s'" % (version, version)) +- print(" git push --tags") +- sys.exit() +- +-readme = open('README.rst').read() +-history = open('HISTORY.rst').read().replace('.. :changelog:', '') +- +-setup( +- name='djangocms-page-sitemap', +- version=version, +- description="""django CMS page extension to handle sitemap customization""", +- long_description=readme + '\n\n' + history, +- author='Iacopo Spalletti', +- author_email='i.spalletti@nephila.it', +- url='https://github.com/nephila/djangocms-page-sitemap', +- packages=[ +- 'djangocms_page_sitemap', +- ], +- include_package_data=True, +- license='BSD', +- zip_safe=False, +- keywords='djangocms-page-sitemap', +- test_suite='cms_helper.run', +- classifiers=[ +- 'Development Status :: 5 - Production/Stable', +- 'Framework :: Django', +- 'Intended Audience :: Developers', +- 'License :: OSI Approved :: BSD License', +- 'Natural Language :: English', +- 'Framework :: Django', +- 'Framework :: Django :: 1.11', +- 'Framework :: Django :: 2.0', +- 'Framework :: Django :: 2.1', +- 'Framework :: Django :: 2.2', +- 'Programming Language :: Python :: 2', +- 'Programming Language :: Python :: 2.7', +- 'Programming Language :: Python :: 3', +- 'Programming Language :: Python :: 3.5', +- 'Programming Language :: Python :: 3.6', +- 'Programming Language :: Python :: 3.7', +- ], +- dependency_links=[ +- "http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms-4.0.0", +- ], +-) ++setuptools.setup() +diff --git a/tasks.py b/tasks.py +new file mode 100644 +index 0000000..82261dd +--- /dev/null ++++ b/tasks.py +@@ -0,0 +1,140 @@ ++import io ++import os ++import re ++import sys ++from glob import glob ++ ++from invoke import task ++ ++DOCS_PORT = os.environ.get("DOCS_PORT", 8000) ++#: branch prefixes for which some checks are skipped ++SPECIAL_BRANCHES = ("master", "develop", "release") ++ ++ ++@task ++def clean(c): ++ """ Remove artifacts and binary files. """ ++ c.run("python setup.py clean --all") ++ patterns = ["build", "dist"] ++ patterns.extend(glob("*.egg*")) ++ patterns.append("docs/_build") ++ patterns.append("**/*.pyc") ++ for pattern in patterns: ++ c.run("rm -rf {}".format(pattern)) ++ ++ ++@task ++def lint(c): ++ """ Run linting tox environments. """ ++ c.run("tox -epep8,isort,black,pypi-description") ++ ++ ++@task # NOQA ++def format(c): # NOQA ++ """ Run code formatting tasks. """ ++ c.run("tox -eblacken,isort_format") ++ ++ ++@task ++def towncrier_check(c): # NOQA ++ """ Check towncrier files. """ ++ output = io.StringIO() ++ c.run("git branch --contains HEAD", out_stream=output) ++ skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"] ++ # cleanup branch names by removing PR-only names in local, remote and disconnected branches to ensure the current ++ # (i.e. user defined) branch name is used ++ branches = list( ++ filter( ++ lambda x: x and all(not x.startswith(part) for part in skipped_branch_prefix), ++ ( ++ branch.replace("origin/", "").replace("remotes/", "").strip("* (") ++ for branch in output.getvalue().split("\n") ++ ), ++ ) ++ ) ++ print("Candidate branches", ", ".join(output.getvalue().split("\n"))) ++ if not branches: ++ # if no branch name matches, we are in one of the excluded branches above, so we just exit ++ print("Skip check, branch excluded by configuration") ++ return ++ branch = branches[0] ++ towncrier_file = None ++ for branch in branches: ++ if any(branch.startswith(prefix) for prefix in SPECIAL_BRANCHES): ++ sys.exit(0) ++ try: ++ parts = re.search(r"(?P\w+)/\D*(?P\d+)\D*", branch).groups() ++ towncrier_file = os.path.join("changes", "{1}.{0}".format(*parts)) ++ if not os.path.exists(towncrier_file) or os.path.getsize(towncrier_file) == 0: ++ print( ++ "=========================\n" ++ "Current tree does not contain the towncrier file {} or file is empty\n" ++ "please check CONTRIBUTING documentation.\n" ++ "=========================" ++ "".format(towncrier_file) ++ ) ++ sys.exit(2) ++ else: ++ break ++ except AttributeError: ++ pass ++ if not towncrier_file: ++ print( ++ "=========================\n" ++ "Branch {} does not respect the '/(-)-description' format\n" ++ "=========================\n" ++ "".format(branch) ++ ) ++ sys.exit(1) ++ ++ ++@task ++def test(c): ++ """ Run test in local environment. """ ++ c.run("python setup.py test") ++ ++ ++@task ++def test_all(c): ++ """ Run all tox environments. """ ++ c.run("tox") ++ ++ ++@task ++def coverage(c): ++ """ Run test with coverage in local environment. """ ++ c.run("coverage erase") ++ c.run("run setup.py test") ++ c.run("report -m") ++ ++ ++@task ++def tag_release(c, level): ++ """ Tag release version. """ ++ c.run("bumpversion --list %s --no-tag" % level) ++ ++ ++@task ++def tag_dev(c, level="patch"): ++ """ Tag development version. """ ++ c.run("bumpversion --list %s --message='Bump develop version [ci skip]' --no-tag" % level) ++ ++ ++@task(pre=[clean]) ++def docbuild(c): ++ """ Build documentation. """ ++ os.chdir("docs") ++ build_dir = os.environ.get("BUILD_DIR", "_build/html") ++ c.run("python -msphinx -W -b html -d _build/doctrees . %s" % build_dir) ++ ++ ++@task(docbuild) ++def docserve(c): ++ """ Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000). """ ++ from livereload import Server ++ ++ server = Server() ++ server.watch("docs/conf.py", lambda: docbuild(c)) ++ server.watch("CONTRIBUTING.rst", lambda: docbuild(c)) ++ server.watch("docs/*.rst", lambda: docbuild(c)) ++ server.serve(port=DOCS_PORT, root="_build/html") + +From bda90b6fb13fbdebbd05ea741e2562f14ca01d6b Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 10:49:04 +0000 +Subject: [PATCH 02/20] Updated the history + +--- + HISTORY.rst | 17 +++++++---------- + 1 file changed, 7 insertions(+), 10 deletions(-) + +diff --git a/HISTORY.rst b/HISTORY.rst +index 4e0f054..77bdfcc 100644 +--- a/HISTORY.rst ++++ b/HISTORY.rst +@@ -6,19 +6,16 @@ History + + .. towncrier release notes start + +-1.0.0 (2020-12-21) +-================== +- +-Features +--------- ++(unreleased) ++============ + +-- Add support for django-app-enabler (#63) +-- Update tooling and drop Python 2 / Django < 2.2 compatibility (#10208) ++- Update tooling + +-0.8.1 (2020-05-02) +-================== ++0.9.0.dev8 (2020-11-23) ++======================= + +-* Enable django CMS 3.7.2 on python 3 ++* Port to django CMS 4.0 ++* Fix djangocms-versioning integration + + 0.8.0 (2020-01-12) + ================== + +From 0ff3e573b5c72db4915fa237e7f411b88e8b2d36 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 10:55:30 +0000 +Subject: [PATCH 03/20] Update the test suite to cms4 + +--- + tox.ini | 178 +++++++++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 137 insertions(+), 41 deletions(-) + +diff --git a/tox.ini b/tox.ini +index 62c446f..2432732 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -1,61 +1,157 @@ + [tox] + envlist = ++ black ++ blacken + docs +- pep8 + isort +- py{35,36,37}-django{111,21}-cms40 +- py{35,36,37}-django22-cms40 +- +-skip_missing_interpreters=True ++ isort_format ++ pep8 ++ pypi-description ++ towncrier ++ py{39,38,37}-django{32}-cms{40} ++ py{38,37,36}-django{22}-cms{40} + + [testenv] +-commands = {env:COMMAND:python} setup.py test +- ++commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} + deps = +- -r{toxinidir}/requirements-test.txt +- +- # Django 1.11 installation requirements +- django111: Django>=1.11,<2.0 +- django111: django-formtools>=2.1<2.2 +- django111: django-sekizai<2.0.0 +- django111: djangocms_admin_style<2.0.0 +- django111: django-classy-tags<2.0.0 +- +- # Django 2.1 installation requirements +- django21: Django>=2.1,<2.2 +- django21: django-sekizai<2.0.0 +- django21: djangocms_admin_style<2.0.0 +- django21: django-classy-tags<2.0.0 +- +- django22: Django>=2.2,<2.3 +- ++ django22: Django>=2.2,<3.0 ++ django32: Django>=3.2,<3.3 + cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip ++ -r {toxinidir}/requirements-test.txt ++passenv = ++ COMMAND ++ PYTEST_* + +- +-basepython = +- py35: python3.5 +- py36: python3.6 +- py37: python3.7 ++[testenv:pep8] ++commands = ++ {envpython} -m flake8 ++ {envpython} -minterrogate -c pyproject.toml djangocms_page_sitemap tests ++deps = ++ interrogate ++ flake8 ++ flake8-broken-line ++ flake8-bugbear ++ flake8-builtins ++ flake8-coding ++ flake8-commas ++ flake8-comprehensions ++ flake8-eradicate ++ flake8-quotes ++ flake8-tidy-imports ++ pep8-naming ++skip_install = true + + [testenv:isort] +-commands = isort --recursive --check-only --diff {toxinidir} +-deps = isort ++commands = ++ {envpython} -m isort -c --df djangocms_page_sitemap tests ++deps = isort>5,<6 + skip_install = true +-basepython = python3.5 + +-[testenv:pep8] +-commands = flake8 +-deps = flake8 ++[testenv:isort_format] ++commands = ++ {envpython} -m isort djangocms_page_sitemap tests ++deps = {[testenv:isort]deps} ++skip_install = true ++ ++[testenv:black] ++commands = ++ {envpython} -m black --check --diff . ++deps = black ++skip_install = true ++ ++[testenv:blacken] ++commands = ++ {envpython} -m black . ++deps = {[testenv:black]deps} + skip_install = true +-basepython = python3.5 + + [testenv:docs] +-changedir = docs +-commands= +- sphinx-build -W -b html -d {envtmpdir}/doctrees . {toxinidir}/docs/_build/html ++commands = ++ {envpython} -m invoke docbuild + deps = ++ invoke + sphinx + sphinx-rtd-theme +- -rrequirements-docs.txt ++ sphinx-autobuild ++ livereload~=2.6 ++ -requirements-test.txt ++skip_install = true ++ ++[testenv:towncrier] ++commands = ++ {envpython} -m invoke towncrier-check ++deps = ++ invoke ++skip_install = true ++ ++[testenv:pypi-description] ++commands = ++ {envpython} -m invoke clean ++ {envpython} -m check_manifest ++ {envpython} -m pep517.build . ++ {envpython} -m twine check dist/* ++deps = ++ invoke ++ check-manifest ++ pep517 ++ twine ++skip_install = true ++ ++[testenv:release] ++commands = ++ {envpython} -m invoke clean ++ {envpython} -m check_manifest ++ {envpython} -m pep517.build . ++ {envpython} -m twine upload {posargs} dist/* ++deps = {[testenv:pypi-description]deps} ++passenv = ++ TWINE_* + skip_install = true +-basepython = python3.5 ++ ++[flake8] ++exclude = *.egg-info,.git,.settings,.tox,build,dist,docs,requirements,tmp,*migrations*,tests,data ++ignore = E800, W503, C812, C813, C815, C818, C819, C408 ++max-line-length = 119 ++# flake8-quotes ++inline-quotes = double ++# flake8-coding ++no-accept-encodings = True ++# flake8-tidy-imports ++banned-modules = __future__ = this project supports python3 only ++ ++[isort] ++combine_as_imports = true ++default_section = THIRDPARTY ++force_grid_wrap = 0 ++include_trailing_comma = true ++known_first_party = djangocms_page_sitemap ++line_length = 119 ++multi_line_output = 3 ++skip = data, .tox ++use_parentheses = True ++ ++[check-manifest] ++ignore = ++ .* ++ *.ini ++ *.toml ++ *.json ++ *.txt ++ *.yml ++ *.yaml ++ .tx/** ++ changes/** ++ docs/** ++ cms_helper.py ++ aldryn_config.py ++ tasks.py ++ tests/** ++ *.mo ++ignore-bad-ideas = ++ *.mo ++ ++[pytest] ++DJANGO_SETTINGS_MODULE = cms_helper ++python_files = test_*.py ++traceback = short ++addopts = --reuse-db + +From 5b9a7d10c291a0bc50afe171e2fbe726b73ead1f Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 11:06:54 +0000 +Subject: [PATCH 04/20] Bring the github workflows in line with the tox + configuration + +--- + .github/workflows/test.yml | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml +index bac4618..7a29250 100644 +--- a/.github/workflows/test.yml ++++ b/.github/workflows/test.yml +@@ -8,12 +8,10 @@ jobs: + runs-on: ubuntu-latest + strategy: + matrix: +- python-version: [3.8, 3.7, 3.6] +- django: [31, 30, 22] +- cms: [38, 37] +- exclude: +- - django: 31 +- cms: 37 ++ python-version: [39, 38, 37] ++ django: [32, 22] ++ cms: [40] ++ + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + +From 5634acd61372e8ff9b36fa70cf5bfb83fca68016 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 11:10:38 +0000 +Subject: [PATCH 05/20] Fix mismatch of python / django versions in tox and GH + actions + +--- + tox.ini | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/tox.ini b/tox.ini +index 2432732..21c93cc 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -8,8 +8,7 @@ envlist = + pep8 + pypi-description + towncrier +- py{39,38,37}-django{32}-cms{40} +- py{38,37,36}-django{22}-cms{40} ++ py{39,38,37}-django{32,22}-cms{40} + + [testenv] + commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} + +From 15302a1d96ee0cd60b9bdce7926f8e1cc60f7d73 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 15:16:41 +0000 +Subject: [PATCH 06/20] Fix various mismatch issues + +--- + .github/workflows/test.yml | 2 +- + setup.cfg | 10 ++++++---- + 2 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml +index 7a29250..1f298c8 100644 +--- a/.github/workflows/test.yml ++++ b/.github/workflows/test.yml +@@ -8,7 +8,7 @@ jobs: + runs-on: ubuntu-latest + strategy: + matrix: +- python-version: [39, 38, 37] ++ python-version: [3.9, 3.8, 3.7] + django: [32, 22] + cms: [40] + +diff --git a/setup.cfg b/setup.cfg +index 84a0f85..d01f83f 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -1,5 +1,5 @@ + [bumpversion] +-current_version = 1.0.0 ++current_version = 0.9.0.dev8 + parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) + serialize = + {major}.{minor}.{patch}.{release}{relver} +@@ -43,17 +43,19 @@ classifiers = + Natural Language :: English + Framework :: Django + Framework :: Django :: 2.2 +- Programming Language :: Python :: 3.6 ++ Framework :: Django :: 3.2 + Programming Language :: Python :: 3.7 ++ Programming Language :: Python :: 3.8 ++ Programming Language :: Python :: 3.9 + + [options] + include_package_data = True + install_requires = +- django-cms>=3.6 ++ django-cms>=3.7 + setup_requires = + setuptools + packages = djangocms_page_sitemap +-python_requires = >=3.6 ++python_requires = >=3.7 + zip_safe = False + test_suite = cms_helper.run + + +From 0258afda9a6c6da21b2768b09f8e960f450ef342 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 15:20:41 +0000 +Subject: [PATCH 07/20] Removed all py2 # -*- coding: utf-8 -*- + +--- + djangocms_page_sitemap/__init__.py | 2 +- + djangocms_page_sitemap/admin.py | 2 +- + djangocms_page_sitemap/cms_toolbars.py | 2 +- + djangocms_page_sitemap/migrations/0001_initial.py | 2 +- + djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 2 +- + djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py | 2 +- + djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py | 2 +- + djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py | 2 +- + djangocms_page_sitemap/models.py | 2 +- + djangocms_page_sitemap/settings.py | 2 +- + djangocms_page_sitemap/sitemap.py | 2 +- + djangocms_page_sitemap/sitemap_urls.py | 2 +- + djangocms_page_sitemap/templatetags/__init__.py | 2 +- + djangocms_page_sitemap/templatetags/robots_index.py | 2 +- + djangocms_page_sitemap/utils.py | 2 +- + tests/__init__.py | 2 +- + tests/base.py | 2 +- + tests/test_models.py | 2 +- + tests/test_sitemap.py | 2 +- + tests/test_toolbar.py | 2 +- + tests/test_utils/__init__.py | 2 +- + tests/test_utils/urls.py | 2 +- + 22 files changed, 22 insertions(+), 22 deletions(-) + +diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py +index 7a4e315..59eeade 100644 +--- a/djangocms_page_sitemap/__init__.py ++++ b/djangocms_page_sitemap/__init__.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + __version__ = '0.9.0.dev8' # pragma: no cover +diff --git a/djangocms_page_sitemap/admin.py b/djangocms_page_sitemap/admin.py +index 05e9937..3ecd26c 100644 +--- a/djangocms_page_sitemap/admin.py ++++ b/djangocms_page_sitemap/admin.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from cms.extensions import PageExtensionAdmin +diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py +index 129edb9..50afdfd 100644 +--- a/djangocms_page_sitemap/cms_toolbars.py ++++ b/djangocms_page_sitemap/cms_toolbars.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from cms.toolbar_pool import toolbar_pool +diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py +index 2334e64..bf8ee0b 100644 +--- a/djangocms_page_sitemap/migrations/0001_initial.py ++++ b/djangocms_page_sitemap/migrations/0001_initial.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import unicode_literals + + import django.core.validators +diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +index b0ff842..4f12d95 100644 +--- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py ++++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import unicode_literals + + from django.db import migrations, models +diff --git a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py +index 564f1f2..2228cd8 100644 +--- a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py ++++ b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import unicode_literals + + import django.core.validators +diff --git a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py +index 762a83e..7f1ed4b 100644 +--- a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py ++++ b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + # Generated by Django 1.10.8 on 2018-02-02 09:44 + from __future__ import unicode_literals + +diff --git a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py +index fda955a..1d70bc7 100644 +--- a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py ++++ b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + # Generated by Django 1.11.10 on 2018-03-24 09:50 + from __future__ import unicode_literals + +diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py +index f2597fc..0fc648b 100644 +--- a/djangocms_page_sitemap/models.py ++++ b/djangocms_page_sitemap/models.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from cms.extensions import PageExtension, extension_pool +diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py +index 406886f..41b6cfc 100644 +--- a/djangocms_page_sitemap/settings.py ++++ b/djangocms_page_sitemap/settings.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from cms.sitemaps import CMSSitemap +diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py +index b21c37d..b10704f 100644 +--- a/djangocms_page_sitemap/sitemap.py ++++ b/djangocms_page_sitemap/sitemap.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from collections import defaultdict +diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py +index cf65490..528ef50 100644 +--- a/djangocms_page_sitemap/sitemap_urls.py ++++ b/djangocms_page_sitemap/sitemap_urls.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from django.conf.urls import url +diff --git a/djangocms_page_sitemap/templatetags/__init__.py b/djangocms_page_sitemap/templatetags/__init__.py +index 40a96af..8b13789 100644 +--- a/djangocms_page_sitemap/templatetags/__init__.py ++++ b/djangocms_page_sitemap/templatetags/__init__.py +@@ -1 +1 @@ +-# -*- coding: utf-8 -*- ++ +diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py +index 8a3c47c..56357f0 100644 +--- a/djangocms_page_sitemap/templatetags/robots_index.py ++++ b/djangocms_page_sitemap/templatetags/robots_index.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from classytags.arguments import Argument +diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py +index 9380a41..68d96a4 100644 +--- a/djangocms_page_sitemap/utils.py ++++ b/djangocms_page_sitemap/utils.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from cms.cache import _get_cache_key +diff --git a/tests/__init__.py b/tests/__init__.py +index 40a96af..8b13789 100644 +--- a/tests/__init__.py ++++ b/tests/__init__.py +@@ -1 +1 @@ +-# -*- coding: utf-8 -*- ++ +diff --git a/tests/base.py b/tests/base.py +index 5ec4382..a00b496 100644 +--- a/tests/base.py ++++ b/tests/base.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from cms.utils.i18n import get_language_list +diff --git a/tests/test_models.py b/tests/test_models.py +index b753319..1953aa4 100644 +--- a/tests/test_models.py ++++ b/tests/test_models.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from django import template +diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py +index 1f229ea..bedb11a 100644 +--- a/tests/test_sitemap.py ++++ b/tests/test_sitemap.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from decimal import Decimal +diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py +index 73866e4..c947930 100644 +--- a/tests/test_toolbar.py ++++ b/tests/test_toolbar.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from cms.api import create_page +diff --git a/tests/test_utils/__init__.py b/tests/test_utils/__init__.py +index 40a96af..8b13789 100644 +--- a/tests/test_utils/__init__.py ++++ b/tests/test_utils/__init__.py +@@ -1 +1 @@ +-# -*- coding: utf-8 -*- ++ +diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py +index 97cf06a..8b6b6ef 100644 +--- a/tests/test_utils/urls.py ++++ b/tests/test_utils/urls.py +@@ -1,4 +1,4 @@ +-# -*- coding: utf-8 -*- ++ + from __future__ import absolute_import, print_function, unicode_literals + + from cms.utils.conf import get_cms_setting + +From 8bdbe1754a9a397ee321ba5739ca4d4e0ce3d24e Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 15:26:52 +0000 +Subject: [PATCH 08/20] Use a dj 3.2 compatible version + +--- + HISTORY.rst | 4 +++- + tox.ini | 3 ++- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/HISTORY.rst b/HISTORY.rst +index 77bdfcc..9ff65de 100644 +--- a/HISTORY.rst ++++ b/HISTORY.rst +@@ -9,7 +9,9 @@ History + (unreleased) + ============ + +-- Update tooling ++* Update tooling and ci test suite to Github Actions ++* Add compatibility with Django 3.2 ++* Drop compatibility with Django < 2.2 + + 0.9.0.dev8 (2020-11-23) + ======================= +diff --git a/tox.ini b/tox.ini +index 21c93cc..44a23f1 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -15,7 +15,8 @@ commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posar + deps = + django22: Django>=2.2,<3.0 + django32: Django>=3.2,<3.3 +- cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip ++ cms40: https://github.com/Aiky30/django-cms/archive/feature/cms-4-django-32-support.zip ++ #cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip + -r {toxinidir}/requirements-test.txt + passenv = + COMMAND + +From d6254030162e109e57a17751a338a3cb4cd07147 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 15:31:13 +0000 +Subject: [PATCH 09/20] Removed all __future__ imports + +--- + djangocms_page_sitemap/__init__.py | 3 --- + djangocms_page_sitemap/admin.py | 3 --- + djangocms_page_sitemap/cms_toolbars.py | 3 --- + djangocms_page_sitemap/migrations/0001_initial.py | 3 --- + djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 3 --- + djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py | 3 --- + djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py | 3 --- + djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py | 3 --- + djangocms_page_sitemap/models.py | 3 --- + djangocms_page_sitemap/settings.py | 3 --- + djangocms_page_sitemap/sitemap.py | 5 ----- + djangocms_page_sitemap/sitemap_urls.py | 3 --- + djangocms_page_sitemap/templatetags/robots_index.py | 3 --- + djangocms_page_sitemap/utils.py | 3 --- + tests/base.py | 4 +--- + tests/test_models.py | 3 --- + tests/test_sitemap.py | 3 --- + tests/test_toolbar.py | 3 --- + tests/test_utils/urls.py | 3 --- + 19 files changed, 1 insertion(+), 59 deletions(-) + +diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py +index 59eeade..7aa1eeb 100644 +--- a/djangocms_page_sitemap/__init__.py ++++ b/djangocms_page_sitemap/__init__.py +@@ -1,5 +1,2 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + __version__ = '0.9.0.dev8' # pragma: no cover + __author__ = 'Iacopo Spalletti ' # pragma: no cover +diff --git a/djangocms_page_sitemap/admin.py b/djangocms_page_sitemap/admin.py +index 3ecd26c..3f468f3 100644 +--- a/djangocms_page_sitemap/admin.py ++++ b/djangocms_page_sitemap/admin.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from cms.extensions import PageExtensionAdmin + from django.contrib import admin + +diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py +index 50afdfd..9705eb4 100644 +--- a/djangocms_page_sitemap/cms_toolbars.py ++++ b/djangocms_page_sitemap/cms_toolbars.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from cms.toolbar_pool import toolbar_pool + from cms.utils.conf import get_cms_setting + from cms.utils.permissions import has_page_permission +diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py +index bf8ee0b..29ad25a 100644 +--- a/djangocms_page_sitemap/migrations/0001_initial.py ++++ b/djangocms_page_sitemap/migrations/0001_initial.py +@@ -1,6 +1,3 @@ +- +-from __future__ import unicode_literals +- + import django.core.validators + from django.db import models, migrations + +diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +index 4f12d95..0e2e8a7 100644 +--- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py ++++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +@@ -1,6 +1,3 @@ +- +-from __future__ import unicode_literals +- + from django.db import migrations, models + from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST + +diff --git a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py +index 2228cd8..f463f2f 100644 +--- a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py ++++ b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py +@@ -1,6 +1,3 @@ +- +-from __future__ import unicode_literals +- + import django.core.validators + from django.db import migrations, models + +diff --git a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py +index 7f1ed4b..af89883 100644 +--- a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py ++++ b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py +@@ -1,7 +1,4 @@ +- + # Generated by Django 1.10.8 on 2018-02-02 09:44 +-from __future__ import unicode_literals +- + from django.db import migrations, models + + +diff --git a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py +index 1d70bc7..2e0d79f 100644 +--- a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py ++++ b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py +@@ -1,7 +1,4 @@ +- + # Generated by Django 1.11.10 on 2018-03-24 09:50 +-from __future__ import unicode_literals +- + from django.db import migrations, models + + +diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py +index 0fc648b..8882288 100644 +--- a/djangocms_page_sitemap/models.py ++++ b/djangocms_page_sitemap/models.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from cms.extensions import PageExtension, extension_pool + from cms.models import Page + from cms.utils.compat.dj import python_2_unicode_compatible +diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py +index 41b6cfc..ca95dbd 100644 +--- a/djangocms_page_sitemap/settings.py ++++ b/djangocms_page_sitemap/settings.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from cms.sitemaps import CMSSitemap + from cms.utils.conf import get_cms_setting + from django.conf import settings +diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py +index b10704f..8fd33ef 100644 +--- a/djangocms_page_sitemap/sitemap.py ++++ b/djangocms_page_sitemap/sitemap.py +@@ -1,8 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- +-from collections import defaultdict +- + from cms.models import PageContent, PageUrl + from cms.sitemaps import CMSSitemap + from cms.utils import get_current_site +diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py +index 528ef50..b591de1 100644 +--- a/djangocms_page_sitemap/sitemap_urls.py ++++ b/djangocms_page_sitemap/sitemap_urls.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from django.conf.urls import url + from django.contrib.sitemaps.views import sitemap + +diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py +index 56357f0..8aa03a9 100644 +--- a/djangocms_page_sitemap/templatetags/robots_index.py ++++ b/djangocms_page_sitemap/templatetags/robots_index.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from classytags.arguments import Argument + from classytags.core import Options, Tag + from cms.templatetags.cms_tags import _get_page_by_untyped_arg +diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py +index 68d96a4..539253d 100644 +--- a/djangocms_page_sitemap/utils.py ++++ b/djangocms_page_sitemap/utils.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from cms.cache import _get_cache_key + from django.apps import apps + +diff --git a/tests/base.py b/tests/base.py +index a00b496..2213f9c 100644 +--- a/tests/base.py ++++ b/tests/base.py +@@ -1,11 +1,9 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals ++from io import StringIO + + from cms.utils.i18n import get_language_list + from django.contrib.auth.models import User + from django.http import SimpleCookie + from django.test import RequestFactory, TestCase +-from django.utils.six import StringIO + + from djangocms_page_sitemap.utils import is_versioning_enabled + +diff --git a/tests/test_models.py b/tests/test_models.py +index 1953aa4..3f6f7bb 100644 +--- a/tests/test_models.py ++++ b/tests/test_models.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from django import template + from django.contrib.auth.models import AnonymousUser + from django.contrib.sites.models import Site +diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py +index bedb11a..b32512d 100644 +--- a/tests/test_sitemap.py ++++ b/tests/test_sitemap.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from decimal import Decimal + from unittest import skipIf + +diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py +index c947930..f0e5c9b 100644 +--- a/tests/test_toolbar.py ++++ b/tests/test_toolbar.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from cms.api import create_page + from cms.test_utils.testcases import CMSTestCase + from cms.toolbar.items import Menu, ModalItem +diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py +index 8b6b6ef..a9c2894 100644 +--- a/tests/test_utils/urls.py ++++ b/tests/test_utils/urls.py +@@ -1,6 +1,3 @@ +- +-from __future__ import absolute_import, print_function, unicode_literals +- + from cms.utils.conf import get_cms_setting + from django.conf import settings + from django.conf.urls import include, url + +From 9b1cd1adf1fbd2dc22f9b39faaa5d75c8708c446 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Tue, 21 Dec 2021 15:40:58 +0000 +Subject: [PATCH 10/20] Removed @python_2_unicode_compatible + +--- + djangocms_page_sitemap/models.py | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py +index 8882288..50611dc 100644 +--- a/djangocms_page_sitemap/models.py ++++ b/djangocms_page_sitemap/models.py +@@ -1,6 +1,5 @@ + from cms.extensions import PageExtension, extension_pool + from cms.models import Page +-from cms.utils.compat.dj import python_2_unicode_compatible + from django.core.cache import cache + from django.core.validators import MaxValueValidator, MinValueValidator + from django.db import models +@@ -13,7 +12,6 @@ + + + @extension_pool.register +-@python_2_unicode_compatible + class PageSitemapProperties(PageExtension): + changefreq = models.CharField( + _('Change frequency'), max_length=20, default='monthly', + +From 4ce98ca34b0dc914b81654116371a63c3739ee7a Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 09:18:42 +0000 +Subject: [PATCH 11/20] Update django limitation from 3.3 to 4.0 + +--- + setup.cfg | 2 +- + tox.ini | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/setup.cfg b/setup.cfg +index d01f83f..0a5b76e 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -65,7 +65,7 @@ djangcms_page_sitemap = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po + + [options.extras_require] + docs = +- django<3.1 ++ django<4.0 + + [upload] + repository = https://upload.pypi.org/legacy/ +diff --git a/tox.ini b/tox.ini +index 44a23f1..87b31bf 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -14,7 +14,7 @@ envlist = + commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} + deps = + django22: Django>=2.2,<3.0 +- django32: Django>=3.2,<3.3 ++ django32: Django>=3.2,<4.0 + cms40: https://github.com/Aiky30/django-cms/archive/feature/cms-4-django-32-support.zip + #cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip + -r {toxinidir}/requirements-test.txt + +From dd1bb823839bfc46d357d617c2d650ddd4140f6a Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 09:35:02 +0000 +Subject: [PATCH 12/20] Fix isort failures + +--- + djangocms_page_sitemap/migrations/0001_initial.py | 2 +- + djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 1 + + tests/test_toolbar.py | 1 - + 3 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py +index 29ad25a..6d9f90a 100644 +--- a/djangocms_page_sitemap/migrations/0001_initial.py ++++ b/djangocms_page_sitemap/migrations/0001_initial.py +@@ -1,5 +1,5 @@ + import django.core.validators +-from django.db import models, migrations ++from django.db import migrations, models + + from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST + +diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +index 0e2e8a7..dd47306 100644 +--- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py ++++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +@@ -1,4 +1,5 @@ + from django.db import migrations, models ++ + from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST + + +diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py +index f0e5c9b..ee9f953 100644 +--- a/tests/test_toolbar.py ++++ b/tests/test_toolbar.py +@@ -12,7 +12,6 @@ + from djangocms_page_sitemap.models import PageSitemapProperties + from djangocms_page_sitemap.utils import is_versioning_enabled + +- + from .base import BaseTest + + + +From 812a0f0a61ab2bc29ab3f8208a14335834360889 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 09:36:44 +0000 +Subject: [PATCH 13/20] Fix installation dependancies + +--- + tox.ini | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tox.ini b/tox.ini +index 87b31bf..b58f0d7 100644 +--- a/tox.ini ++++ b/tox.ini +@@ -74,7 +74,7 @@ deps = + sphinx-rtd-theme + sphinx-autobuild + livereload~=2.6 +- -requirements-test.txt ++ -r requirements-test.txt + skip_install = true + + [testenv:towncrier] + +From 591df6231d76a11629bca4b6c4a6a2336b3d2d9c Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 09:58:14 +0000 +Subject: [PATCH 14/20] fixed lint failures + +--- + aldryn_config.py | 24 +++---- + cms_helper.py | 71 ++++++++++--------- + djangocms_page_sitemap/__init__.py | 4 +- + djangocms_page_sitemap/cms_toolbars.py | 12 ++-- + djangocms_page_sitemap/models.py | 20 +++--- + djangocms_page_sitemap/settings.py | 20 +++--- + djangocms_page_sitemap/sitemap.py | 4 +- + djangocms_page_sitemap/sitemap_urls.py | 4 +- + .../templatetags/robots_index.py | 18 ++--- + djangocms_page_sitemap/utils.py | 4 +- + 10 files changed, 91 insertions(+), 90 deletions(-) + +diff --git a/aldryn_config.py b/aldryn_config.py +index 66499b1..e8d0bb0 100644 +--- a/aldryn_config.py ++++ b/aldryn_config.py +@@ -5,28 +5,28 @@ + from aldryn_client import forms + + PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST = { +- 'always': 'always', +- 'hourly': 'hourly', +- 'daily': 'daily', +- 'weekly': 'weekly', +- 'monthly': 'monthly', +- 'yearly': 'yearly', +- 'never': 'never', ++ "always": "always", ++ "hourly": "hourly", ++ "daily": "daily", ++ "weekly": "weekly", ++ "monthly": "monthly", ++ "yearly": "yearly", ++ "never": "never", + } + + + class Form(forms.BaseForm): + PAGE_SITEMAP_DEFAULT_CHANGEFREQ = forms.SelectField( +- 'Default changefrequency (default: django CMS value -monthly-)', ++ "Default changefrequency (default: django CMS value -monthly-)", + choices=PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST.items(), + ) + PAGE_SITEMAP_CACHE_DURATION = forms.CharField( +- 'Cache duration (default: same as django CMS menu cache)', ++ "Cache duration (default: same as django CMS menu cache)", + required=False + ) + + def to_settings(self, data, settings): +- settings['PAGE_SITEMAP_DEFAULT_CHANGEFREQ'] = data['PAGE_SITEMAP_DEFAULT_CHANGEFREQ'] +- settings['PAGE_SITEMAP_CACHE_DURATION'] = data['PAGE_SITEMAP_CACHE_DURATION'] +- settings['ADDON_URLS'].insert(0, 'djangocms_page_sitemap.sitemap_urls') ++ settings["PAGE_SITEMAP_DEFAULT_CHANGEFREQ"] = data["PAGE_SITEMAP_DEFAULT_CHANGEFREQ"] ++ settings["PAGE_SITEMAP_CACHE_DURATION"] = data["PAGE_SITEMAP_CACHE_DURATION"] ++ settings["ADDON_URLS"].insert(0, "djangocms_page_sitemap.sitemap_urls") + return settings +diff --git a/cms_helper.py b/cms_helper.py +index 35d4008..0d61a7f 100755 +--- a/cms_helper.py ++++ b/cms_helper.py +@@ -16,54 +16,55 @@ def __getitem__(self, item): + def gettext(s): + return s + ++ + HELPER_SETTINGS = { +- 'NOSE_ARGS': [ +- '-s', ++ "NOSE_ARGS": [ ++ "-s", + ], +- 'CACHES': { +- 'default': { +- 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', ++ "CACHES": { ++ "default": { ++ "BACKEND": "django.core.cache.backends.locmem.LocMemCache", + } + }, +- 'CMS_CACHE_DURATIONS': { +- 'menus': 10, +- 'content': 10, +- 'permissions': 10, ++ "CMS_CACHE_DURATIONS": { ++ "menus": 10, ++ "content": 10, ++ "permissions": 10, + }, +- 'ROOT_URLCONF': 'tests.test_utils.urls', ++ "ROOT_URLCONF": "tests.test_utils.urls", + # FIXME: Django CMS migrtions with Django 2.2 produce an error when + # running tests, temporarily disabling migrations +- 'MIGRATION_MODULES': DisableMigrations(), +- 'INSTALLED_APPS': [ +- 'django.contrib.sitemaps', ++ "MIGRATION_MODULES": DisableMigrations(), ++ "INSTALLED_APPS": [ ++ "django.contrib.sitemaps", + ], +- 'LANGUAGE_CODE': 'en', +- 'TIME_ZONE': 'UTC', +- 'LANGUAGES': ( +- ('en', gettext('English')), +- ('fr', gettext('French')), +- ('it', gettext('Italiano')), ++ "LANGUAGE_CODE": "en", ++ "TIME_ZONE": "UTC", ++ "LANGUAGES": ( ++ ("en", gettext("English")), ++ ("fr", gettext("French")), ++ ("it", gettext("Italiano")), + ), +- 'CMS_LANGUAGES': { ++ "CMS_LANGUAGES": { + 1: [ + { +- 'code': 'en', +- 'name': gettext('English'), +- 'public': True, ++ "code": "en", ++ "name": gettext("English"), ++ "public": True, + }, + { +- 'code': 'it', +- 'name': gettext('Italiano'), +- 'public': True, ++ "code": "it", ++ "name": gettext("Italiano"), ++ "public": True, + }, + { +- 'code': 'fr', +- 'name': gettext('French'), +- 'public': True, ++ "code": "fr", ++ "name": gettext("French"), ++ "public": True, + }, + ], +- 'default': { +- 'hide_untranslated': False, ++ "default": { ++ "hide_untranslated": False, + }, + }, + +@@ -72,17 +73,17 @@ def gettext(s): + + def run(): + from app_helper import runner +- runner.cms('djangocms_page_sitemap') ++ runner.cms("djangocms_page_sitemap") + + + def setup(): + from app_helper import runner +- runner.setup('djangocms_page_sitemap', sys.modules[__name__], use_cms=True) ++ runner.setup("djangocms_page_sitemap", sys.modules[__name__], use_cms=True) + + +-if __name__ == '__main__': ++if __name__ == "__main__": + run() + +-if __name__ == 'cms_helper': ++if __name__ == "cms_helper": + # this is needed to run cms_helper in pycharm + setup() +diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py +index 7aa1eeb..466ef04 100644 +--- a/djangocms_page_sitemap/__init__.py ++++ b/djangocms_page_sitemap/__init__.py +@@ -1,2 +1,2 @@ +-__version__ = '0.9.0.dev8' # pragma: no cover +-__author__ = 'Iacopo Spalletti ' # pragma: no cover ++__version__ = "0.9.0.dev8" # pragma: no cover ++__author__ = "Iacopo Spalletti " # pragma: no cover +diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py +index 9705eb4..498e745 100644 +--- a/djangocms_page_sitemap/cms_toolbars.py ++++ b/djangocms_page_sitemap/cms_toolbars.py +@@ -13,7 +13,7 @@ + from cms.cms_toolbars import PageToolbar + + +-PAGE_SITEMAP_MENU_TITLE = _('Sitemap properties') ++PAGE_SITEMAP_MENU_TITLE = _("Sitemap properties") + + + @toolbar_pool.register +@@ -25,9 +25,9 @@ def populate(self): + return + + # check global permissions if CMS_PERMISSIONS is active +- if get_cms_setting('PERMISSION'): ++ if get_cms_setting("PERMISSION"): + has_global_current_page_change_permission = has_page_permission( +- self.request.user, self.request.current_page, 'change' ++ self.request.user, self.request.current_page, "change" + ) + else: + has_global_current_page_change_permission = False +@@ -38,7 +38,7 @@ def populate(self): + ) + if has_global_current_page_change_permission or can_change: + not_edit_mode = not self.toolbar.edit_mode_active +- current_page_menu = self.toolbar.get_or_create_menu('page') ++ current_page_menu = self.toolbar.get_or_create_menu("page") + # Page tags + try: + page_extension = PageSitemapProperties.objects.get(extended_object_id=self.page.pk) +@@ -46,11 +46,11 @@ def populate(self): + page_extension = None + try: + if page_extension: +- url = reverse('admin:djangocms_page_sitemap_pagesitemapproperties_change', ++ url = reverse("admin:djangocms_page_sitemap_pagesitemapproperties_change", + args=(page_extension.pk,)) + else: + url = "%s?extended_object=%s" % ( +- reverse('admin:djangocms_page_sitemap_pagesitemapproperties_add'), ++ reverse("admin:djangocms_page_sitemap_pagesitemapproperties_add"), + self.page.pk) + except NoReverseMatch: # pragma: no cover + # not in urls +diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py +index 50611dc..83bc1e0 100644 +--- a/djangocms_page_sitemap/models.py ++++ b/djangocms_page_sitemap/models.py +@@ -14,29 +14,29 @@ + @extension_pool.register + class PageSitemapProperties(PageExtension): + changefreq = models.CharField( +- _('Change frequency'), max_length=20, default='monthly', ++ _("Change frequency"), max_length=20, default="monthly", + choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items() + ) + priority = models.DecimalField( +- _('Priority'), decimal_places=1, max_digits=2, default=0.5, ++ _("Priority"), decimal_places=1, max_digits=2, default=0.5, + validators=[MinValueValidator(0), MaxValueValidator(1)] + ) +- include_in_sitemap = models.BooleanField(_('Include in sitemap'), default=True) ++ include_in_sitemap = models.BooleanField(_("Include in sitemap"), default=True) + noindex = models.BooleanField( +- _('Mark as no index'), default=False, +- help_text=_('Add meta tag robots with value noindex') ++ _("Mark as no index"), default=False, ++ help_text=_("Add meta tag robots with value noindex") + ) + noarchive = models.BooleanField( +- _('Mark as no archive'), default=False, +- help_text=_('Add meta tag robots with value noarchive') ++ _("Mark as no archive"), default=False, ++ help_text=_("Add meta tag robots with value noarchive") + ) + robots_extra = models.CharField( +- _('Extra robots value'), default='', max_length=200, blank=True, +- help_text=_('Extra values for robots meta tag') ++ _("Extra robots value"), default='', max_length=200, blank=True, ++ help_text=_("Extra values for robots meta tag") + ) + + def __str__(self): +- return _('Sitemap values for Page %s') % self.extended_object.pk ++ return _("Sitemap values for Page %s") % self.extended_object.pk + + + # Cache cleanup when deleting pages / editing page extensions +diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py +index ca95dbd..5d3dca0 100644 +--- a/djangocms_page_sitemap/settings.py ++++ b/djangocms_page_sitemap/settings.py +@@ -4,18 +4,18 @@ + from django.utils.translation import ugettext_lazy as _ + + PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST = { +- 'always': _('always'), +- 'hourly': _('hourly'), +- 'daily': _('daily'), +- 'weekly': _('weekly'), +- 'monthly': _('monthly'), +- 'yearly': _('yearly'), +- 'never': _('never'), ++ "always": _("always"), ++ "hourly": _("hourly"), ++ "daily": _("daily"), ++ "weekly": _("weekly"), ++ "monthly": _("monthly"), ++ "yearly": _("yearly"), ++ "never": _("never"), + } + PAGE_SITEMAP_CHANGEFREQ_LIST = getattr( +- settings, 'PAGE_SITEMAP_CHANGEFREQ_LIST', PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST ++ settings, "PAGE_SITEMAP_CHANGEFREQ_LIST", PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST + ) + PAGE_SITEMAP_DEFAULT_CHANGEFREQ = getattr( +- settings, 'PAGE_SITEMAP_DEFAULT_CHANGEFREQ', CMSSitemap.changefreq ++ settings, "PAGE_SITEMAP_DEFAULT_CHANGEFREQ", CMSSitemap.changefreq + ) +-PAGE_SITEMAP_CACHE_DURATION = get_cms_setting('CACHE_DURATIONS')['menus'] ++PAGE_SITEMAP_CACHE_DURATION = get_cms_setting("CACHE_DURATIONS")["menus"] +diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py +index 8fd33ef..796a217 100644 +--- a/djangocms_page_sitemap/sitemap.py ++++ b/djangocms_page_sitemap/sitemap.py +@@ -20,7 +20,7 @@ def items(self): + site = get_current_site() + languages = get_public_languages(site_id=site.pk) + page_content_prefetch = Prefetch( +- 'page__pagecontent_set', ++ "page__pagecontent_set", + queryset=PageContent.objects.filter( + language__in=languages, + ) +@@ -37,7 +37,7 @@ def items(self): + page__node__site=site, + ) + .exclude(page__pagesitemapproperties__include_in_sitemap=False) +- .order_by('page__node__path') ++ .order_by("page__node__path") + ) + valid_urls = [] + for page_url in all_urls: +diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py +index b591de1..0225a6f 100644 +--- a/djangocms_page_sitemap/sitemap_urls.py ++++ b/djangocms_page_sitemap/sitemap_urls.py +@@ -1,8 +1,8 @@ +-from django.conf.urls import url + from django.contrib.sitemaps.views import sitemap ++from django.urls import re_path + + from .sitemap import ExtendedSitemap + + urlpatterns = [ +- url(r'^sitemap\.xml$', sitemap, {'sitemaps': {'cmspages': ExtendedSitemap}}), ++ re_path(r"^sitemap\.xml$", sitemap, {"sitemaps": {"cmspages": ExtendedSitemap}}), + ] +diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py +index 8aa03a9..8115534 100644 +--- a/djangocms_page_sitemap/templatetags/robots_index.py ++++ b/djangocms_page_sitemap/templatetags/robots_index.py +@@ -8,19 +8,19 @@ + register = template.Library() + + +-@register.tag(name='page_robots') ++@register.tag(name="page_robots") + class PageRobots(Tag): + """ + Generates the robots meta tag according to the extension attributes + """ +- name = 'page_robots' ++ name = "page_robots" + options = Options( +- Argument('page', required=False), +- Argument('site_id', required=False), ++ Argument("page", required=False), ++ Argument("site_id", required=False), + ) + + def render_tag(self, context, page, site_id): +- request = context.get('request') ++ request = context.get("request") + if not request: + return '' + if not site_id: +@@ -37,11 +37,11 @@ def render_tag(self, context, page, site_id): + return '' + try: + if page.pagesitemapproperties.noindex: +- content.append('noindex') ++ content.append("noindex") + if page.pagesitemapproperties.noarchive: +- content.append('noarchive') ++ content.append("noarchive") + if page.pagesitemapproperties.robots_extra: + content.append(page.pagesitemapproperties.robots_extra) +- return '' % ','.join(content) ++ return "" % ','.join(content) + except ObjectDoesNotExist: +- return '' ++ return "" +diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py +index 539253d..ecbc700 100644 +--- a/djangocms_page_sitemap/utils.py ++++ b/djangocms_page_sitemap/utils.py +@@ -10,13 +10,13 @@ def get_cache_key(page): + site_id = page.node.site_id + except AttributeError: + site_id = page.site_id +- return _get_cache_key('page_sitemap', page, 'default', site_id) ++ return _get_cache_key("page_sitemap", page, "default", site_id) + + + def is_versioning_enabled(): + from cms.models import PageContent + try: +- app_config = apps.get_app_config('djangocms_versioning') ++ app_config = apps.get_app_config("djangocms_versioning") + return app_config.cms_extension.is_content_model_versioned(PageContent) + except LookupError: + return False + +From a54ae9a06731938c88ea4f9d5b8fba7eca234431 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 10:00:27 +0000 +Subject: [PATCH 15/20] Fix missing secret key for the test suite + +--- + cms_helper.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/cms_helper.py b/cms_helper.py +index 0d61a7f..7fbacd6 100755 +--- a/cms_helper.py ++++ b/cms_helper.py +@@ -18,6 +18,7 @@ def gettext(s): + + + HELPER_SETTINGS = { ++ "SECRET_KEY": "djangocms-page-sitemap-test-suite-key", + "NOSE_ARGS": [ + "-s", + ], + +From f0a17c52a60b03fd234626b7b207d16764625cc4 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 10:16:54 +0000 +Subject: [PATCH 16/20] Fixed failing tests + +--- + tests/base.py | 21 +++------------------ + tests/test_toolbar.py | 6 +++--- + tests/test_utils/urls.py | 13 +++++++------ + 3 files changed, 13 insertions(+), 27 deletions(-) + +diff --git a/tests/base.py b/tests/base.py +index 2213f9c..aaaf6f1 100644 +--- a/tests/base.py ++++ b/tests/base.py +@@ -35,24 +35,9 @@ def get_pages(self): + create_title(language='fr', title='page un', page=page_1, created_by=self.user) + create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) + create_title(language='fr', title='page trois', page=page_3, created_by=self.user) +- page_content1 = create_title( +- title='pagecontent1_en', +- language='en', +- page=page_1, +- created_by=self.user +- ) +- page_content2 = create_title( +- title='pagecontent2_en', +- language='en', +- page=page_2, +- created_by=self.user +- ) +- page_content3 = create_title( +- title='pagecontent3_en', +- language='en', +- page=page_3, +- created_by=self.user +- ) ++ page_content1 = page_1.get_title_obj("en") ++ page_content2 = page_2.get_title_obj("en") ++ page_content3 = page_3.get_title_obj("en") + if is_versioning_enabled(): + page_content1.versions.first().publish(self.user) + page_content2.versions.first().publish(self.user) +diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py +index ee9f953..d1cd7eb 100644 +--- a/tests/test_toolbar.py ++++ b/tests/test_toolbar.py +@@ -6,7 +6,7 @@ + from django.test.utils import override_settings + from django.urls import reverse + from django.utils.encoding import force_text +-from django.utils.translation import ugettext_lazy as _ ++from django.utils.translation import gettext_lazy as _ + + from djangocms_page_sitemap.cms_toolbars import PAGE_SITEMAP_MENU_TITLE + from djangocms_page_sitemap.models import PageSitemapProperties +@@ -147,8 +147,8 @@ def test_toolbar_buttons_are_not_duplicated(self): + + user = self.get_superuser() + page_1 = create_page('page-one', 'page.html', language='en', created_by=user) +- page_content = create_title(title='pagecontent1', language='en', page=page_1, +- created_by=user) ++ page_content = page_1.get_title_obj("en") ++ + if is_versioning_enabled(): + page_content.versions.first().publish(user) + preview_endpoint = get_object_preview_url(page_content, language='en') +diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py +index a9c2894..2f4a837 100644 +--- a/tests/test_utils/urls.py ++++ b/tests/test_utils/urls.py +@@ -1,26 +1,27 @@ + from cms.utils.conf import get_cms_setting + from django.conf import settings +-from django.conf.urls import include, url + from django.conf.urls.i18n import i18n_patterns + from django.contrib import admin + from django.contrib.staticfiles.urls import staticfiles_urlpatterns + from django.views.static import serve ++from django.urls import include, re_path + + from djangocms_page_sitemap import sitemap_urls + ++ + admin.autodiscover() + + urlpatterns = [ +- url(r'^media/(?P.*)$', serve, ++ re_path(r'^media/(?P.*)$', serve, + {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), +- url(r'^media/cms/(?P.*)$', serve, ++ re_path(r'^media/cms/(?P.*)$', serve, + {'document_root': get_cms_setting('MEDIA_ROOT'), 'show_indexes': True}), +- url(r'^', include(sitemap_urls)), ++ re_path(r'^', include(sitemap_urls)), + ] + + urlpatterns += staticfiles_urlpatterns() + + urlpatterns += i18n_patterns( +- url(r'^admin/', admin.site.urls), +- url(r'^', include('cms.urls')), ++ re_path(r'^admin/', admin.site.urls), ++ re_path(r'^', include('cms.urls')), + ) + +From 2d4c09e44b70ce875a091620c398d5c2c77838bb Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 10:18:26 +0000 +Subject: [PATCH 17/20] Fix deprecation notices + +--- + djangocms_page_sitemap/models.py | 2 +- + tests/base.py | 2 +- + tests/test_toolbar.py | 16 ++++++++-------- + 3 files changed, 10 insertions(+), 10 deletions(-) + +diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py +index 83bc1e0..ee15911 100644 +--- a/djangocms_page_sitemap/models.py ++++ b/djangocms_page_sitemap/models.py +@@ -5,7 +5,7 @@ + from django.db import models + from django.db.models.signals import post_save, pre_delete + from django.dispatch import receiver +-from django.utils.translation import ugettext_lazy as _ ++from django.utils.translation import gettext_lazy as _ + + from .settings import PAGE_SITEMAP_CHANGEFREQ_LIST + from .utils import get_cache_key +diff --git a/tests/base.py b/tests/base.py +index aaaf6f1..abf4c2e 100644 +--- a/tests/base.py ++++ b/tests/base.py +@@ -71,7 +71,7 @@ def get_page_request(self, page, user, path=None, edit=False, lang_code='en'): + else: + request.GET = {'edit_off': None} + request.current_page = page +- mid = ToolbarMiddleware() ++ mid = ToolbarMiddleware(request) + mid.process_request(request) + return request + +diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py +index d1cd7eb..764b9dd 100644 +--- a/tests/test_toolbar.py ++++ b/tests/test_toolbar.py +@@ -5,7 +5,7 @@ + from django.contrib.auth.models import Permission, User + from django.test.utils import override_settings + from django.urls import reverse +-from django.utils.encoding import force_text ++from django.utils.encoding import force_str + from django.utils.translation import gettext_lazy as _ + + from djangocms_page_sitemap.cms_toolbars import PAGE_SITEMAP_MENU_TITLE +@@ -70,11 +70,11 @@ def test_perm(self): + page_menu = toolbar.menus['page'] + try: + self.assertEqual( +- len(page_menu.find_items(ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 ++ len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 + ) + except AssertionError: + self.assertEqual( +- len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 ++ len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 + ) + + @override_settings(CMS_PERMISSION=True) +@@ -104,11 +104,11 @@ def test_toolbar(self): + page_menu = toolbar.menus['page'] + try: + self.assertEqual( +- len(page_menu.find_items(ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 ++ len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 + ) + except AssertionError: + self.assertEqual( +- len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 ++ len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 + ) + + def test_toolbar_with_items(self): +@@ -125,14 +125,14 @@ def test_toolbar_with_items(self): + page_menu = toolbar.menus['page'] + try: + meta_menu = page_menu.find_items( +- ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE) ++ ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE) + )[0].item + except IndexError: + meta_menu = page_menu.find_items( +- ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE) ++ ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE) + )[0].item + self.assertTrue(meta_menu.url.startswith(reverse('admin:djangocms_page_sitemap_pagesitemapproperties_change', args=(page_ext.pk,)))) +- self.assertEqual(force_text(page_ext), force_text(_('Sitemap values for Page %s') % page1.pk)) ++ self.assertEqual(force_str(page_ext), force_str(_('Sitemap values for Page %s') % page1.pk)) + + + class VersioningToolbarTest(CMSTestCase): + +From 774ff10c7d0d20cdecc37b247e307c65ae375bcd Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 10:33:48 +0000 +Subject: [PATCH 18/20] Replace changelog entry with towncrier configuraton + +--- + HISTORY.rst | 7 ------- + tasks.py | 2 +- + 2 files changed, 1 insertion(+), 8 deletions(-) + +diff --git a/HISTORY.rst b/HISTORY.rst +index 9ff65de..61e02c1 100644 +--- a/HISTORY.rst ++++ b/HISTORY.rst +@@ -6,13 +6,6 @@ History + + .. towncrier release notes start + +-(unreleased) +-============ +- +-* Update tooling and ci test suite to Github Actions +-* Add compatibility with Django 3.2 +-* Drop compatibility with Django < 2.2 +- + 0.9.0.dev8 (2020-11-23) + ======================= + +diff --git a/tasks.py b/tasks.py +index 82261dd..02be157 100644 +--- a/tasks.py ++++ b/tasks.py +@@ -8,7 +8,7 @@ + + DOCS_PORT = os.environ.get("DOCS_PORT", 8000) + #: branch prefixes for which some checks are skipped +-SPECIAL_BRANCHES = ("master", "develop", "release") ++SPECIAL_BRANCHES = ("master", "develop", "release", "support/4.0.x") + + + @task + +From 2dfb2fc223200062d2c8fcd8808b315dcf390a75 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 11:35:45 +0000 +Subject: [PATCH 19/20] Fixed versioning tests + +--- + changes/910.feature | 3 +++ + cms_helper.py | 1 + + tests/base.py | 16 ++++++++++------ + tests/test_toolbar.py | 5 ++--- + 4 files changed, 16 insertions(+), 9 deletions(-) + create mode 100644 changes/910.feature + +diff --git a/changes/910.feature b/changes/910.feature +new file mode 100644 +index 0000000..9d140fd +--- /dev/null ++++ b/changes/910.feature +@@ -0,0 +1,3 @@ ++* Update tooling and ci test suite to Github Actions ++* Add compatibility with Django 3.2 ++* Drop compatibility with Django < 2.2 +diff --git a/cms_helper.py b/cms_helper.py +index 7fbacd6..9a78054 100755 +--- a/cms_helper.py ++++ b/cms_helper.py +@@ -38,6 +38,7 @@ def gettext(s): + "MIGRATION_MODULES": DisableMigrations(), + "INSTALLED_APPS": [ + "django.contrib.sitemaps", ++ 'djangocms_versioning', + ], + "LANGUAGE_CODE": "en", + "TIME_ZONE": "UTC", +diff --git a/tests/base.py b/tests/base.py +index abf4c2e..4f92837 100644 +--- a/tests/base.py ++++ b/tests/base.py +@@ -1,5 +1,6 @@ + from io import StringIO + ++from cms.models import PageContent + from cms.utils.i18n import get_language_list + from django.contrib.auth.models import User + from django.http import SimpleCookie +@@ -32,16 +33,19 @@ def get_pages(self): + page_1 = create_page('page one', 'page.html', language='en', created_by=self.user) + page_2 = create_page('page two', 'page.html', language='en', created_by=self.user) + page_3 = create_page('page three', 'page.html', language='en', created_by=self.user) +- create_title(language='fr', title='page un', page=page_1, created_by=self.user) +- create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) +- create_title(language='fr', title='page trois', page=page_3, created_by=self.user) +- page_content1 = page_1.get_title_obj("en") +- page_content2 = page_2.get_title_obj("en") +- page_content3 = page_3.get_title_obj("en") ++ page_1_content_fr = create_title(language='fr', title='page un', page=page_1, created_by=self.user) ++ page_1_content_it = create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) ++ page_3_content_fr = create_title(language='fr', title='page trois', page=page_3, created_by=self.user) ++ page_content1 = PageContent._original_manager.get(page=page_1, language="en") ++ page_content2 = PageContent._original_manager.get(page=page_2, language="en") ++ page_content3 = PageContent._original_manager.get(page=page_3, language="en") + if is_versioning_enabled(): + page_content1.versions.first().publish(self.user) + page_content2.versions.first().publish(self.user) + page_content3.versions.first().publish(self.user) ++ page_1_content_fr.versions.first().publish(self.user) ++ page_1_content_it.versions.first().publish(self.user) ++ page_3_content_fr.versions.first().publish(self.user) + if hasattr(page_1, 'set_as_homepage'): + page_1.set_as_homepage() + +diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py +index 764b9dd..4a58273 100644 +--- a/tests/test_toolbar.py ++++ b/tests/test_toolbar.py +@@ -1,4 +1,5 @@ + from cms.api import create_page ++from cms.models import PageContent + from cms.test_utils.testcases import CMSTestCase + from cms.toolbar.items import Menu, ModalItem + from cms.toolbar.utils import get_object_preview_url +@@ -143,11 +144,9 @@ def test_toolbar_buttons_are_not_duplicated(self): + + This test Can be ran with or without versioning and should return the same result! + """ +- from cms.api import create_title +- + user = self.get_superuser() + page_1 = create_page('page-one', 'page.html', language='en', created_by=user) +- page_content = page_1.get_title_obj("en") ++ page_content = PageContent._original_manager.get(page=page_1, language="en") + + if is_versioning_enabled(): + page_content.versions.first().publish(user) + +From acc9942b4f9fd11e29164da5bcad2dd3c543ee58 Mon Sep 17 00:00:00 2001 +From: Andrew Aikman +Date: Wed, 22 Dec 2021 12:05:19 +0000 +Subject: [PATCH 20/20] Requirements added + +--- + requirements-test.txt | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/requirements-test.txt b/requirements-test.txt +index 4f6ebe2..51fb298 100644 +--- a/requirements-test.txt ++++ b/requirements-test.txt +@@ -3,3 +3,5 @@ coverage>5 + coveralls>2 + mock>=1.0.1 + django-app-helper>=2.0.0 ++ ++https://github.com/Aiky30/djangocms-versioning/tarball/feature/django-32-compat#egg=djangocms-versioning diff --git a/README.rst b/README.rst index 211fe7d..c260223 100644 --- a/README.rst +++ b/README.rst @@ -8,23 +8,23 @@ django CMS page extension to handle sitemap customization Support Python version: -* Python 2.7, 3.5, 3.6, 3.7 +* Python 3.7, 3.8, 3.9, 3.10 Supported Django versions: -* Django 1.11 to 2.2 +* Django 2.2, 3.2 Supported django CMS versions: -* django CMS 3.6+ +* django CMS 3.7 - 3.10 .. note:: djangocms-page-sitemap 0.8 has been relicensed with BSD license. -.. note:: djangocms-page-sitemap 0.7 dropped compatibility with django CMS < 3.6. 0.6.x releases will be made if necessary after 0.6 release. - +.. note:: djangocms-page-sitemap 1.0 dropped compatibility with Python 2 and Django < 2.2 +******** Features --------- +******** * Support for changefreq and priority customisation per-page * Option to exclude a page from the Sitemap @@ -33,78 +33,91 @@ Features * Available on Divio Cloud +********** Quickstart ----------- +********** * Install djangocms-page-sitemap:: pip install djangocms-page-sitemap -* Add to ``INSTALLED_APPS`` with ``django.contrib.sitemaps``:: - - INSTALLED_APPS = [ - ... - 'django.contrib.sitemaps', - 'djangocms_page_sitemap', - ] +* Add to ``INSTALLED_APPS`` with ``django.contrib.sitemaps``: -* Add to the urlconf, eventually removing django CMS sitemap:: + .. code-block:: python + INSTALLED_APPS = [ + ... + "django.contrib.sitemaps", + "djangocms_page_sitemap", + ] - from djangocms_page_sitemap import sitemap_urls +* Load it into the urlconf, eventually removing django CMS sitemap: - ... + .. code-block:: python - urlpatterns = [ - url(r'^admin/', include(admin.site.urls)), ... - url(r'^', include(sitemap_urls)), - ... - ] + urlpatterns = [ + path("admin/", admin.site.urls), + ... + path("", include("djangocms_page_sitemap.sitemap_urls")), + ... + ] + +* Load ``robots_index`` templatetag and add it to the page in the head tag of the django CMS pages (or in a shared base template): -* Add the following snippets to the django CMS templates:: + .. code-block:: html+django - {% load robots_index %} + {% load robots_index %} - ... - - - {% page_robots %} - - ... + ... + + + {% page_robots %} + + ... * If you need to provide a custom sitemap configuration (for example to add more - sitemap classes to it, you can append the sitemap url explicitly:: + sitemap classes to it, you can append the sitemap url explicitly: - from django.contrib.sitemaps.views import sitemap - from djangocms_page_sitemap.sitemap import ExtendedSitemap - from myapp.sitemaps import MySiteSitemap + .. code-block:: python + from django.contrib.sitemaps.views import sitemap + from djangocms_page_sitemap.sitemap import ExtendedSitemap + from myapp.sitemaps import MySiteSitemap - urlpatterns = patterns( - '', - ... - url(r'^sitemap\.xml$', sitemap, - {'sitemaps': { - 'cmspages': ExtendedSitemap, 'myapp': MySiteSitemap, - } - }), - ) + urlpatterns = [ + ... + path("sitemap.xml", sitemap, { + "sitemaps": { + "cmspages": ExtendedSitemap, "myapp": MySiteSitemap, + } + ), + ... + ] + + +************************** +django-app-enabler support +************************** + +`django-app-enabler`_ is supported. + +You can either +* Installation & configuration: ``python -mapp_enabler install djangocms-page-meta`` +* Autoconfiguration: ``python -mapp_enabler enable djangocms_page_meta`` -* Add the following snippets to the django CMS templates:: +Fully using this package will require some changes that cannot be modified by ``django-app-enabler``: - {% load robots_index %} +* Remove any existing sitemap declaration from ``urls.py``; +* Load robots tags in the page like outlined above; +* Run migrations: ``python manage.py migrate`` - ... - - - {% page_robots %} - - ... +Check documentation above for details. +********** Usage ------ +********** After installing as above, you will be able to tune the sitemap setting for each page. @@ -116,11 +129,11 @@ For each page you will be able to set the following flags / values: * Sitemap priority (default: 0.5) * Include page in sitemap (default: ``True``) * Set ``noindex`` value to page robots meta tag -* Set ``noarchite`` value to page robots meta tag +* Set ``noarchive`` value to page robots meta tag * Provide any additional robots meta tag values page_robots options -------------------- +=================== ``page_robots`` meta tag accepts the following parameters: @@ -129,7 +142,7 @@ page_robots options * ``site``: the current site id (default: current site). Settings --------- +=================== * PAGE_SITEMAP_CHANGEFREQ_LIST: List of frequency changes * PAGE_SITEMAP_DEFAULT_CHANGEFREQ: Default changefrequency (default: django CMS value -monthly-) @@ -137,6 +150,7 @@ Settings .. _page lookup: https://docs.django-cms.org/en/reference/templatetags.html#page_lookup +.. _django-app-enabler: https://github.com/nephila/django-app-enabler .. |Gitter| image:: https://img.shields.io/badge/GITTER-join%20chat-brightgreen.svg?style=flat-square diff --git a/addon.json b/addon.json deleted file mode 100644 index dcd68f5..0000000 --- a/addon.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "package-name": "djangocms-page-sitemap", - "installed-apps": [ - "djangocms_page_sitemap" - ] -} diff --git a/addon.json b/addon.json new file mode 120000 index 0000000..de741f0 --- /dev/null +++ b/addon.json @@ -0,0 +1 @@ +djangocms_page_sitemap/addon.json \ No newline at end of file diff --git a/aldryn_config.py b/aldryn_config.py index e8d0bb0..195fca4 100644 --- a/aldryn_config.py +++ b/aldryn_config.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- try: from divio_cli import forms except ImportError: @@ -18,11 +17,10 @@ class Form(forms.BaseForm): PAGE_SITEMAP_DEFAULT_CHANGEFREQ = forms.SelectField( "Default changefrequency (default: django CMS value -monthly-)", - choices=PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST.items(), + choices=list(PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST.items()), ) PAGE_SITEMAP_CACHE_DURATION = forms.CharField( - "Cache duration (default: same as django CMS menu cache)", - required=False + "Cache duration (default: same as django CMS menu cache)", required=False ) def to_settings(self, data, settings): diff --git a/changes/.directory b/changes/.directory new file mode 100644 index 0000000..e69de29 diff --git a/cms_helper.py b/cms_helper.py index 9a78054..adf8378 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -1,16 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - -import sys - - -class DisableMigrations(object): - def __contains__(self, item): - return True - - def __getitem__(self, item): - return None def gettext(s): @@ -18,10 +6,6 @@ def gettext(s): HELPER_SETTINGS = { - "SECRET_KEY": "djangocms-page-sitemap-test-suite-key", - "NOSE_ARGS": [ - "-s", - ], "CACHES": { "default": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", @@ -33,12 +17,9 @@ def gettext(s): "permissions": 10, }, "ROOT_URLCONF": "tests.test_utils.urls", - # FIXME: Django CMS migrtions with Django 2.2 produce an error when - # running tests, temporarily disabling migrations - "MIGRATION_MODULES": DisableMigrations(), "INSTALLED_APPS": [ "django.contrib.sitemaps", - 'djangocms_versioning', + "djangocms_versioning", ], "LANGUAGE_CODE": "en", "TIME_ZONE": "UTC", @@ -69,17 +50,20 @@ def gettext(s): "hide_untranslated": False, }, }, - } def run(): from app_helper import runner + runner.cms("djangocms_page_sitemap") def setup(): + import sys + from app_helper import runner + runner.setup("djangocms_page_sitemap", sys.modules[__name__], use_cms=True) diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 466ef04..73462a9 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,2 +1,2 @@ -__version__ = "0.9.0.dev8" # pragma: no cover -__author__ = "Iacopo Spalletti " # pragma: no cover +__version__ = "1.2.0" +__author__ = "Iacopo Spalletti " diff --git a/djangocms_page_sitemap/addon.json b/djangocms_page_sitemap/addon.json new file mode 100644 index 0000000..56d7bc6 --- /dev/null +++ b/djangocms_page_sitemap/addon.json @@ -0,0 +1,12 @@ +{ + "package-name": "djangocms-page-sitemap", + "installed-apps": [ + "django.contrib.sitemaps", + "djangocms_page_sitemap" + ], + "settings": {}, + "urls": [ + ["", "djangocms_page_sitemap.sitemap_urls"] + ], + "message": "Installation completed, please setup your templates according to the documentation: https://djangocms-page-sitemap.readthedocs.io/en/latest/" +} diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py index 498e745..17f656a 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -2,7 +2,7 @@ from cms.utils.conf import get_cms_setting from cms.utils.permissions import has_page_permission from django.urls import NoReverseMatch, reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from .models import PageSitemapProperties @@ -32,10 +32,7 @@ def populate(self): else: has_global_current_page_change_permission = False # check if user has page edit permission - can_change = ( - self.request.current_page and - self.request.current_page.has_change_permission(self.request.user) - ) + can_change = self.request.current_page and self.request.current_page.has_change_permission(self.request.user) if has_global_current_page_change_permission or can_change: not_edit_mode = not self.toolbar.edit_mode_active current_page_menu = self.toolbar.get_or_create_menu("page") @@ -46,16 +43,15 @@ def populate(self): page_extension = None try: if page_extension: - url = reverse("admin:djangocms_page_sitemap_pagesitemapproperties_change", - args=(page_extension.pk,)) + url = reverse( + "admin:djangocms_page_sitemap_pagesitemapproperties_change", args=(page_extension.pk,) + ) else: - url = "%s?extended_object=%s" % ( - reverse("admin:djangocms_page_sitemap_pagesitemapproperties_add"), - self.page.pk) + url = "{}?extended_object={}".format( + reverse("admin:djangocms_page_sitemap_pagesitemapproperties_add"), self.page.pk + ) except NoReverseMatch: # pragma: no cover # not in urls pass else: - current_page_menu.add_modal_item( - PAGE_SITEMAP_MENU_TITLE, url=url, disabled=not_edit_mode - ) + current_page_menu.add_modal_item(PAGE_SITEMAP_MENU_TITLE, url=url, disabled=not_edit_mode) diff --git a/djangocms_page_sitemap/locale/ar/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/ar/LC_MESSAGES/django.mo index c9227ec0d307d9173e3747cd8ac87decbc9830aa..0853034a6ba07c730ab28ac99bd0971b4707c9f6 100644 GIT binary patch delta 117 zcmdnRIgxWhOX@{N28KOAtir&+(8tWcpb4Zm18D&ueHTb80qJ)@+7w6&vM?}k0cm$2 l%>kr?fHW_Vj)w9xp>z?D<^hUVL-`#WUy3ts)?}K<1OTbg4wnD` delta 156 zcmbQpxr=i`OX@F128KOAtir&+u$`HKK@&*d0n!3MnvI2lK?z8U18GwrZ3U#cfOG+n z<^a;wK$;gww?O%mp!94Y%>xu)0_AVq_)?rvEkxJ3C^fMpGe1w)C9x#cO2Np$&{WsZ YK-bVh!O+yo#8TV9$iQIpU&bj+0H6ICYXATM diff --git a/djangocms_page_sitemap/locale/ar/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/ar/LC_MESSAGES/django.po index acefd61..720687b 100644 --- a/djangocms_page_sitemap/locale/ar/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/ar/LC_MESSAGES/django.po @@ -1,7 +1,7 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# +# # Translators: # Bashar Al-Abdulhadi, 2016 msgid "" diff --git a/djangocms_page_sitemap/locale/de/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/de/LC_MESSAGES/django.mo index 25c9bf9d959120a56fe1fb8f622a82ecfe8f5d84..81184519636e60696c4559a173f69fe1121ed834 100644 GIT binary patch delta 118 zcmbQu@rivxOIkA{1H&F57GhvvaA0O&5CPJ`K$;6kX8>tYAYBZkm4S38kmd%`Yk@Qe pklqQTLFx_xX-*)07DxjT!*w9R1Eg<5#a}RQd?m)XS(E7#BLIss5Gw!x delta 157 zcmeywKAU4gOWGPn28KOAEX2UTkjc!zAOfUofHW77o(QBxf%F_8tqi0$0cma^eGN!+ z0O?0S8l>(ukmdx^-+(j_F)*+&Fz|pVAPo{1WZC#ij8QE_*SRP)u_QA;PuC@}B-Kj6 e$iUE4*U&)M&_cn`)XKzC+rY@cVDn$buZ#fiAQ}Jw diff --git a/djangocms_page_sitemap/locale/de/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/de/LC_MESSAGES/django.po index 526b29c..0fb0f7a 100644 --- a/djangocms_page_sitemap/locale/de/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/de/LC_MESSAGES/django.po @@ -1,7 +1,7 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# +# # Translators: # fsbraun , 2016 msgid "" diff --git a/djangocms_page_sitemap/locale/en/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/en/LC_MESSAGES/django.mo index 3ed85f98d222ca60b7a61f590b068de9c19b2dab..a780eeb09382dadabab6ceb3acb1244efe454265 100644 GIT binary patch literal 1458 zcmeH_O=}b}7{^DgZ|iHTCsBxk+9I>FTPT*PD{9?Bv5QMxdrxPwGwIGIW0HLXLGY#^ zp6t<+2gR!&K*5^_@#aZ-@*sH958yxDY+FI-7w}>K^UL#0lINeDe47}1;UP{zXQ6k{ zIcRAQ9*FngB=`Zm1pWX|g5!HVZvwmk5^%=lD~=qr^B#hSz-O+$4xT~&20Q?M1owlV zT>b?-i2SRoZ@Bt*$DiO+c=!!kUysIyzFvd2-)GSJ+5ido%jKuh#MUo^c3uctUw2%+ z0a{-PXnj2f@$;Uz{5fcSt-Jb5SAXUB7KE*>uzT2kMo6iDRZ+^j%-eM$7cuL5 z^C=YxBTdB~beM<+UbSx&9qqiisVi-cHEBvUdOPyrEs7}X#Efu3G&ihGbFW5Ki%<ynDk%Bv&$L%5bK)N;|sNDU4p!9?g1mpuL##Y~ZD`qky&)CItoS zGUfFcYatmhYTwnBTw{^(7h`{gDb1w_NxX(*%c!mW9J~6?bzzz1QW?Ld6CV4wI*Ilh zG9-oiU4NN%xn1htriO)Nx>TO^OVfVoDu&@q`AP{nNJ}3sSXpNJPGw>dN#S84fFxf}F3A^3+^m_e(jt LEB|lr==S~rXlQ_5 delta 277 zcmdnQ{fjB)o)F7a1|VPrVi_P-0b*t#)&XJ=umEBQprj>`2C0FAfTH}Y)Z`Lf&lKIT z)S}|d{5&g#07qwUM|W3+FxQ}9Pk+D3a?DcoA-c{*sfi^(d0m&pl2j`NBLhQIT|)z1 zLkk5%Gb=*_Z380%1Fisn-JsO6OprNHb&;-)LAt*Fx-O0i9{yIop4w6Vey&_TiNz(l zAw`LK#W{&3`9)R=ZlOLt3Vx2ht_n7;zK)(g4vsD^L9W5Uc0i?h>7|;9>8ZLQsfoE( j3O\n" +"Last-Translator: yakky \n" "Language-Team: English (http://www.transifex.com/nephila/djangocms-page-sitemap/language/en/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/djangocms_page_sitemap/locale/es/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/es/LC_MESSAGES/django.mo index 9dbe7536b59c48d74e6c5466c82e535c8f10c2cb..b0ee8837f6ab2cf20ae29eb3846ed25337bb52db 100644 GIT binary patch delta 15 WcmaFMe1v&|3S-wq)rgJD+!+Bc_XVT? delta 54 zcmX@Y{FZrw3ghO9su5}-y3R$Zi6xo&dAcr%C8<^lMh1qax`qb2h87BjrdB4F+6G1j J1{\n" +"Last-Translator: yakky \n" "Language-Team: Spanish (http://www.transifex.com/nephila/djangocms-page-sitemap/language/es/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.mo index 85fff05a0bace86cb4b7a10ea0dcea5bc2cd3245..72f188d772d7989c79bbdb3a64549fddfce3f04f 100644 GIT binary patch delta 118 zcmZ3-(aJHQC9R8*fng623o$S-xHB^_hyv*-APwRd0BH#z-3+8vf%F_8%?6|o0cma^ peG*7>0O_khniELh1JXdm@B&Ei0qHkT@!!lFUx_hp)?{L30sxBK53m3L delta 157 zcmZqWSjRD;C2cb!1H&F57GhvvC}3t_5CziBKpMoK38W=}^cog(RD6LO)SaG&(n2DEJ?Le fFfuSS)ipHGHMCGLG_^9Z)HX0OFxdQ;k%I{UwM-a> diff --git a/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po index 7c40d93..f694a08 100644 --- a/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po @@ -1,16 +1,16 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# +# # Translators: -# yakky , 2015 +# yakky , 2015 msgid "" msgstr "" "Project-Id-Version: djangocms-page-sitemap\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-10-18 15:49+0200\n" "PO-Revision-Date: 2015-10-18 13:54+0000\n" -"Last-Translator: yakky \n" +"Last-Translator: yakky \n" "Language-Team: Italian (http://www.transifex.com/nephila/djangocms-page-sitemap/language/it/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/djangocms_page_sitemap/locale/lt/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/lt/LC_MESSAGES/django.mo index 6414dafd69058eb52338b7e203f75efe67b21a8c..1d2ce19ac768901050143f0677748e83019f2a4f 100644 GIT binary patch delta 117 zcmZqYyvH%2CG|Wb1H&F57Gz*x=wW7HkOR{5fHXId-V5cQ1kzeS{tF<@2Bd{q7#O&K lv=or$0n(~a+6YLq1Nrt)zB`cS1oA^Rz7%KNtjQF|1OSQz4Nw38 delta 156 zcmcb|(at%cCG`g*1H&F57Gz*x*vibnAP1z618Hs`{S3, 2015 msgid "" diff --git a/djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.mo index 2a50268267ad81686d63e1411e567020163497c7..8651ff6f5d1f2ed7b2d6ea250cf8461019f1bd36 100644 GIT binary patch delta 15 Xcmeyze3f~E3ghgFsu3HPMKA&YGJOT; delta 54 zcmcc0{EvBp3geN9su5}-y3R$Zi6xo&dAcr%C8<^lMh1qax`qb2h87BjrdB4F+6G1j J1{\n" +"Last-Translator: yakky \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/nephila/djangocms-page-sitemap/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/djangocms_page_sitemap/locale/ru/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/ru/LC_MESSAGES/django.mo index 46d54dca9f13b1ffbc7941694e3cb900836d8077..677541b4c65651c716779bae019c480e9512b22d 100644 GIT binary patch delta 117 zcmdnTHI-{ZOR6vv1H&Fh1_nh228IjF3=En;`V){A0@5-p3=C>OS|3O|0_iXy%>$%o r0BMl?QXnk=q;~*m5g>gMNb>>ddq7$YNWX>3vuu1R&bV2VNt77?fH@AX delta 156 zcmbQrwU28;OR5bM1H&Fh1_nh228N%^3=En;TAGD{K?q2@0%su_V<> f!N|bSRM*fz*U&=2(A3JrQrp1Dz+m%VMhRvBd$SmW diff --git a/djangocms_page_sitemap/locale/ru/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/ru/LC_MESSAGES/django.po index 3ccc6dc..9aa9159 100644 --- a/djangocms_page_sitemap/locale/ru/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/ru/LC_MESSAGES/django.po @@ -1,7 +1,7 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# +# # Translators: # Rustam Mirzaev , 2015 msgid "" diff --git a/djangocms_page_sitemap/locale/tr/LC_MESSAGES/django.mo b/djangocms_page_sitemap/locale/tr/LC_MESSAGES/django.mo index 8b39fe280c8af184993c8e0d0c570d02e80e3a3c..c3749dfa9c97ef72cc6f6dfe067aa411e1264d13 100644 GIT binary patch delta 15 WcmaFEe3*HH3S;L))rgJD+!z5b(FLFY delta 54 zcmX@i{Dygg3gf1Usu5}-y3R$Zi6xo&dAcr%C8<^lMh1qax`qb2h87BjrdB4F+6G1j J1{\n" +"Last-Translator: yakky \n" "Language-Team: Turkish (http://www.transifex.com/nephila/djangocms-page-sitemap/language/tr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py index 6d9f90a..6eacdb7 100644 --- a/djangocms_page_sitemap/migrations/0001_initial.py +++ b/djangocms_page_sitemap/migrations/0001_initial.py @@ -6,21 +6,59 @@ class Migration(migrations.Migration): dependencies = [ - ('cms', '__first__'), + ("cms", "__first__"), ] operations = [ migrations.CreateModel( - name='PageSitemapProperties', + name="PageSitemapProperties", fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('changefreq', models.CharField(max_length=20, verbose_name='Change frequency', choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items())), - ('priority', models.DecimalField(verbose_name='Priority', max_digits=2, decimal_places=1, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(1)])), - ('extended_object', models.OneToOneField(editable=False, to='cms.Page', on_delete=models.CASCADE)), - ('public_extension', models.OneToOneField(related_name='draft_extension', null=True, editable=False, to='djangocms_page_sitemap.PageSitemapProperties', on_delete=models.CASCADE)), + ( + "id", + models.AutoField( + verbose_name="ID", + serialize=False, + auto_created=True, + primary_key=True, + ), + ), + ( + "changefreq", + models.CharField( + max_length=20, + verbose_name="Change frequency", + choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items(), + ), + ), + ( + "priority", + models.DecimalField( + verbose_name="Priority", + max_digits=2, + decimal_places=1, + validators=[ + django.core.validators.MinValueValidator(0), + django.core.validators.MaxValueValidator(1), + ], + ), + ), + ( + "extended_object", + models.OneToOneField(editable=False, to="cms.Page", on_delete=models.CASCADE), + ), + ( + "public_extension", + models.OneToOneField( + related_name="draft_extension", + null=True, + editable=False, + to="djangocms_page_sitemap.PageSitemapProperties", + on_delete=models.CASCADE, + ), + ), ], options={ - 'abstract': False, + "abstract": False, }, ), ] diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py index dd47306..c66a309 100644 --- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py @@ -4,20 +4,23 @@ class Migration(migrations.Migration): - dependencies = [ - ('djangocms_page_sitemap', '0001_initial'), + ("djangocms_page_sitemap", "0001_initial"), ] operations = [ migrations.AddField( - model_name='pagesitemapproperties', - name='include_in_sitemap', - field=models.BooleanField(default=True, verbose_name='Include in sitemap'), + model_name="pagesitemapproperties", + name="include_in_sitemap", + field=models.BooleanField(default=True, verbose_name="Include in sitemap"), ), migrations.AlterField( - model_name='pagesitemapproperties', - name='changefreq', - field=models.CharField(max_length=20, choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items(), verbose_name='Change frequency'), + model_name="pagesitemapproperties", + name="changefreq", + field=models.CharField( + max_length=20, + choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items(), + verbose_name="Change frequency", + ), ), ] diff --git a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py index f463f2f..1c7a339 100644 --- a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py +++ b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py @@ -5,20 +5,33 @@ class Migration(migrations.Migration): - dependencies = [ - ('djangocms_page_sitemap', '0002_auto_20151018_1451'), + ("djangocms_page_sitemap", "0002_auto_20151018_1451"), ] operations = [ migrations.AlterField( - model_name='pagesitemapproperties', - name='changefreq', - field=models.CharField(max_length=20, verbose_name='Change frequency', default='monthly', choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items()), + model_name="pagesitemapproperties", + name="changefreq", + field=models.CharField( + max_length=20, + verbose_name="Change frequency", + default="monthly", + choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items(), + ), ), migrations.AlterField( - model_name='pagesitemapproperties', - name='priority', - field=models.DecimalField(max_digits=2, decimal_places=1, default=0.5, verbose_name='Priority', validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(1)]), + model_name="pagesitemapproperties", + name="priority", + field=models.DecimalField( + max_digits=2, + decimal_places=1, + default=0.5, + verbose_name="Priority", + validators=[ + django.core.validators.MinValueValidator(0), + django.core.validators.MaxValueValidator(1), + ], + ), ), ] diff --git a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py index af89883..43f3da0 100644 --- a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py +++ b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py @@ -1,27 +1,40 @@ # Generated by Django 1.10.8 on 2018-02-02 09:44 + from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('djangocms_page_sitemap', '0003_auto_20151018_1612'), + ("djangocms_page_sitemap", "0003_auto_20151018_1612"), ] operations = [ migrations.AddField( - model_name='pagesitemapproperties', - name='noarchive', - field=models.BooleanField(default=False, help_text='Add meta tag robots with value noarchive', verbose_name='Mark as no archive'), + model_name="pagesitemapproperties", + name="noarchive", + field=models.BooleanField( + default=False, + help_text="Add meta tag robots with value noarchive", + verbose_name="Mark as no archive", + ), ), migrations.AddField( - model_name='pagesitemapproperties', - name='noindex', - field=models.BooleanField(default=False, help_text='Add meta tag robots with value noindex', verbose_name='Mark as no index'), + model_name="pagesitemapproperties", + name="noindex", + field=models.BooleanField( + default=False, + help_text="Add meta tag robots with value noindex", + verbose_name="Mark as no index", + ), ), migrations.AddField( - model_name='pagesitemapproperties', - name='robots_extra', - field=models.CharField(default='', help_text='Extra values for robots meta tag', max_length=200, verbose_name='Extra robots value'), + model_name="pagesitemapproperties", + name="robots_extra", + field=models.CharField( + default="", + help_text="Extra values for robots meta tag", + max_length=200, + verbose_name="Extra robots value", + ), ), ] diff --git a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py index 2e0d79f..22b9315 100644 --- a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py +++ b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py @@ -1,17 +1,23 @@ # Generated by Django 1.11.10 on 2018-03-24 09:50 + from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ - ('djangocms_page_sitemap', '0004_auto_20180202_1044'), + ("djangocms_page_sitemap", "0004_auto_20180202_1044"), ] operations = [ migrations.AlterField( - model_name='pagesitemapproperties', - name='robots_extra', - field=models.CharField(blank=True, default='', help_text='Extra values for robots meta tag', max_length=200, verbose_name='Extra robots value'), + model_name="pagesitemapproperties", + name="robots_extra", + field=models.CharField( + blank=True, + default="", + help_text="Extra values for robots meta tag", + max_length=200, + verbose_name="Extra robots value", + ), ), ] diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index ee15911..15db55a 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -14,25 +14,28 @@ @extension_pool.register class PageSitemapProperties(PageExtension): changefreq = models.CharField( - _("Change frequency"), max_length=20, default="monthly", - choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items() + _("Change frequency"), max_length=20, default="monthly", choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items() ) priority = models.DecimalField( - _("Priority"), decimal_places=1, max_digits=2, default=0.5, - validators=[MinValueValidator(0), MaxValueValidator(1)] + _("Priority"), + decimal_places=1, + max_digits=2, + default=0.5, + validators=[MinValueValidator(0), MaxValueValidator(1)], ) include_in_sitemap = models.BooleanField(_("Include in sitemap"), default=True) noindex = models.BooleanField( - _("Mark as no index"), default=False, - help_text=_("Add meta tag robots with value noindex") + _("Mark as no index"), default=False, help_text=_("Add meta tag robots with value noindex") ) noarchive = models.BooleanField( - _("Mark as no archive"), default=False, - help_text=_("Add meta tag robots with value noarchive") + _("Mark as no archive"), default=False, help_text=_("Add meta tag robots with value noarchive") ) robots_extra = models.CharField( - _("Extra robots value"), default='', max_length=200, blank=True, - help_text=_("Extra values for robots meta tag") + _("Extra robots value"), + default="", + max_length=200, + blank=True, + help_text=_("Extra values for robots meta tag"), ) def __str__(self): diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py index 5d3dca0..09c1e72 100644 --- a/djangocms_page_sitemap/settings.py +++ b/djangocms_page_sitemap/settings.py @@ -1,7 +1,7 @@ from cms.sitemaps import CMSSitemap from cms.utils.conf import get_cms_setting from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST = { "always": _("always"), @@ -12,10 +12,6 @@ "yearly": _("yearly"), "never": _("never"), } -PAGE_SITEMAP_CHANGEFREQ_LIST = getattr( - settings, "PAGE_SITEMAP_CHANGEFREQ_LIST", PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST -) -PAGE_SITEMAP_DEFAULT_CHANGEFREQ = getattr( - settings, "PAGE_SITEMAP_DEFAULT_CHANGEFREQ", CMSSitemap.changefreq -) +PAGE_SITEMAP_CHANGEFREQ_LIST = getattr(settings, "PAGE_SITEMAP_CHANGEFREQ_LIST", PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST) +PAGE_SITEMAP_DEFAULT_CHANGEFREQ = getattr(settings, "PAGE_SITEMAP_DEFAULT_CHANGEFREQ", CMSSitemap.changefreq) PAGE_SITEMAP_CACHE_DURATION = get_cms_setting("CACHE_DURATIONS")["menus"] diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py index 796a217..6d368cb 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -23,21 +23,19 @@ def items(self): "page__pagecontent_set", queryset=PageContent.objects.filter( language__in=languages, - ) + ), ) all_urls = ( - PageUrl - .objects - .get_for_site(site) - .prefetch_related(page_content_prefetch) - .filter( + PageUrl.objects.get_for_site(site) + .prefetch_related(page_content_prefetch) + .filter( language__in=languages, path__isnull=False, page__login_required=False, page__node__site=site, ) - .exclude(page__pagesitemapproperties__include_in_sitemap=False) - .order_by("page__node__path") + .exclude(page__pagesitemapproperties__include_in_sitemap=False) + .order_by("page__node__path") ) valid_urls = [] for page_url in all_urls: @@ -55,7 +53,11 @@ def priority(self, title): return properties.priority else: try: - cache.set(ext_key, title.page.pagesitemapproperties, PAGE_SITEMAP_CACHE_DURATION) + cache.set( + ext_key, + title.page.pagesitemapproperties, + PAGE_SITEMAP_CACHE_DURATION, + ) return title.page.pagesitemapproperties.priority except PageSitemapProperties.DoesNotExist: return self.default_priority @@ -67,7 +69,11 @@ def changefreq(self, title): return properties.changefreq else: try: - cache.set(ext_key, title.page.pagesitemapproperties, PAGE_SITEMAP_CACHE_DURATION) + cache.set( + ext_key, + title.page.pagesitemapproperties, + PAGE_SITEMAP_CACHE_DURATION, + ) return title.page.pagesitemapproperties.changefreq except PageSitemapProperties.DoesNotExist: return self.default_changefreq diff --git a/djangocms_page_sitemap/templatetags/__init__.py b/djangocms_page_sitemap/templatetags/__init__.py index 8b13789..e69de29 100644 --- a/djangocms_page_sitemap/templatetags/__init__.py +++ b/djangocms_page_sitemap/templatetags/__init__.py @@ -1 +0,0 @@ - diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py index 8115534..e916e97 100644 --- a/djangocms_page_sitemap/templatetags/robots_index.py +++ b/djangocms_page_sitemap/templatetags/robots_index.py @@ -13,6 +13,7 @@ class PageRobots(Tag): """ Generates the robots meta tag according to the extension attributes """ + name = "page_robots" options = Options( Argument("page", required=False), @@ -22,7 +23,7 @@ class PageRobots(Tag): def render_tag(self, context, page, site_id): request = context.get("request") if not request: - return '' + return "" if not site_id: site_id = get_current_site(request).pk if not page: @@ -34,7 +35,7 @@ def render_tag(self, context, page, site_id): page = _get_page_by_untyped_arg(page, request, site_id) content = [] if not page: - return '' + return "" try: if page.pagesitemapproperties.noindex: content.append("noindex") @@ -42,6 +43,6 @@ def render_tag(self, context, page, site_id): content.append("noarchive") if page.pagesitemapproperties.robots_extra: content.append(page.pagesitemapproperties.robots_extra) - return "" % ','.join(content) + return '' % ",".join(content) except ObjectDoesNotExist: return "" diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py index ecbc700..78d61cf 100644 --- a/djangocms_page_sitemap/utils.py +++ b/djangocms_page_sitemap/utils.py @@ -15,6 +15,7 @@ def get_cache_key(page): def is_versioning_enabled(): from cms.models import PageContent + try: app_config = apps.get_app_config("djangocms_versioning") return app_config.cms_extension.is_content_model_versioned(PageContent) diff --git a/tasks.py b/tasks.py index 02be157..6b6c161 100644 --- a/tasks.py +++ b/tasks.py @@ -13,7 +13,7 @@ @task def clean(c): - """ Remove artifacts and binary files. """ + """Remove artifacts and binary files.""" c.run("python setup.py clean --all") patterns = ["build", "dist"] patterns.extend(glob("*.egg*")) @@ -25,19 +25,19 @@ def clean(c): @task def lint(c): - """ Run linting tox environments. """ + """Run linting tox environments.""" c.run("tox -epep8,isort,black,pypi-description") @task # NOQA def format(c): # NOQA - """ Run code formatting tasks. """ + """Run code formatting tasks.""" c.run("tox -eblacken,isort_format") @task def towncrier_check(c): # NOQA - """ Check towncrier files. """ + """Check towncrier files.""" output = io.StringIO() c.run("git branch --contains HEAD", out_stream=output) skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"] @@ -90,18 +90,20 @@ def towncrier_check(c): # NOQA @task def test(c): - """ Run test in local environment. """ + """Run test in local environment.""" c.run("python setup.py test") @task def test_all(c): + """Run all tox environments.""" """ Run all tox environments. """ c.run("tox") @task def coverage(c): + """Run test with coverage in local environment.""" """ Run test with coverage in local environment. """ c.run("coverage erase") c.run("run setup.py test") @@ -109,20 +111,24 @@ def coverage(c): @task -def tag_release(c, level): - """ Tag release version. """ - c.run("bumpversion --list %s --no-tag" % level) +def tag_release(c, level, new_version=""): + """Tag release version.""" + if new_version: + new_version = f" --new-version {new_version}" + c.run(f"bumpversion --list {level} --no-tag{new_version}") @task -def tag_dev(c, level="patch"): - """ Tag development version. """ - c.run("bumpversion --list %s --message='Bump develop version [ci skip]' --no-tag" % level) +def tag_dev(c, level="patch", new_version=""): + """Tag development version.""" + if new_version: + new_version = f" --new-version {new_version}" + c.run(f"bumpversion --list {level} --message='Bump develop version [ci skip]' --no-tag{new_version}") @task(pre=[clean]) def docbuild(c): - """ Build documentation. """ + """Build documentation.""" os.chdir("docs") build_dir = os.environ.get("BUILD_DIR", "_build/html") c.run("python -msphinx -W -b html -d _build/doctrees . %s" % build_dir) @@ -130,7 +136,7 @@ def docbuild(c): @task(docbuild) def docserve(c): - """ Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000). """ + """Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000).""" from livereload import Server server = Server() diff --git a/tests/__init__.py b/tests/__init__.py index 8b13789..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +0,0 @@ - diff --git a/tests/base.py b/tests/base.py index 4f92837..4bd60cd 100644 --- a/tests/base.py +++ b/tests/base.py @@ -3,7 +3,7 @@ from cms.models import PageContent from cms.utils.i18n import get_language_list from django.contrib.auth.models import User -from django.http import SimpleCookie +from django.http import HttpResponse, SimpleCookie from django.test import RequestFactory, TestCase from djangocms_page_sitemap.utils import is_versioning_enabled @@ -13,29 +13,31 @@ class BaseTest(TestCase): """ Base class with utility function """ + request_factory = None user = None languages = get_language_list() page_data = { - 'changefreq': 'never', - 'priority': '0.3', + "changefreq": "never", + "priority": "0.3", } @classmethod def setUpClass(cls): cls.request_factory = RequestFactory() - cls.user = User.objects.create(username='admin', is_staff=True, is_superuser=True) - cls.user_staff = User.objects.create(username='staff', is_staff=True) - cls.user_normal = User.objects.create(username='normal') + cls.user = User.objects.create(username="admin", is_staff=True, is_superuser=True) + cls.user_staff = User.objects.create(username="staff", is_staff=True) + cls.user_normal = User.objects.create(username="normal") def get_pages(self): from cms.api import create_page, create_title - page_1 = create_page('page one', 'page.html', language='en', created_by=self.user) - page_2 = create_page('page two', 'page.html', language='en', created_by=self.user) - page_3 = create_page('page three', 'page.html', language='en', created_by=self.user) - page_1_content_fr = create_title(language='fr', title='page un', page=page_1, created_by=self.user) - page_1_content_it = create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) - page_3_content_fr = create_title(language='fr', title='page trois', page=page_3, created_by=self.user) + + page_1 = create_page("page one", "page.html", language="en", created_by=self.user) + page_2 = create_page("page two", "page.html", language="en", created_by=self.user) + page_3 = create_page("page three", "page.html", language="en", created_by=self.user) + page_1_content_fr = create_title(language="fr", title="page un", page=page_1, created_by=self.user) + page_1_content_it = create_title(language="it", title="pagina uno", page=page_1, created_by=self.user) + page_3_content_fr = create_title(language="fr", title="page trois", page=page_3, created_by=self.user) page_content1 = PageContent._original_manager.get(page=page_1, language="en") page_content2 = PageContent._original_manager.get(page=page_2, language="en") page_content3 = PageContent._original_manager.get(page=page_3, language="en") @@ -46,7 +48,7 @@ def get_pages(self): page_1_content_fr.versions.first().publish(self.user) page_1_content_it.versions.first().publish(self.user) page_3_content_fr.versions.first().publish(self.user) - if hasattr(page_1, 'set_as_homepage'): + if hasattr(page_1, "set_as_homepage"): page_1.set_as_homepage() return page_1, page_2, page_3 @@ -61,22 +63,27 @@ def get_request(self, page, lang): request.LANGUAGE_CODE = lang return request - def get_page_request(self, page, user, path=None, edit=False, lang_code='en'): + def get_page_request(self, page, user, path=None, edit=False, lang_code="en"): from cms.middleware.toolbar import ToolbarMiddleware + path = path or page and page.get_absolute_url(lang_code) if edit: - path += '?edit' + path += "?edit" request = RequestFactory().get(path) request.session = {} request.user = user request.LANGUAGE_CODE = lang_code if edit: - request.GET = {'edit': None} + request.GET = {"edit": None} else: - request.GET = {'edit_off': None} + request.GET = {"edit_off": None} request.current_page = page - mid = ToolbarMiddleware(request) - mid.process_request(request) + if hasattr(ToolbarMiddleware, "process_request"): + mid = ToolbarMiddleware() + mid.process_request(request) + else: + mid = ToolbarMiddleware(lambda req: HttpResponse()) + mid.__call__(request) return request @classmethod diff --git a/tests/test_models.py b/tests/test_models.py index 3f6f7bb..4aee45a 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -9,9 +9,7 @@ class RobotsTest(BaseTest): - def _test_robots_tag(self, template_string, context, expected): - tpl_obj = template.Template(template_string) ctx_obj = template.Context(context) rendered = tpl_obj.render(ctx_obj) @@ -20,26 +18,24 @@ def _test_robots_tag(self, template_string, context, expected): self.assertEqual(ctx_obj.get(key), value) def test_robots_tag_no_request(self): - template = '{% load robots_index %}{% page_robots %}' + template = "{% load robots_index %}{% page_robots %}" context = {} - self._test_robots_tag(template, context, '') + self._test_robots_tag(template, context, "") def test_robots_tag_request_no_page(self): - template = '{% load robots_index %}{% page_robots %}' - request = RequestFactory().get('/') + template = "{% load robots_index %}{% page_robots %}" + request = RequestFactory().get("/") request.session = {} - context = {'request': request} - self._test_robots_tag(template, context, '') + context = {"request": request} + self._test_robots_tag(template, context, "") def test_robots_options(self): page1, page2, page3 = self.get_pages() - extension = PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never' - ) + extension = PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") - template = '{% load robots_index %}{% page_robots %}' + template = "{% load robots_index %}{% page_robots %}" expected = '' - context = {'request': self.get_page_request(page1, AnonymousUser())} + context = {"request": self.get_page_request(page1, AnonymousUser())} self._test_robots_tag(template, context, expected) extension.noindex = True @@ -52,75 +48,81 @@ def test_robots_options(self): expected = '' self._test_robots_tag(template, context, expected) - extension.robots_extra = 'nodmoz' + extension.robots_extra = "nodmoz" extension.save() expected = '' self._test_robots_tag(template, context, expected) def test_robots_page_parameter(self): page1, page2, page3 = self.get_pages() - extension = PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never' - ) + extension = PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") + if hasattr(page1, "publish"): + page1.publish("en") extension.refresh_from_db() - template = '{% load robots_index %}{% page_robots %}' - expected = '' - context = {'request': self.get_page_request(page2, AnonymousUser())} + template = "{% load robots_index %}{% page_robots %}" + expected = "" + context = {"request": self.get_page_request(page2, AnonymousUser())} self._test_robots_tag(template, context, expected) extension.noindex = True extension.save() - expected = '' + if hasattr(page1, "publish"): + page1.publish("en") + expected = "" self._test_robots_tag(template, context, expected) - template = '{%% load robots_index %%}{%% page_robots %s %%}' % page1.pk + template = "{%% load robots_index %%}{%% page_robots %s %%}" % page1.pk expected = '' self._test_robots_tag(template, context, expected) extension.noarchive = True extension.save() + if hasattr(page1, "publish"): + page1.publish("en") expected = '' self._test_robots_tag(template, context, expected) - extension.robots_extra = 'nodmoz' + extension.robots_extra = "nodmoz" extension.save() + if hasattr(page1, "publish"): + page1.publish("en") expected = '' self._test_robots_tag(template, context, expected) def test_robots_page_no_site(self): page1, page2, page3 = self.get_pages() - extension = PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never' - ) + extension = PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") + if hasattr(page1, "publish"): + page1.publish("en") extension.refresh_from_db() template = '{% load robots_index %}{% page_robots None "abc" %}' - expected = '' - context = {'request': self.get_page_request(page2, AnonymousUser())} + expected = "" + context = {"request": self.get_page_request(page2, AnonymousUser())} self._test_robots_tag(template, context, expected) def test_robots_page_no_page(self): page1, page2, page3 = self.get_pages() - extension = PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never' - ) + extension = PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") + if hasattr(page1, "publish"): + page1.publish("en") extension.refresh_from_db() template = '{% load robots_index %}{% page_robots "abc" %}' - expected = '' - context = {'request': self.get_page_request(page2, AnonymousUser())} + expected = "" + context = {"request": self.get_page_request(page2, AnonymousUser())} self._test_robots_tag(template, context, expected) def test_robots_page_other_site(self): - site_2 = Site.objects.create(domain='http://othersite.com') + site_2 = Site.objects.create(domain="http://othersite.com") page1, page2, page3 = self.get_pages() - extension = PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never' - ) + extension = PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") + if hasattr(page1, "publish"): + page1.publish("en") extension.refresh_from_db() - template = '{%% load robots_index %%}{%% page_robots None %s %%}' % site_2.pk - expected = '' - context = {'request': self.get_page_request(page2, AnonymousUser())} + template = "{%% load robots_index %%}{%% page_robots None %s %%}" % site_2.pk + expected = "" + context = {"request": self.get_page_request(page2, AnonymousUser())} self._test_robots_tag(template, context, expected) diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index b32512d..4178950 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -14,33 +14,37 @@ class SitemapTest(BaseTest): - def test_sitemap_base(self): page1, page2, page3 = self.get_pages() - sitemap = self.client.get('/sitemap.xml') - test_string = 'http://example.com/%s/%s' \ - 'monthly0.5' \ - % (page1.get_title_obj().language, now().strftime('%Y-%m-%d')) + sitemap = self.client.get("/sitemap.xml") + test_string = ( + "http://example.com/%s/%s" + "monthly0.5" + % (page1.get_title_obj().language, now().strftime("%Y-%m-%d")) + ) self.assertContains(sitemap, test_string) def test_sitemap_extended(self): page1, page2, page3 = self.get_pages() - PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never' - ) + PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") - test_string = 'http://example.com/%s/%s' \ - 'never0.2' \ - % (page1.get_title_obj().language, now().strftime('%Y-%m-%d')) - sitemap = self.client.get('/sitemap.xml') + test_string = ( + "http://example.com/%s/%s" + "never0.2" + % (page1.get_title_obj().language, now().strftime("%Y-%m-%d")) + ) + sitemap = self.client.get("/sitemap.xml") self.assertContains(sitemap, test_string) def test_sitemap_exclude(self): page1, page2, page3 = self.get_pages() PageSitemapProperties.objects.create( - extended_object=page3, priority='0.2', changefreq='never', include_in_sitemap=False + extended_object=page3, + priority="0.2", + changefreq="never", + include_in_sitemap=False, ) sitemap = ExtendedSitemap() # unpublished since change, still in the sitemap @@ -52,25 +56,21 @@ def test_sitemap_exclude(self): def test_sitemap_cache(self): page1, page2, page3 = self.get_pages() - PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never' - ) - PageSitemapProperties.objects.create( - extended_object=page3, priority='0.8', changefreq='hourly' - ) + PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") + PageSitemapProperties.objects.create(extended_object=page3, priority="0.8", changefreq="hourly") sitemap = ExtendedSitemap() self.assertEqual(len(sitemap.items()), 6) for item in sitemap.items(): if item.page.pk == page1.pk: - self.assertEqual(sitemap.changefreq(item), 'never') - self.assertEqual(sitemap.priority(item), Decimal('0.2')) + self.assertEqual(sitemap.changefreq(item), "never") + self.assertEqual(sitemap.priority(item), Decimal("0.2")) ext_key = get_cache_key(item.page) self.assertEqual(cache.get(ext_key), item.page.pagesitemapproperties) if item.page.pk == page3.pk: - self.assertEqual(sitemap.changefreq(item), 'hourly') - self.assertEqual(sitemap.priority(item), Decimal('0.8')) + self.assertEqual(sitemap.changefreq(item), "hourly") + self.assertEqual(sitemap.priority(item), Decimal("0.8")) ext_key = get_cache_key(page1) page1.pagesitemapproperties.save() @@ -80,38 +80,29 @@ def test_sitemap_cache(self): page3.delete() self.assertEqual(cache.get(ext_key), None) - @skipIf(not is_versioning_enabled(), 'This test can only run when versioning is installed') + @skipIf(not is_versioning_enabled(), "This test can only run when versioning is installed") def test_pageurl_lastmod_with_cms4_versioning(self): # Check the latest version modified date for the page is checked for lastmod() # if versioning is enabled, Currenly test is skipped , as this require changes in testsuite - page_1 = create_page('page-one', 'page.html', language='en', created_by=self.user) - page_content = create_title( - title='page un', - language='en', - page=page_1, - created_by=self.user - ) + page_1 = create_page("page-one", "page.html", language="en", created_by=self.user) + page_content = create_title(title="page un", language="en", page=page_1, created_by=self.user) if is_versioning_enabled(): page_content.versions.first().publish(self.user) - last_modified_date = '%s' % ( - page_content.versions.first().modified.strftime('%Y-%m-%d') + last_modified_date = "%s" % (page_content.versions.first().modified.strftime("%Y-%m-%d")) + expected_string = ( + "http://example.com%s%smonthly" + "0.5" + % (page_1.get_absolute_url(language="en"), last_modified_date) ) - expected_string = 'http://example.com%s%smonthly' \ - '0.5' \ - % (page_1.get_absolute_url(language='en'), last_modified_date) - sitemap = self.client.get('/sitemap.xml') + sitemap = self.client.get("/sitemap.xml") self.assertContains(sitemap, expected_string) def test_sitemap_items_query_performance(self): page1, page2, page3 = self.get_pages() - PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never' - ) - PageSitemapProperties.objects.create( - extended_object=page3, priority='0.8', changefreq='hourly' - ) + PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") + PageSitemapProperties.objects.create(extended_object=page3, priority="0.8", changefreq="hourly") sitemap = ExtendedSitemap() max_queries = 4 with self.assertNumQueries(FuzzyInt(3, max_queries)): diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index 4a58273..0d6f3a4 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -25,23 +25,21 @@ def find_toolbar_buttons(button_name, toolbar): """ found = [] for button_list in toolbar.get_right_items(): - found = found + [ - button for button in button_list.buttons if button.name == button_name - ] + found = found + [button for button in button_list.buttons if button.name == button_name] return found class ToolbarTest(BaseTest): - def test_no_page(self): """ Test that no page menu is present if request not in a page """ from cms.toolbar.toolbar import CMSToolbar - request = self.get_page_request(None, self.user, '/', edit=True) + + request = self.get_page_request(None, self.user, "/", edit=True) toolbar = CMSToolbar(request) toolbar.get_left_items() - page_menu = toolbar.find_items(Menu, name='Page') + page_menu = toolbar.find_items(Menu, name="Page") self.assertEqual(page_menu, []) def test_no_perm(self): @@ -49,33 +47,63 @@ def test_no_perm(self): Test that no page menu is present if user has no perm """ from cms.toolbar.toolbar import CMSToolbar + page1, page2, page3 = self.get_pages() - request = self.get_page_request(page1, self.user_staff, '/', edit=True) + request = self.get_page_request(page1, self.user_staff, "/", edit=True) toolbar = CMSToolbar(request) toolbar.get_left_items() - page_menu = toolbar.find_items(Menu, name='Page') + page_menu = toolbar.find_items(Menu, name="Page") self.assertEqual(len(page_menu), 1) + def test_page_types(self): + """ + Test that page meta menu is not displayed on page types. + """ + from cms.toolbar.toolbar import CMSToolbar + + page1, page2, page3 = self.get_pages() + page1.is_page_type = True + page1.save() + self.user_staff.user_permissions.add(Permission.objects.get(codename="change_page")) + self.user_staff = User.objects.get(pk=self.user_staff.pk) + request = self.get_page_request(page1, self.user_staff, "/", edit=True) + toolbar = CMSToolbar(request) + toolbar.get_left_items() + page_menu = toolbar.menus["page"] + try: + self.assertEqual( + len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), + 0, + ) + except AssertionError: + self.assertEqual( + len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), + 0, + ) + def test_perm(self): """ Test that page meta menu is present if user has Page.change_perm """ from cms.toolbar.toolbar import CMSToolbar + page1, page2, page3 = self.get_pages() - self.user_staff.user_permissions.add(Permission.objects.get(codename='change_page')) + self.user_staff.user_permissions.add(Permission.objects.get(codename="change_page")) self.user_staff = User.objects.get(pk=self.user_staff.pk) - request = self.get_page_request(page1, self.user_staff, '/', edit=True) + request = self.get_page_request(page1, self.user_staff, "/", edit=True) toolbar = CMSToolbar(request) toolbar.get_left_items() - page_menu = toolbar.menus['page'] + page_menu = toolbar.menus["page"] try: self.assertEqual( - len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 + len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), + 1, ) except AssertionError: self.assertEqual( - len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 + len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), + 1, ) @override_settings(CMS_PERMISSION=True) @@ -84,13 +112,14 @@ def test_perm_permissions(self): Test that no page menu is present if user has general page Page.change_perm but not permission on current page """ from cms.toolbar.toolbar import CMSToolbar + page1, page2, page3 = self.get_pages() - self.user_staff.user_permissions.add(Permission.objects.get(codename='change_page')) + self.user_staff.user_permissions.add(Permission.objects.get(codename="change_page")) self.user_staff = User.objects.get(pk=self.user_staff.pk) - request = self.get_page_request(page1, self.user_staff, '/', edit=True) + request = self.get_page_request(page1, self.user_staff, "/", edit=True) toolbar = CMSToolbar(request) toolbar.get_left_items() - page_menu = toolbar.find_items(Menu, name='Page') + page_menu = toolbar.find_items(Menu, name="Page") self.assertEqual(len(page_menu), 1) def test_toolbar(self): @@ -98,11 +127,12 @@ def test_toolbar(self): Test that PageSitemapProperties item is present for superuser """ from cms.toolbar.toolbar import CMSToolbar + page1, page2, page3 = self.get_pages() - request = self.get_page_request(page1, self.user, '/', edit=True) + request = self.get_page_request(page1, self.user, "/", edit=True) toolbar = CMSToolbar(request) toolbar.get_left_items() - page_menu = toolbar.menus['page'] + page_menu = toolbar.menus["page"] try: self.assertEqual( len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 @@ -117,27 +147,26 @@ def test_toolbar_with_items(self): Test that PageSitemapProperties item is present for superuser if PageSitemapProperties exists for current page """ from cms.toolbar.toolbar import CMSToolbar + page1, page2, page3 = self.get_pages() - page_ext = PageSitemapProperties.objects.create( - extended_object=page1, priority='0.2', changefreq='never') - request = self.get_page_request(page1, self.user, '/', edit=True) + page_ext = PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") + request = self.get_page_request(page1, self.user, "/", edit=True) toolbar = CMSToolbar(request) toolbar.get_left_items() - page_menu = toolbar.menus['page'] + page_menu = toolbar.menus["page"] try: - meta_menu = page_menu.find_items( - ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE) - )[0].item + meta_menu = page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))[0].item except IndexError: - meta_menu = page_menu.find_items( - ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE) - )[0].item - self.assertTrue(meta_menu.url.startswith(reverse('admin:djangocms_page_sitemap_pagesitemapproperties_change', args=(page_ext.pk,)))) - self.assertEqual(force_str(page_ext), force_str(_('Sitemap values for Page %s') % page1.pk)) + meta_menu = page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))[0].item + self.assertTrue( + meta_menu.url.startswith( + reverse("admin:djangocms_page_sitemap_pagesitemapproperties_change", args=(page_ext.pk,)) + ) + ) + self.assertEqual(force_str(page_ext), force_str(_("Sitemap values for Page %s") % page1.pk)) class VersioningToolbarTest(CMSTestCase): - def test_toolbar_buttons_are_not_duplicated(self): """ The toolbar for djangocms-page-sitemap doesn't affect the toolbar buttons. @@ -145,12 +174,12 @@ def test_toolbar_buttons_are_not_duplicated(self): This test Can be ran with or without versioning and should return the same result! """ user = self.get_superuser() - page_1 = create_page('page-one', 'page.html', language='en', created_by=user) + page_1 = create_page("page-one", "page.html", language="en", created_by=user) page_content = PageContent._original_manager.get(page=page_1, language="en") if is_versioning_enabled(): page_content.versions.first().publish(user) - preview_endpoint = get_object_preview_url(page_content, language='en') + preview_endpoint = get_object_preview_url(page_content, language="en") with self.login_user_context(self.get_superuser()): response = self.client.post(preview_endpoint) diff --git a/tests/test_utils/__init__.py b/tests/test_utils/__init__.py index 8b13789..e69de29 100644 --- a/tests/test_utils/__init__.py +++ b/tests/test_utils/__init__.py @@ -1 +0,0 @@ - diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py index 2f4a837..401c1da 100644 --- a/tests/test_utils/urls.py +++ b/tests/test_utils/urls.py @@ -3,25 +3,35 @@ from django.conf.urls.i18n import i18n_patterns from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns +from django.urls import include, path, re_path from django.views.static import serve -from django.urls import include, re_path from djangocms_page_sitemap import sitemap_urls - admin.autodiscover() urlpatterns = [ - re_path(r'^media/(?P.*)$', serve, - {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), - re_path(r'^media/cms/(?P.*)$', serve, - {'document_root': get_cms_setting('MEDIA_ROOT'), 'show_indexes': True}), - re_path(r'^', include(sitemap_urls)), + re_path(r"^media/(?P.*)$", serve, {"document_root": settings.MEDIA_ROOT, "show_indexes": True}), + re_path( + r"^media/cms/(?P.*)$", serve, {"document_root": get_cms_setting("MEDIA_ROOT"), "show_indexes": True} + ), + path("", include(sitemap_urls)), + re_path( + r"^media/(?P.*)$", + serve, + {"document_root": settings.MEDIA_ROOT, "show_indexes": True}, + ), + re_path( + r"^media/cms/(?P.*)$", + serve, + {"document_root": get_cms_setting("MEDIA_ROOT"), "show_indexes": True}, + ), + path("", include(sitemap_urls)), ] urlpatterns += staticfiles_urlpatterns() urlpatterns += i18n_patterns( - re_path(r'^admin/', admin.site.urls), - re_path(r'^', include('cms.urls')), + re_path(r"^admin/", admin.site.urls), + path("", include("cms.urls")), ) From f5610317df1d83edc5155dcadf0d27e19e38c5ac Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 12 May 2023 22:41:33 +0200 Subject: [PATCH 34/37] Merge --- 70.patch | 4154 ----------------------------------------- changes/82.feature | 1 + tests/test_sitemap.py | 4 +- 3 files changed, 3 insertions(+), 4156 deletions(-) delete mode 100644 70.patch create mode 100644 changes/82.feature diff --git a/70.patch b/70.patch deleted file mode 100644 index 297d2a9..0000000 --- a/70.patch +++ /dev/null @@ -1,4154 +0,0 @@ -From e1efa53bfc908267989e418ad80de27a16660027 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 10:42:41 +0000 -Subject: [PATCH 01/20] Initial port of tools changes - ---- - .checkignore | 3 + - .codeclimate.yml | 1 - - .coveragerc | 2 +- - .csslintrc | 2 + - .editorconfig | 10 +- - .github/ISSUE_TEMPLATE/---bug-report.md | 48 ++ - .github/ISSUE_TEMPLATE/---feature-request.md | 42 ++ - .github/pull_request_template.md | 18 + - .github/workflows/lint.yml | 41 ++ - .github/workflows/publish.yml | 38 ++ - .github/workflows/test.yml | 61 +++ - .gitignore | 523 ++++++++++++++++++- - .pre-commit-config.yaml | 62 +++ - .pyup.yml | 7 + - .readthedocs.yaml | 19 + - .travis.yml | 61 --- - .tx/config | 1 - - CONTRIBUTING.rst | 105 +++- - HISTORY.rst | 52 +- - LICENSE | 4 +- - MANIFEST.in | 3 +- - Makefile | 46 -- - docs/Makefile | 2 +- - docs/authors.rst | 2 +- - docs/conf.py | 152 +++--- - docs/contributing.rst | 2 +- - docs/history.rst | 2 +- - docs/index.rst | 2 +- - docs/make.bat | 2 +- - docs/readme.rst | 2 +- - pyproject.toml | 30 ++ - requirements-docs.txt | 2 - - requirements-test.txt | 10 +- - requirements.txt | 2 +- - setup.cfg | 84 ++- - setup.py | 64 +-- - tasks.py | 140 +++++ - 37 files changed, 1300 insertions(+), 347 deletions(-) - create mode 100644 .checkignore - create mode 100644 .csslintrc - create mode 100644 .github/ISSUE_TEMPLATE/---bug-report.md - create mode 100644 .github/ISSUE_TEMPLATE/---feature-request.md - create mode 100644 .github/pull_request_template.md - create mode 100644 .github/workflows/lint.yml - create mode 100644 .github/workflows/publish.yml - create mode 100644 .github/workflows/test.yml - create mode 100644 .pre-commit-config.yaml - create mode 100644 .pyup.yml - create mode 100644 .readthedocs.yaml - delete mode 100644 .travis.yml - delete mode 100644 Makefile - create mode 100644 pyproject.toml - delete mode 100644 requirements-docs.txt - mode change 100755 => 100644 setup.py - create mode 100644 tasks.py - -diff --git a/.checkignore b/.checkignore -new file mode 100644 -index 0000000..12e56c3 ---- /dev/null -+++ b/.checkignore -@@ -0,0 +1,3 @@ -+tests/* -+docs/* -+djangocms_page_sitemap/migrations/* -diff --git a/.codeclimate.yml b/.codeclimate.yml -index 1a50e5b..9fa0ebb 100644 ---- a/.codeclimate.yml -+++ b/.codeclimate.yml -@@ -5,5 +5,4 @@ languages: - Python: true - exclude_paths: - - 'djangocms_page_sitemap/migrations/*' -- - 'djangocms_page_sitemap/south_migrations/*' - - 'tests/*' -diff --git a/.coveragerc b/.coveragerc -index 8ee5bf3..0f28a09 100644 ---- a/.coveragerc -+++ b/.coveragerc -@@ -3,7 +3,7 @@ branch = True - source = djangocms_page_sitemap - - [report] --omit = ../*migrations*,../*tests* -+omit = *migrations*,*tests*,*test_utils* - # Regexes for lines to exclude from consideration - exclude_lines = - # Have to re-enable the standard pragma -diff --git a/.csslintrc b/.csslintrc -new file mode 100644 -index 0000000..aacba95 ---- /dev/null -+++ b/.csslintrc -@@ -0,0 +1,2 @@ -+--exclude-exts=.min.css -+--ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes -diff --git a/.editorconfig b/.editorconfig -index 56def90..d979ee9 100644 ---- a/.editorconfig -+++ b/.editorconfig -@@ -8,27 +8,27 @@ end_of_line = lf - charset = utf-8 - trim_trailing_whitespace = true - insert_final_newline = true --max_line_length = 80 -+max_line_length = 120 - - [*.md] - trim_trailing_whitespace = false - - [*.rst] --max_line_length = 80 -+max_line_length = 120 - - [*.py] --max_line_length = 100 -+max_line_length = 120 - - [*.{scss,html}] - indent_size = 2 - indent_style = space - max_line_length = 120 - --[*.js] -+[*.{js,vue,json}] - indent_size = 2 - max_line_length = 120 - --[*.yml] -+[*.{yml,yaml}] - indent_size = 2 - - [Makefile] -diff --git a/.github/ISSUE_TEMPLATE/---bug-report.md b/.github/ISSUE_TEMPLATE/---bug-report.md -new file mode 100644 -index 0000000..19d08d8 ---- /dev/null -+++ b/.github/ISSUE_TEMPLATE/---bug-report.md -@@ -0,0 +1,48 @@ -+--- -+name: "\U0001F41B Bug report" -+about: Create a report to help us improve -+title: '' -+labels: 'type: bug' -+assignees: '' -+ -+--- -+ -+ -+ -+## Description -+ -+ -+ -+## Steps to reproduce -+ -+ -+ -+## Versions -+ -+ -+ -+## Expected behaviour -+ -+ -+ -+## Actual behaviour -+ -+ -+ -+## Additional information -+ -+ -diff --git a/.github/ISSUE_TEMPLATE/---feature-request.md b/.github/ISSUE_TEMPLATE/---feature-request.md -new file mode 100644 -index 0000000..5b74e5f ---- /dev/null -+++ b/.github/ISSUE_TEMPLATE/---feature-request.md -@@ -0,0 +1,42 @@ -+--- -+name: "\U0001F389 Feature request" -+about: Share your idea, let's discuss it! -+title: '' -+labels: 'type: feature' -+assignees: '' -+ -+--- -+ -+ -+ -+## Description -+ -+ -+ -+## Use cases -+ -+ -+ -+## Proposed solution -+ -+ -+ -+## Alternatives -+ -+ -+ -+## Additional information -+ -+ -diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md -new file mode 100644 -index 0000000..dcb9856 ---- /dev/null -+++ b/.github/pull_request_template.md -@@ -0,0 +1,18 @@ -+# Description -+ -+Describe: -+ -+* Content of the pull request -+* Feature added / Problem fixed -+ -+## References -+ -+Provide any github issue fixed (as in ``Fix #XYZ``) -+ -+# Checklist -+ -+* [ ] I have read the [contribution guide](https://djangocms-page-sitemap.readthedocs.io/en/latest/contributing.html) -+* [ ] Code lint checked via `inv lint` -+* [ ] ``changes`` file included (see [docs](https://djangocms-page-sitemap.readthedocs.io/en/latest/contributing.html#pull-request-guidelines)) -+* [ ] Usage documentation added in case of new features -+* [ ] Tests added -diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml -new file mode 100644 -index 0000000..d03bb3c ---- /dev/null -+++ b/.github/workflows/lint.yml -@@ -0,0 +1,41 @@ -+name: Code quality -+ -+on: [push, pull_request] -+ -+jobs: -+ lint: -+ runs-on: ubuntu-latest -+ if: "!contains(github.event.head_commit.message, '[skip ci]')" -+ strategy: -+ matrix: -+ python-version: [3.8] -+ toxenv: [pep8, isort, black, pypi-description, docs, towncrier] -+ steps: -+ - uses: actions/checkout@v2 -+ with: -+ repository: ${{ github.event.pull_request.head.repo.full_name }} -+ ref: ${{ github.event.pull_request.head.ref }} -+ - name: Set up Python ${{ matrix.python-version }} -+ uses: actions/setup-python@v2 -+ with: -+ python-version: ${{ matrix.python-version }} -+ - name: Cache pip -+ uses: actions/cache@v1 -+ with: -+ path: ~/.cache/pip -+ key: ${{ runner.os }}-pip-${{ matrix.toxenv }} -+ restore-keys: | -+ ${{ runner.os }}-pip-${{ matrix.toxenv }} -+ - name: Cache tox -+ uses: actions/cache@v1 -+ with: -+ path: .tox -+ key: ${{ runner.os }}-lint-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }} -+ restore-keys: | -+ ${{ runner.os }}-lint-${{ matrix.toxenv }}- -+ - name: Install dependencies -+ run: | -+ python -m pip install --upgrade pip setuptools tox>=1.8 -+ - name: Test with tox -+ run: | -+ tox -e${{ matrix.toxenv }} -diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml -new file mode 100644 -index 0000000..07b9e64 ---- /dev/null -+++ b/.github/workflows/publish.yml -@@ -0,0 +1,38 @@ -+name: Upload Python Package -+ -+on: -+ release: -+ types: [published,prereleased] -+ -+jobs: -+ deploy: -+ runs-on: ubuntu-latest -+ steps: -+ - uses: actions/checkout@v2 -+ - name: Set up Python -+ uses: actions/setup-python@v2 -+ with: -+ python-version: '3.x' -+ - name: Cache pip -+ uses: actions/cache@v1 -+ with: -+ path: ~/.cache/pip -+ key: ${{ runner.os }}-pip-${{ matrix.toxenv }} -+ restore-keys: | -+ ${{ runner.os }}-pip-${{ matrix.toxenv }} -+ - name: Cache tox -+ uses: actions/cache@v1 -+ with: -+ path: .tox -+ key: ${{ runner.os }}-tox-release-${{ hashFiles('setup.cfg') }} -+ restore-keys: | -+ ${{ runner.os }}-tox-release- -+ - name: Install dependencies -+ run: | -+ python -m pip install --upgrade pip setuptools tox>=1.8 -+ - name: Build and publish -+ env: -+ TWINE_USERNAME: __token__ -+ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} -+ run: | -+ tox -erelease -diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml -new file mode 100644 -index 0000000..bac4618 ---- /dev/null -+++ b/.github/workflows/test.yml -@@ -0,0 +1,61 @@ -+name: Tox tests -+ -+on: [push, pull_request] -+ -+jobs: -+ test: -+ if: "!contains(github.event.head_commit.message, '[skip ci]')" -+ runs-on: ubuntu-latest -+ strategy: -+ matrix: -+ python-version: [3.8, 3.7, 3.6] -+ django: [31, 30, 22] -+ cms: [38, 37] -+ exclude: -+ - django: 31 -+ cms: 37 -+ steps: -+ - uses: actions/checkout@v2 -+ - name: Set up Python ${{ matrix.python-version }} -+ uses: actions/setup-python@v2 -+ with: -+ python-version: ${{ matrix.python-version }} -+ - name: Cache pip -+ uses: actions/cache@v1 -+ with: -+ path: ~/.cache/pip -+ key: ${{ runner.os }}-pip-${{ matrix.toxenv }} -+ restore-keys: | -+ ${{ runner.os }}-pip-${{ matrix.toxenv }} -+ - name: Cache tox -+ uses: actions/cache@v1 -+ with: -+ path: .tox -+ key: ${{ runner.os }}-tox-${{ format('{{py{0}-django{1}-cms{2}}}', matrix.python-version, matrix.django, matrix.cms) }}-${{ hashFiles('setup.cfg') }} -+ restore-keys: | -+ ${{ runner.os }}-tox-${{ format('{{py{0}-django{1}-cms{2}}}', matrix.python-version, matrix.django, matrix.cms) }}- -+ - name: Install dependencies -+ run: | -+ sudo apt-get install gettext -+ python -m pip install --upgrade pip tox>=3.5 -+ - name: Test with tox -+ env: -+ TOX_ENV: ${{ format('py-django{1}-cms{2}', matrix.python-version, matrix.django, matrix.cms) }} -+ COMMAND: coverage run -+ COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} -+ COVERALLS_SERVICE_NAME: github -+ run: | -+ tox -e$TOX_ENV -+ .tox/$TOX_ENV/bin/coverage xml -+ .tox/$TOX_ENV/bin/coveralls -+ - uses: codecov/codecov-action@v1 -+ with: -+ token: ${{ secrets.CODECOV_TOKEN }} -+ flags: unittests -+ file: ./coverage.xml -+ fail_ci_if_error: false -+ services: -+ redis: -+ image: redis -+ ports: -+ - 6379:6379 -diff --git a/.gitignore b/.gitignore -index f515e3b..1125109 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -1,42 +1,525 @@ -+ -+# Created by https://www.gitignore.io/api/vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode -+# Edit at https://www.gitignore.io/?templates=vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode -+ -+### Django ### -+*.log -+*.pot -+*.pyc -+__pycache__/ -+local_settings.py -+db.sqlite3 -+db.sqlite3-journal -+media -+ -+# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ -+# in your Git repository. Update and uncomment the following line accordingly. -+# /staticfiles/ -+ -+### Django.Python Stack ### -+# Byte-compiled / optimized / DLL files - *.py[cod] -+*$py.class - - # C extensions - *.so - --# Packages --*.egg --*.egg-info --dist --build --eggs --parts --bin --var --sdist --develop-eggs --*.eggs -+# Distribution / packaging -+.Python -+build/ -+develop-eggs/ -+dist/ -+downloads/ -+eggs/ -+.eggs/ -+lib/ -+lib64/ -+parts/ -+sdist/ -+var/ -+wheels/ -+pip-wheel-metadata/ -+share/python-wheels/ -+*.egg-info/ - .installed.cfg --lib --lib64 -+*.egg -+MANIFEST -+ -+# PyInstaller -+# Usually these files are written by a python script from a template -+# before PyInstaller builds the exe, so as to inject date/other infos into it. -+*.manifest -+*.spec - - # Installer logs - pip-log.txt -+pip-delete-this-directory.txt - - # Unit test / coverage reports -+htmlcov/ -+.tox/ -+.nox/ - .coverage --.tox -+.coverage.* -+.cache - nosetests.xml -+coverage.xml -+*.cover -+.hypothesis/ -+.pytest_cache/ -+ -+# Translations -+*.mo -+ -+# Scrapy stuff: -+.scrapy -+ -+# Sphinx documentation -+docs/_build/ -+ -+# PyBuilder -+target/ -+ -+# pyenv -+.python-version -+ -+# pipenv -+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -+# However, in case of collaboration, if having platform-specific dependencies or dependencies -+# having no cross-platform support, pipenv may install dependencies that don't work, or not -+# install all needed dependencies. -+#Pipfile.lock -+ -+# celery beat schedule file -+celerybeat-schedule -+ -+# SageMath parsed files -+*.sage.py -+ -+# Spyder project settings -+.spyderproject -+.spyproject -+ -+# Rope project settings -+.ropeproject - - # Mr Developer - .mr.developer.cfg - .project - .pydevproject - --# Complexity --output/*.html --output/*/index.html -+# mkdocs documentation -+/site -+ -+# mypy -+.mypy_cache/ -+.dmypy.json -+dmypy.json -+ -+# Pyre type checker -+.pyre/ -+ -+### Linux ### -+*~ -+ -+# temporary files which can be created if a process still has a handle open of a deleted file -+.fuse_hidden* -+ -+# KDE directory preferences -+.directory -+ -+# Linux trash folder which might appear on any partition or disk -+.Trash-* -+ -+# .nfs files are created when an open file is removed but is still being accessed -+.nfs* -+ -+### macOS ### -+# General -+.DS_Store -+.AppleDouble -+.LSOverride -+ -+# Icon must end with two \r -+Icon -+ -+# Thumbnails -+._* -+ -+# Files that might appear in the root of a volume -+.DocumentRevisions-V100 -+.fseventsd -+.Spotlight-V100 -+.TemporaryItems -+.Trashes -+.VolumeIcon.icns -+.com.apple.timemachine.donotpresent -+ -+# Directories potentially created on remote AFP share -+.AppleDB -+.AppleDesktop -+Network Trash Folder -+Temporary Items -+.apdisk -+ -+### Node ### -+# Logs -+logs -+npm-debug.log* -+yarn-debug.log* -+yarn-error.log* -+lerna-debug.log* -+ -+# Diagnostic reports (https://nodejs.org/api/report.html) -+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json -+ -+# Runtime data -+pids -+*.pid -+*.seed -+*.pid.lock -+ -+# Directory for instrumented libs generated by jscoverage/JSCover -+lib-cov -+ -+# Coverage directory used by tools like istanbul -+coverage -+*.lcov -+ -+# nyc test coverage -+.nyc_output -+ -+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -+.grunt -+ -+# Bower dependency directory (https://bower.io/) -+bower_components -+ -+# node-waf configuration -+.lock-wscript -+ -+# Compiled binary addons (https://nodejs.org/api/addons.html) -+build/Release -+ -+# Dependency directories -+node_modules/ -+jspm_packages/ -+ -+# TypeScript v1 declaration files -+typings/ -+ -+# TypeScript cache -+*.tsbuildinfo -+ -+# Optional npm cache directory -+.npm -+ -+# Optional eslint cache -+.eslintcache -+ -+# Optional REPL history -+.node_repl_history -+ -+# Output of 'npm pack' -+*.tgz -+ -+# Yarn Integrity file -+.yarn-integrity -+ -+# dotenv environment variables file -+.env -+.env.test -+ -+# parcel-bundler cache (https://parceljs.org/) -+ -+# next.js build output -+.next -+ -+# nuxt.js build output -+.nuxt -+ -+# rollup.js default build output -+ -+# Uncomment the public line if your project uses Gatsby -+# https://nextjs.org/blog/next-9-1#public-directory-support -+# https://create-react-app.dev/docs/using-the-public-folder/#docsNav -+# public -+ -+# Storybook build outputs -+.out -+.storybook-out -+ -+# vuepress build output -+.vuepress/dist -+ -+# Serverless directories -+.serverless/ -+ -+# FuseBox cache -+.fusebox/ -+ -+# DynamoDB Local files -+.dynamodb/ -+ -+# Temporary folders -+tmp/ -+temp/ -+ -+### PyCharm ### -+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm -+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 -+.idea/ -+ -+# User-specific stuff -+.idea/**/workspace.xml -+.idea/**/tasks.xml -+.idea/**/usage.statistics.xml -+.idea/**/dictionaries -+.idea/**/shelf -+ -+# Generated files -+.idea/**/contentModel.xml -+ -+# Sensitive or high-churn files -+.idea/**/dataSources/ -+.idea/**/dataSources.ids -+.idea/**/dataSources.local.xml -+.idea/**/sqlDataSources.xml -+.idea/**/dynamic.xml -+.idea/**/uiDesigner.xml -+.idea/**/dbnavigator.xml -+ -+# Gradle -+.idea/**/gradle.xml -+.idea/**/libraries -+ -+# Gradle and Maven with auto-import -+# When using Gradle or Maven with auto-import, you should exclude module files, -+# since they will be recreated, and may cause churn. Uncomment if using -+# auto-import. -+# .idea/modules.xml -+# .idea/*.iml -+# .idea/modules -+# *.iml -+# *.ipr -+ -+# CMake -+cmake-build-*/ -+ -+# Mongo Explorer plugin -+.idea/**/mongoSettings.xml -+ -+# File-based project format -+*.iws -+ -+# IntelliJ -+out/ -+ -+# mpeltonen/sbt-idea plugin -+.idea_modules/ -+ -+# JIRA plugin -+atlassian-ide-plugin.xml -+ -+# Cursive Clojure plugin -+.idea/replstate.xml -+ -+# Crashlytics plugin (for Android Studio and IntelliJ) -+com_crashlytics_export_strings.xml -+crashlytics.properties -+crashlytics-build.properties -+fabric.properties -+ -+# Editor-based Rest Client -+.idea/httpRequests -+ -+# Android studio 3.1+ serialized cache file -+.idea/caches/build_file_checksums.ser -+ -+### PyCharm Patch ### -+# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 -+ -+# *.iml -+# modules.xml -+# .idea/misc.xml -+# *.ipr -+ -+# Sonarlint plugin -+.idea/**/sonarlint/ -+ -+# SonarQube Plugin -+.idea/**/sonarIssues.xml -+ -+# Markdown Navigator plugin -+.idea/**/markdown-navigator.xml -+.idea/**/markdown-navigator/ -+ -+### Python ### -+# Byte-compiled / optimized / DLL files -+ -+# C extensions -+ -+# Distribution / packaging -+ -+# PyInstaller -+# Usually these files are written by a python script from a template -+# before PyInstaller builds the exe, so as to inject date/other infos into it. -+ -+# Installer logs -+ -+# Unit test / coverage reports -+ -+# Translations -+ -+# Scrapy stuff: -+ -+# Sphinx documentation -+ -+# PyBuilder -+ -+# pyenv -+ -+# pipenv -+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -+# However, in case of collaboration, if having platform-specific dependencies or dependencies -+# having no cross-platform support, pipenv may install dependencies that don't work, or not -+# install all needed dependencies. -+ -+# celery beat schedule file -+ -+# SageMath parsed files -+ -+# Spyder project settings -+ -+# Rope project settings -+ -+# Mr Developer -+ -+# mkdocs documentation -+ -+# mypy -+ -+# Pyre type checker -+ -+### Sass ### -+.sass-cache/ -+*.css.map -+*.sass.map -+*.scss.map -+ -+### SublimeText ### -+# Cache files for Sublime Text -+*.tmlanguage.cache -+*.tmPreferences.cache -+*.stTheme.cache -+ -+# Workspace files are user-specific -+*.sublime-workspace -+ -+# Project files should be checked into the repository, unless a significant -+# proportion of contributors will probably not be using Sublime Text -+# *.sublime-project -+ -+# SFTP configuration file -+sftp-config.json -+ -+# Package control specific files -+Package Control.last-run -+Package Control.ca-list -+Package Control.ca-bundle -+Package Control.system-ca-bundle -+Package Control.cache/ -+Package Control.ca-certs/ -+Package Control.merged-ca-bundle -+Package Control.user-ca-bundle -+oscrypto-ca-bundle.crt -+bh_unicode_properties.cache -+ -+# Sublime-github package stores a github token in this file -+# https://packagecontrol.io/packages/sublime-github -+GitHub.sublime-settings -+ -+### Vim ### -+# Swap -+[._]*.s[a-v][a-z] -+[._]*.sw[a-p] -+[._]s[a-rt-v][a-z] -+[._]ss[a-gi-z] -+[._]sw[a-p] -+ -+# Session -+Session.vim -+Sessionx.vim -+ -+# Temporary -+.netrwhist -+ -+# Auto-generated tag files -+tags -+ -+# Persistent undo -+[._]*.un~ -+ -+# Coc configuration directory -+.vim -+ -+### VirtualEnv ### -+# Virtualenv -+# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ -+pyvenv.cfg -+.venv -+env/ -+venv/ -+ENV/ -+env.bak/ -+venv.bak/ -+pip-selfcheck.json -+ -+### VisualStudioCode ### -+.vscode/* -+!.vscode/settings.json -+!.vscode/tasks.json -+!.vscode/launch.json -+!.vscode/extensions.json -+ -+### VisualStudioCode Patch ### -+# Ignore all local history of files -+.history -+ -+### Vuejs ### -+# Recommended template: Node.gitignore -+ -+npm-debug.log -+yarn-error.log -+ -+### Windows ### -+# Windows thumbnail cache files -+Thumbs.db -+Thumbs.db:encryptable -+ehthumbs.db -+ehthumbs_vista.db -+ -+# Dump file -+*.stackdump -+ -+# Folder config file -+[Dd]esktop.ini -+ -+# Recycle Bin used on file shares -+$RECYCLE.BIN/ -+ -+# Windows Installer files -+*.cab -+*.msi -+*.msix -+*.msm -+*.msp -+ -+# Windows shortcuts -+*.lnk -+ -+# End of https://www.gitignore.io/api/vim,node,sass,vuejs,linux,macos,django,python,pycharm,windows,virtualenv,sublimetext,visualstudiocode - --# Sphinx --docs/_build - - *.sqlite -+data -diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml -new file mode 100644 -index 0000000..30dc5aa ---- /dev/null -+++ b/.pre-commit-config.yaml -@@ -0,0 +1,62 @@ -+# See https://pre-commit.com for more information -+# See https://pre-commit.com/hooks.html for more hooks -+exclude: "(.idea|node_modules|.tox)" -+repos: -+ - repo: https://github.com/pre-commit/pre-commit-hooks -+ rev: v3.3.0 -+ hooks: -+ - id: trailing-whitespace -+ - id: end-of-file-fixer -+ - id: check-yaml -+ - id: check-added-large-files -+ - id: check-builtin-literals -+ - id: check-executables-have-shebangs -+ - id: check-merge-conflict -+ - id: check-toml -+ - id: fix-encoding-pragma -+ args: -+ - --remove -+ - repo: https://github.com/timothycrosley/isort -+ rev: "5.6.4" -+ hooks: -+ - id: isort -+ - repo: https://github.com/psf/black -+ rev: 20.8b1 -+ hooks: -+ - id: black -+ - repo: https://gitlab.com/pycqa/flake8 -+ rev: 3.8.4 -+ hooks: -+ - id: flake8 -+ additional_dependencies: -+ - flake8-broken-line -+ - flake8-bugbear -+ - flake8-builtins -+ - flake8-coding -+ - flake8-commas -+ - flake8-comprehensions -+ - flake8-eradicate -+ - flake8-quotes -+ - flake8-tidy-imports -+ - pep8-naming -+ - repo: https://github.com/econchick/interrogate -+ rev: 1.3.1 -+ hooks: -+ - id: interrogate -+ args: -+ - "-cpyproject.toml" -+ - "--quiet" -+ - repo: https://github.com/asottile/pyupgrade -+ rev: v2.7.3 -+ hooks: -+ - id: pyupgrade -+ args: -+ - --py3-plus -+ - repo: local -+ hooks: -+ - id: towncrier -+ name: towncrier -+ entry: inv towncrier-check -+ language: system -+ pass_filenames: false -+ always_run: true -diff --git a/.pyup.yml b/.pyup.yml -new file mode 100644 -index 0000000..2809577 ---- /dev/null -+++ b/.pyup.yml -@@ -0,0 +1,7 @@ -+update: all -+pin: False -+branch: -+schedule: "every day" -+search: True -+branch_prefix: pyup/ -+close_prs: True -diff --git a/.readthedocs.yaml b/.readthedocs.yaml -new file mode 100644 -index 0000000..bbd8063 ---- /dev/null -+++ b/.readthedocs.yaml -@@ -0,0 +1,19 @@ -+version: 2 -+ -+sphinx: -+ configuration: docs/conf.py -+ fail_on_warning: false -+ -+formats: -+ - epub -+ - pdf -+ -+python: -+ version: 3.7 -+ install: -+ - requirements: requirements-test.txt -+ - method: pip -+ path: . -+ extra_requirements: -+ - docs -+ system_packages: false -diff --git a/.travis.yml b/.travis.yml -deleted file mode 100644 -index 0d82458..0000000 ---- a/.travis.yml -+++ /dev/null -@@ -1,61 +0,0 @@ --language: python --dist: xenial -- --python: -- - 3.7 -- - 3.6 -- - 3.5 -- - 2.7 -- --env: -- matrix: -- - TOXENV='pep8' -- - TOXENV='isort' -- - TOXENV='docs' -- - DJANGO='django111' CMS='cms40' FE=1 -- - DJANGO='django21' CMS='cms40' FE=1 -- - DJANGO='django22' CMS='cms40' FE=1 -- -- --# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors --install: -- - pip install -U setuptools tox>=1.8 coveralls -- - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PYVER=py27; fi" -- - "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PYVER=py35; fi" -- - "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export PYVER=py36; fi" -- - "if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then export PYVER=py37; fi" -- - "if [[ ${DJANGO}z != 'z' ]]; then export TOXENV=$PYVER-$DJANGO-$CMS; fi" -- --# command to run tests, e.g. python setup.py test --script: COMMAND='coverage run' tox -e$TOXENV -- --before_install: -- - pip install codecov --after_success: -- - codecov -- - coveralls -- --matrix: -- exclude: -- - python: 2.7 -- env: TOXENV='pep8' -- - python: 2.7 -- env: TOXENV='isort' -- - python: 2.7 -- env: TOXENV='docs' -- - python: 3.5 -- env: TOXENV='pep8' -- - python: 3.5 -- env: TOXENV='isort' -- - python: 3.5 -- env: TOXENV='docs' -- - python: 3.6 -- env: TOXENV='pep8' -- - python: 3.6 -- env: TOXENV='isort' -- - python: 3.6 -- env: TOXENV='docs' -- - python: 2.7 -- env: DJANGO='django22' CMS='cms40' FE=1 -- - python: 2.7 -- env: DJANGO='django21' CMS='cms40' FE=1 -diff --git a/.tx/config b/.tx/config -index de298f4..8520dcd 100644 ---- a/.tx/config -+++ b/.tx/config -@@ -5,4 +5,3 @@ host = https://www.transifex.com - file_filter = djangocms_page_sitemap/locale//LC_MESSAGES/django.po - source_file = djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po - source_lang = en -- -diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst -index c57411e..f2cc28b 100644 ---- a/CONTRIBUTING.rst -+++ b/CONTRIBUTING.rst -@@ -3,7 +3,7 @@ Contributing - ============ - - Contributions are welcome, and they are greatly appreciated! Every --little bit helps, and credit will always be given. -+little bit helps, and credit will always be given. - - You can contribute in many ways: - -@@ -11,7 +11,7 @@ Types of Contributions - ---------------------- - - Report Bugs --~~~~~~~~~~~ -+=========== - - Report bugs at https://github.com/nephila/djangocms-page-sitemap/issues. - -@@ -22,26 +22,26 @@ If you are reporting a bug, please include: - * Detailed steps to reproduce the bug. - - Fix Bugs --~~~~~~~~ -+======== - - Look through the GitHub issues for bugs. Anything tagged with "bug" - is open to whoever wants to implement it. - - Implement Features --~~~~~~~~~~~~~~~~~~ -+================== - - Look through the GitHub issues for features. Anything tagged with "feature" - is open to whoever wants to implement it. - - Write Documentation --~~~~~~~~~~~~~~~~~~~ -+=================== - --djangocms-page-sitemap could always use more documentation, whether as part of the -+djangocms-page-sitemap could always use more documentation, whether as part of the - official djangocms-page-sitemap docs, in docstrings, or even on the web in blog posts, - articles, and such. - - Submit Feedback --~~~~~~~~~~~~~~~ -+=============== - - The best way to send feedback is to file an issue at https://github.com/nephila/djangocms-page-sitemap/issues. - -@@ -52,8 +52,9 @@ If you are proposing a feature: - * Remember that this is a volunteer-driven project, and that contributions - are welcome :) - -+************ - Get Started! -------------- -+************ - - Ready to contribute? Here's how to set up `djangocms-page-sitemap` for local development. - -@@ -66,7 +67,8 @@ Ready to contribute? Here's how to set up `djangocms-page-sitemap` for local dev - - $ mkvirtualenv djangocms-page-sitemap - $ cd djangocms-page-sitemap/ -- $ python setup.py develop -+ $ pip install -r requirements-test.txt -+ $ pip install -e . - - 4. Create a branch for local development:: - -@@ -77,11 +79,9 @@ Now you can make your changes locally. - 5. When you're done making changes, check that your changes pass flake8 and the - tests, including testing other Python versions with tox:: - -- $ flake8 djangocms_page_sitemap tests -- $ python setup.py test - $ tox - --To get flake8 and tox, just pip install them into your virtualenv. -+To get flake8 and tox, just pip install them into your virtualenv. - - 6. Commit your changes and push your branch to GitHub:: - -@@ -91,22 +91,75 @@ To get flake8 and tox, just pip install them into your virtualenv. - - 7. Submit a pull request through the GitHub website. - --Pull Request Guidelines ------------------------- -+Development tips -+---------------- - --Before you submit a pull request, check that it meets these guidelines: -+This project allows you to use `pre-commit `_ to ensure an easy compliance -+to the project code styles. - --1. The pull request should include tests. --2. If the pull request adds functionality, the docs should be updated. Put -- your new functionality into a function with a docstring, and add the -- feature to the list in README.rst. --3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check -- https://travis-ci.org/nephila/djangocms-page-sitemap/pull_requests -- and make sure that the tests pass for all supported Python versions. -+If you want to use it, install it globally (for example with ``pip3 install --user precommit``, -+but check `installation instruction `_. -+When first cloning the project ensure you install the git hooks by running ``pre-commit install``. - --Tips ------ -+From now on every commit will be checked against our code style. -+ -+Check also the available tox environments with ``tox -l``: the ones not marked with a python version number are tools -+to help you work on the project buy checking / formatting code style, running docs etc. -+ -+Testing tips -+------------ -+You can test your project using any specific combination of python, django and django cms. - --To run a subset of tests:: -+For example ``tox -epy3.7-django30-cms37`` runs the tests on python 3.7, Django 3.0 and django CMS 3.7. -+ -+ -+Pull Request Guidelines -+======================= -+ -+Before you submit a pull request, check that it meets these guidelines: - -- $ python -m unittest tests.test_djangocms_page_sitemap -\ No newline at end of file -+#. Pull request must be named with the following naming scheme: -+ -+ ``/(-)-description`` -+ -+ See below for available types. -+ -+#. The pull request should include tests. -+#. If the pull request adds functionality, the docs should be updated. -+ Documentation must be added in ``docs`` directory, and must include usage -+ information for the end user. -+ In case of public API method, add extended docstrings with full parameters -+ description and usage example. -+#. Add a changes file in ``changes`` directory describing the contribution in -+ one line. It will be added automatically to the history file upon release. -+ File must be named as ``.`` with type being: -+ -+ * ``.feature``: For new features. -+ * ``.bugfix``: For bug fixes. -+ * ``.doc``: For documentation improvement. -+ * ``.removal``: For deprecation or removal of public API. -+ * ``.misc``: For general issues. -+ -+ Check `towncrier`_ documentation for more details. -+ -+#. The pull request should work for all python / django / django CMS versions -+ declared in tox.ini. -+ Check the CI and make sure that the tests pass for all supported versions. -+ -+Release a version -+================= -+ -+#. Update authors file -+#. Merge ``develop`` on ``master`` branch -+#. Bump release via task: ``inv tag-release (major|minor|patch)`` -+#. Update changelog via towncrier: ``towncrier --yes`` -+#. Commit changelog with ``git commit --amend`` to merge with bumpversion commit -+#. Create tag ``git tag `` -+#. Push tag to github -+#. Publish the release from the tags page -+#. If pipeline succeeds, push ``master`` -+#. Merge ``master`` back on ``develop`` -+#. Bump developement version via task: ``inv tag-dev -l (major|minor|patch)`` -+#. Push ``develop`` -+ -+.. _towncrier: https://pypi.org/project/towncrier/#news-fragments -diff --git a/HISTORY.rst b/HISTORY.rst -index b98f145..4e0f054 100644 ---- a/HISTORY.rst -+++ b/HISTORY.rst -@@ -1,22 +1,32 @@ - .. :changelog: - -+******* - History --------- -+******* - -+.. towncrier release notes start - --0.9.0 (unreleased) --++++++++++++++++++ -+1.0.0 (2020-12-21) -+================== - --* Port to django CMS 4.0 --* Fix djangocms-versioning integration -+Features -+-------- -+ -+- Add support for django-app-enabler (#63) -+- Update tooling and drop Python 2 / Django < 2.2 compatibility (#10208) -+ -+0.8.1 (2020-05-02) -+================== -+ -+* Enable django CMS 3.7.2 on python 3 - - 0.8.0 (2020-01-12) --++++++++++++++++++ -+================== - - * Relicense under BSD license - - 0.7.0 (2019-08-22) --++++++++++++++++++ -+================== - - * Add compatibility with Django 2.2 - * Drop compatibility with Django < 1.11 -@@ -24,36 +34,36 @@ History - * Move to django-app-helper - - 0.6.0 (2019-07-13) --++++++++++++++++++ -+================== - - * Drop compatibility with Django < 1.11 - * Drop compatibility with Python 3 < 3.5 - - 0.5.4 (2019-07-13) --++++++++++++++++++ -+================== - - * Fix error when page_robots is executed outside a request - * Fix tox for older environments - - 0.5.3 (2019-03-09) --++++++++++++++++++ -+================== - - * Add Django 2.0, 2.1 support - * Add django CMS 3.6 support - * Apply workaround to avoid triggering ``Page.site_id`` deprecation warning - - 0.5.2 (2018-04-07) --++++++++++++++++++ -+================== - - * Make robots_extra not required - - 0.5.1 (2018-02-27) --++++++++++++++++++ -+================== - - * Fix error in migration dependencies - - 0.5.0 (2018-02-22) --++++++++++++++++++ -+================== - - * Add Django 1.11 support - * Add django CMS 3.5 support -@@ -61,45 +71,45 @@ History - * Add support for noindex, noarchive robots meta tag - - 0.4.3 (2019-07-13) --++++++++++++++++++ -+================== - - * Fix error when page_robots is executed outside a request - * Fix tox for older environments - - 0.4.2 (2019-04-08) --++++++++++++++++++ -+================== - - * Add support for noindex, noarchive robots meta tag - - 0.4.1 (2016-12-02) --++++++++++++++++++ -+================== - - * Add Django 1.10 support - - 0.4.0 (2016-10-26) --++++++++++++++++++ -+================== - - * Drop compatibility with django CMS 3.1 and below, Django 1.7 and below - - 0.3.1 (2015-10-18) --++++++++++++++++++ -+================== - - * Improve defaults - - 0.3.0 (2015-10-18) --++++++++++++++++++ -+================== - - * Add Python 3.5 - * Add option to exclude page from sitemap - - 0.2.0 (2015-08-15) --++++++++++++++++++ -+================== - - * Update to support django CMS 3.1 - * Drop support for Django 1.4, 1.5 - * Add support for Django 1.8 - - 0.1.0 (2014-08-26) --++++++++++++++++++ -+================== - - * Initial version. -diff --git a/LICENSE b/LICENSE -index ea1677b..87312ae 100644 ---- a/LICENSE -+++ b/LICENSE -@@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification, - - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - --* Neither the name of djangocms-page-meta nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -+* Neither the name of djangocms-page-sitemap nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - --THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -\ No newline at end of file -+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -diff --git a/MANIFEST.in b/MANIFEST.in -index baadc97..3c9876f 100644 ---- a/MANIFEST.in -+++ b/MANIFEST.in -@@ -3,4 +3,5 @@ include CONTRIBUTING.rst - include HISTORY.rst - include LICENSE - include README.rst --recursive-include djangocms_page_sitemap *.html *.png *.gif *js *.css *jpg *jpeg *svg *py -\ No newline at end of file -+include requirements.txt -+recursive-include djangocms_page_sitemap *.html *.png *.gif *js *jpg *jpeg *svg *py *po *mo *css -diff --git a/Makefile b/Makefile -deleted file mode 100644 -index a60f029..0000000 ---- a/Makefile -+++ /dev/null -@@ -1,46 +0,0 @@ --.PHONY: clean-pyc clean-build docs -- --help: -- @echo "clean-build - remove build artifacts" -- @echo "clean-pyc - remove Python file artifacts" -- @echo "lint - check style with flake8" -- @echo "test - run tests quickly with the default Python" -- @echo "test-all - run tests on every Python version with tox" -- @echo "coverage - check code coverage quickly with the default Python" -- @echo "release - package and upload a release" -- @echo "sdist - package" -- --clean: clean-build clean-pyc -- --clean-build: -- python setup.py clean --all -- rm -fr build/ -- rm -fr dist/ -- rm -fr *.egg-info -- --clean-pyc: -- find . -name '*.pyc' -exec rm -f {} + -- find . -name '*.pyo' -exec rm -f {} + -- find . -name '*~' -exec rm -f {} + -- --lint: -- tox -epep8,isort -- --test: -- python setup.py test -- --test-all: -- tox -- --coverage: -- coverage erase -- coverage run setup.py test -- coverage report -m -- --release: clean -- python setup.py clean --all sdist bdist_wheel -- twine upload dist/* -- --sdist: clean -- python setup.py sdist -- ls -l dist -diff --git a/docs/Makefile b/docs/Makefile -index 1005e26..0e35bee 100644 ---- a/docs/Makefile -+++ b/docs/Makefile -@@ -174,4 +174,4 @@ xml: - pseudoxml: - $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml - @echo -- @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." -\ No newline at end of file -+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." -diff --git a/docs/authors.rst b/docs/authors.rst -index 94292d0..e122f91 100644 ---- a/docs/authors.rst -+++ b/docs/authors.rst -@@ -1 +1 @@ --.. include:: ../AUTHORS.rst -\ No newline at end of file -+.. include:: ../AUTHORS.rst -diff --git a/docs/conf.py b/docs/conf.py -index 8907b6c..6ab7aa7 100644 ---- a/docs/conf.py -+++ b/docs/conf.py -@@ -1,4 +1,3 @@ --# -*- coding: utf-8 -*- - # - # complexity documentation build configuration file, created by - # sphinx-quickstart on Tue Jul 9 22:26:36 2013. -@@ -11,45 +10,46 @@ - # All configuration values have a default; values that are commented out - # serve to show the default. - -+# fmt: off - import os - import sys - - # If extensions (or modules to document with autodoc) are in another directory, - # add these directories to sys.path here. If the directory is relative to the - # documentation root, use os.path.abspath to make it absolute, like shown here. --#sys.path.insert(0, os.path.abspath('.')) -+# sys.path.insert(0, os.path.abspath('.')) - - cwd = os.getcwd() - parent = os.path.dirname(cwd) - sys.path.append(parent) - --import djangocms_page_sitemap # isort:skip -- -+import djangocms_page_sitemap # isort:skip # noqa -+# fmt: on - - # -- General configuration ----------------------------------------------------- - - # If your documentation needs a minimal Sphinx version, state it here. --#needs_sphinx = '1.0' -+# needs_sphinx = '1.0' - - # Add any Sphinx extension module names here, as strings. They can be extensions - # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. --extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] -+extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"] - - # Add any paths that contain templates here, relative to this directory. --templates_path = ['_templates'] -+templates_path = ["_templates"] - - # The suffix of source filenames. --source_suffix = '.rst' -+source_suffix = ".rst" - - # The encoding of source files. --#source_encoding = 'utf-8-sig' -+# source_encoding = 'utf-8-sig' - - # The master toctree document. --master_doc = 'index' -+master_doc = "index" - - # General information about the project. --project = u'djangocms-page-sitemap' --copyright = u'2014, Iacopo Spalletti' -+project = "djangocms-page-sitemap" -+copyright = "2014, Iacopo Spalletti" # noqa # A001 - - # The version info for the project you're documenting, acts as replacement for - # |version| and |release|, also used in various other places throughout the -@@ -62,71 +62,71 @@ - - # The language for content autogenerated by Sphinx. Refer to documentation - # for a list of supported languages. --#language = None -+# language = None - - # There are two options for replacing |today|: either, you set today to some - # non-false value, then it is used: --#today = '' -+# today = '' - # Else, today_fmt is used as the format for a strftime call. --#today_fmt = '%B %d, %Y' -+# today_fmt = '%B %d, %Y' - - # List of patterns, relative to source directory, that match files and - # directories to ignore when looking for source files. --exclude_patterns = ['_build'] -+exclude_patterns = ["_build"] - - # The reST default role (used for this markup: `text`) to use for all documents. --#default_role = None -+# default_role = None - - # If true, '()' will be appended to :func: etc. cross-reference text. --#add_function_parentheses = True -+# add_function_parentheses = True - - # If true, the current module name will be prepended to all description - # unit titles (such as .. function::). --#add_module_names = True -+# add_module_names = True - - # If true, sectionauthor and moduleauthor directives will be shown in the - # output. They are ignored by default. --#show_authors = False -+# show_authors = False - - # The name of the Pygments (syntax highlighting) style to use. --pygments_style = 'sphinx' -+pygments_style = "sphinx" - - # A list of ignored prefixes for module index sorting. --#modindex_common_prefix = [] -+# modindex_common_prefix = [] - - # If true, keep warnings as "system message" paragraphs in the built documents. --#keep_warnings = False -+# keep_warnings = False - - - # -- Options for HTML output --------------------------------------------------- - - # The theme to use for HTML and HTML Help pages. See the documentation for - # a list of builtin themes. --html_theme = 'default' -+html_theme = "default" - - # Theme options are theme-specific and customize the look and feel of a theme - # further. For a list of options available for each theme, see the - # documentation. --#html_theme_options = {} -+# html_theme_options = {} - - # Add any paths that contain custom themes here, relative to this directory. --#html_theme_path = [] -+# html_theme_path = [] - - # The name for this set of Sphinx documents. If None, it defaults to - # " v documentation". --#html_title = None -+# html_title = None - - # A shorter title for the navigation bar. Default is the same as html_title. --#html_short_title = None -+# html_short_title = None - - # The name of an image file (relative to this directory) to place at the top - # of the sidebar. --#html_logo = None -+# html_logo = None - - # The name of an image file (within the static path) to use as favicon of the - # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 - # pixels large. --#html_favicon = None -+# html_favicon = None - - # Add any paths that contain custom static files (such as style sheets) here, - # relative to this directory. They are copied after the builtin static files, -@@ -135,88 +135,91 @@ - - # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, - # using the given strftime format. --#html_last_updated_fmt = '%b %d, %Y' -+# html_last_updated_fmt = '%b %d, %Y' - - # If true, SmartyPants will be used to convert quotes and dashes to - # typographically correct entities. --#html_use_smartypants = True -+# html_use_smartypants = True - - # Custom sidebar templates, maps document names to template names. --#html_sidebars = {} -+# html_sidebars = {} - - # Additional templates that should be rendered to pages, maps page names to - # template names. --#html_additional_pages = {} -+# html_additional_pages = {} - - # If false, no module index is generated. --#html_domain_indices = True -+# html_domain_indices = True - - # If false, no index is generated. --#html_use_index = True -+# html_use_index = True - - # If true, the index is split into individual pages for each letter. --#html_split_index = False -+# html_split_index = False - - # If true, links to the reST sources are added to the pages. --#html_show_sourcelink = True -+# html_show_sourcelink = True - - # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. --#html_show_sphinx = True -+# html_show_sphinx = True - - # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. --#html_show_copyright = True -+# html_show_copyright = True - - # If true, an OpenSearch description file will be output, and all pages will - # contain a tag referring to it. The value of this option must be the - # base URL from which the finished HTML is served. --#html_use_opensearch = '' -+# html_use_opensearch = '' - - # This is the file name suffix for HTML files (e.g. ".xhtml"). --#html_file_suffix = None -+# html_file_suffix = None - - # Output file base name for HTML help builder. --htmlhelp_basename = 'djangocms-page-sitemapdoc' -+htmlhelp_basename = "djangocms-page-sitemapdoc" - - - # -- Options for LaTeX output -------------------------------------------------- - - latex_elements = { --# The paper size ('letterpaper' or 'a4paper'). --#'papersize': 'letterpaper', -- --# The font size ('10pt', '11pt' or '12pt'). --#'pointsize': '10pt', -- --# Additional stuff for the LaTeX preamble. --#'preamble': '', -+ # The paper size ('letterpaper' or 'a4paper'). -+ # 'papersize': 'letterpaper', -+ # The font size ('10pt', '11pt' or '12pt'). -+ # 'pointsize': '10pt', -+ # Additional stuff for the LaTeX preamble. -+ # 'preamble': '', - } - - # Grouping the document tree into LaTeX files. List of tuples - # (source start file, target name, title, author, documentclass [howto/manual]). - latex_documents = [ -- ('index', 'djangocms-page-sitemap.tex', u'djangocms-page-sitemap Documentation', -- u'Iacopo Spalletti', 'manual'), -+ ( -+ "index", -+ "djangocms-page-sitemap.tex", -+ "djangocms-page-sitemap Documentation", -+ "Iacopo Spalletti", -+ "manual", -+ ), - ] - - # The name of an image file (relative to this directory) to place at the top of - # the title page. --#latex_logo = None -+# latex_logo = None - - # For "manual" documents, if this is true, then toplevel headings are parts, - # not chapters. --#latex_use_parts = False -+# latex_use_parts = False - - # If true, show page references after internal links. --#latex_show_pagerefs = False -+# latex_show_pagerefs = False - - # If true, show URL addresses after external links. --#latex_show_urls = False -+# latex_show_urls = False - - # Documents to append as an appendix to all manuals. --#latex_appendices = [] -+# latex_appendices = [] - - # If false, no module index is generated. --#latex_domain_indices = True -+# latex_domain_indices = True - - - # -- Options for manual page output -------------------------------------------- -@@ -224,12 +227,17 @@ - # One entry per manual page. List of tuples - # (source start file, name, description, authors, manual section). - man_pages = [ -- ('index', 'djangocms-page-sitemap', u'djangocms-page-sitemap Documentation', -- [u'Iacopo Spalletti'], 1) -+ ( -+ "index", -+ "djangocms-page-sitemap", -+ "djangocms-page-sitemap Documentation", -+ ["Iacopo Spalletti"], -+ 1, -+ ) - ] - - # If true, show URL addresses after external links. --#man_show_urls = False -+# man_show_urls = False - - - # -- Options for Texinfo output ------------------------------------------------ -@@ -238,19 +246,25 @@ - # (source start file, target name, title, author, - # dir menu entry, description, category) - texinfo_documents = [ -- ('index', 'djangocms-page-sitemap', u'djangocms-page-sitemap Documentation', -- u'Iacopo Spalletti', 'djangocms-page-sitemap', 'One line description of project.', -- 'Miscellaneous'), -+ ( -+ "index", -+ "djangocms-page-sitemap", -+ "djangocms-page-sitemap Documentation", -+ "Iacopo Spalletti", -+ "djangocms-page-sitemap", -+ "One line description of project.", -+ "Miscellaneous", -+ ), - ] - - # Documents to append as an appendix to all manuals. --#texinfo_appendices = [] -+# texinfo_appendices = [] - - # If false, no module index is generated. --#texinfo_domain_indices = True -+# texinfo_domain_indices = True - - # How to display URL addresses: 'footnote', 'no', or 'inline'. --#texinfo_show_urls = 'footnote' -+# texinfo_show_urls = 'footnote' - - # If true, do not generate a @detailmenu in the "Top" node's menu. --#texinfo_no_detailmenu = False -+# texinfo_no_detailmenu = False -diff --git a/docs/contributing.rst b/docs/contributing.rst -index 3bdd7dc..e582053 100644 ---- a/docs/contributing.rst -+++ b/docs/contributing.rst -@@ -1 +1 @@ --.. include:: ../CONTRIBUTING.rst -\ No newline at end of file -+.. include:: ../CONTRIBUTING.rst -diff --git a/docs/history.rst b/docs/history.rst -index bec23d8..2506499 100644 ---- a/docs/history.rst -+++ b/docs/history.rst -@@ -1 +1 @@ --.. include:: ../HISTORY.rst -\ No newline at end of file -+.. include:: ../HISTORY.rst -diff --git a/docs/index.rst b/docs/index.rst -index 64f1a54..03c879f 100644 ---- a/docs/index.rst -+++ b/docs/index.rst -@@ -14,4 +14,4 @@ Contents: - readme - contributing - authors -- history -\ No newline at end of file -+ history -diff --git a/docs/make.bat b/docs/make.bat -index 2b44764..2df9a8c 100644 ---- a/docs/make.bat -+++ b/docs/make.bat -@@ -239,4 +239,4 @@ if "%1" == "pseudoxml" ( - goto end - ) - --:end -\ No newline at end of file -+:end -diff --git a/docs/readme.rst b/docs/readme.rst -index 6b2b3ec..72a3355 100644 ---- a/docs/readme.rst -+++ b/docs/readme.rst -@@ -1 +1 @@ --.. include:: ../README.rst -\ No newline at end of file -+.. include:: ../README.rst -diff --git a/pyproject.toml b/pyproject.toml -new file mode 100644 -index 0000000..f1ec81a ---- /dev/null -+++ b/pyproject.toml -@@ -0,0 +1,30 @@ -+[build-system] -+requires = ["setuptools>=40.6.0", "wheel"] -+build-backend = "setuptools.build_meta" -+ -+[tool.black] -+line-length = 119 -+target-version = ["py36"] -+include = 'djangocms_page_sitemap/*py' -+ -+[tool.towncrier] -+package = "djangocms_page_sitemap" -+directory = "changes" -+filename = "HISTORY.rst" -+title_format = "{version} ({project_date})" -+ -+[tool.interrogate] -+ignore-init-method = true -+ignore-init-module = true -+ignore-magic = false -+ignore-semiprivate = false -+ignore-private = false -+ignore-module = true -+ignore-nested-functions = true -+fail-under = 0 -+exclude = ["docs", ".tox"] -+ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"] -+verbose = 0 -+quiet = false -+whitelist-regex = [] -+color = true -diff --git a/requirements-docs.txt b/requirements-docs.txt -deleted file mode 100644 -index 57ccf60..0000000 ---- a/requirements-docs.txt -+++ /dev/null -@@ -1,2 +0,0 @@ ---r requirements-test.txt --Django<3.0 -diff --git a/requirements-test.txt b/requirements-test.txt -index 9e809d5..4f6ebe2 100644 ---- a/requirements-test.txt -+++ b/requirements-test.txt -@@ -1,5 +1,5 @@ --coverage<5.0 --coveralls --flake8>=2.1.0 --tox>=2.0 --django-app-helper -+-e .[docs] -+coverage>5 -+coveralls>2 -+mock>=1.0.1 -+django-app-helper>=2.0.0 -diff --git a/requirements.txt b/requirements.txt -index ecf975e..d6e1198 100644 ---- a/requirements.txt -+++ b/requirements.txt -@@ -1 +1 @@ ---e . -\ No newline at end of file -+-e . -diff --git a/setup.cfg b/setup.cfg -index 6bd9ba4..84a0f85 100644 ---- a/setup.cfg -+++ b/setup.cfg -@@ -1,20 +1,72 @@ --[flake8] --exclude = *.egg-info,*.eggs,.git,.settings,.tox,build,dist,docs,requirements,tmp,*migrations*,*south_migrations*,tests,data --ignore = E305, W504 --max-line-length = 99 -+[bumpversion] -+current_version = 1.0.0 -+parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) -+serialize = -+ {major}.{minor}.{patch}.{release}{relver} -+ {major}.{minor}.{patch} -+commit = True -+tag = True -+sign_tags = True -+tag_name = {new_version} -+message = Release {new_version} -+ -+[bumpversion:part:release] -+optional_value = gamma -+values = -+ dev -+ a -+ b -+ rc -+ gamma -+ -+[bumpversion:file:djangocms_page_sitemap/__init__.py] - - [metadata] --license-file = LICENSE -+name = djangocms-page-sitemap -+version = attr: djangocms_page_sitemap.__version__ -+url = https://github.com/nephila/djangocms-page-sitemap -+project_urls = -+ Documentation = https://djangocms-page-sitemap.readthedocs.io/ -+author = Iacopo Spalletti -+author_email = i.spalletti@nephila.it -+description = django CMS page extension to handle sitemap customization -+long_description = file: README.rst, HISTORY.rst -+long_description_content_type = text/x-rst -+license = BSD -+license_file = LICENSE -+keywords = django cms, sitemap, django-app-enabler addon -+classifiers = -+ Development Status :: 5 - Production/Stable -+ Framework :: Django -+ Intended Audience :: Developers -+ License :: OSI Approved :: BSD License -+ Natural Language :: English -+ Framework :: Django -+ Framework :: Django :: 2.2 -+ Programming Language :: Python :: 3.6 -+ Programming Language :: Python :: 3.7 - --[wheel] --universal = 1 -+[options] -+include_package_data = True -+install_requires = -+ django-cms>=3.6 -+setup_requires = -+ setuptools -+packages = djangocms_page_sitemap -+python_requires = >=3.6 -+zip_safe = False -+test_suite = cms_helper.run -+ -+[options.package_data] -+* = *.txt, *.rst -+djangcms_page_sitemap = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po - --[isort] --line_length = 99 --skip = migrations, south_migrations --combine_as_imports = true --default_section = THIRDPARTY --include_trailing_comma = true --known_first_party = djangocms_page_sitemap --multi_line_output = 5 --not_skip = __init__.py -+[options.extras_require] -+docs = -+ django<3.1 -+ -+[upload] -+repository = https://upload.pypi.org/legacy/ -+ -+[bdist_wheel] -+universal = 1 -diff --git a/setup.py b/setup.py -old mode 100755 -new mode 100644 -index c2fbabb..b908cbe ---- a/setup.py -+++ b/setup.py -@@ -1,63 +1,3 @@ --#!/usr/bin/env python --# -*- coding: utf-8 -*- -+import setuptools - --import os --import sys -- --import djangocms_page_sitemap -- --try: -- from setuptools import setup --except ImportError: -- from distutils.core import setup -- --version = djangocms_page_sitemap.__version__ -- --if sys.argv[-1] == 'publish': -- os.system('python setup.py sdist upload') -- print("You probably want to also tag the version now:") -- print(" git tag -a %s -m 'version %s'" % (version, version)) -- print(" git push --tags") -- sys.exit() -- --readme = open('README.rst').read() --history = open('HISTORY.rst').read().replace('.. :changelog:', '') -- --setup( -- name='djangocms-page-sitemap', -- version=version, -- description="""django CMS page extension to handle sitemap customization""", -- long_description=readme + '\n\n' + history, -- author='Iacopo Spalletti', -- author_email='i.spalletti@nephila.it', -- url='https://github.com/nephila/djangocms-page-sitemap', -- packages=[ -- 'djangocms_page_sitemap', -- ], -- include_package_data=True, -- license='BSD', -- zip_safe=False, -- keywords='djangocms-page-sitemap', -- test_suite='cms_helper.run', -- classifiers=[ -- 'Development Status :: 5 - Production/Stable', -- 'Framework :: Django', -- 'Intended Audience :: Developers', -- 'License :: OSI Approved :: BSD License', -- 'Natural Language :: English', -- 'Framework :: Django', -- 'Framework :: Django :: 1.11', -- 'Framework :: Django :: 2.0', -- 'Framework :: Django :: 2.1', -- 'Framework :: Django :: 2.2', -- 'Programming Language :: Python :: 2', -- 'Programming Language :: Python :: 2.7', -- 'Programming Language :: Python :: 3', -- 'Programming Language :: Python :: 3.5', -- 'Programming Language :: Python :: 3.6', -- 'Programming Language :: Python :: 3.7', -- ], -- dependency_links=[ -- "http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms-4.0.0", -- ], --) -+setuptools.setup() -diff --git a/tasks.py b/tasks.py -new file mode 100644 -index 0000000..82261dd ---- /dev/null -+++ b/tasks.py -@@ -0,0 +1,140 @@ -+import io -+import os -+import re -+import sys -+from glob import glob -+ -+from invoke import task -+ -+DOCS_PORT = os.environ.get("DOCS_PORT", 8000) -+#: branch prefixes for which some checks are skipped -+SPECIAL_BRANCHES = ("master", "develop", "release") -+ -+ -+@task -+def clean(c): -+ """ Remove artifacts and binary files. """ -+ c.run("python setup.py clean --all") -+ patterns = ["build", "dist"] -+ patterns.extend(glob("*.egg*")) -+ patterns.append("docs/_build") -+ patterns.append("**/*.pyc") -+ for pattern in patterns: -+ c.run("rm -rf {}".format(pattern)) -+ -+ -+@task -+def lint(c): -+ """ Run linting tox environments. """ -+ c.run("tox -epep8,isort,black,pypi-description") -+ -+ -+@task # NOQA -+def format(c): # NOQA -+ """ Run code formatting tasks. """ -+ c.run("tox -eblacken,isort_format") -+ -+ -+@task -+def towncrier_check(c): # NOQA -+ """ Check towncrier files. """ -+ output = io.StringIO() -+ c.run("git branch --contains HEAD", out_stream=output) -+ skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"] -+ # cleanup branch names by removing PR-only names in local, remote and disconnected branches to ensure the current -+ # (i.e. user defined) branch name is used -+ branches = list( -+ filter( -+ lambda x: x and all(not x.startswith(part) for part in skipped_branch_prefix), -+ ( -+ branch.replace("origin/", "").replace("remotes/", "").strip("* (") -+ for branch in output.getvalue().split("\n") -+ ), -+ ) -+ ) -+ print("Candidate branches", ", ".join(output.getvalue().split("\n"))) -+ if not branches: -+ # if no branch name matches, we are in one of the excluded branches above, so we just exit -+ print("Skip check, branch excluded by configuration") -+ return -+ branch = branches[0] -+ towncrier_file = None -+ for branch in branches: -+ if any(branch.startswith(prefix) for prefix in SPECIAL_BRANCHES): -+ sys.exit(0) -+ try: -+ parts = re.search(r"(?P\w+)/\D*(?P\d+)\D*", branch).groups() -+ towncrier_file = os.path.join("changes", "{1}.{0}".format(*parts)) -+ if not os.path.exists(towncrier_file) or os.path.getsize(towncrier_file) == 0: -+ print( -+ "=========================\n" -+ "Current tree does not contain the towncrier file {} or file is empty\n" -+ "please check CONTRIBUTING documentation.\n" -+ "=========================" -+ "".format(towncrier_file) -+ ) -+ sys.exit(2) -+ else: -+ break -+ except AttributeError: -+ pass -+ if not towncrier_file: -+ print( -+ "=========================\n" -+ "Branch {} does not respect the '/(-)-description' format\n" -+ "=========================\n" -+ "".format(branch) -+ ) -+ sys.exit(1) -+ -+ -+@task -+def test(c): -+ """ Run test in local environment. """ -+ c.run("python setup.py test") -+ -+ -+@task -+def test_all(c): -+ """ Run all tox environments. """ -+ c.run("tox") -+ -+ -+@task -+def coverage(c): -+ """ Run test with coverage in local environment. """ -+ c.run("coverage erase") -+ c.run("run setup.py test") -+ c.run("report -m") -+ -+ -+@task -+def tag_release(c, level): -+ """ Tag release version. """ -+ c.run("bumpversion --list %s --no-tag" % level) -+ -+ -+@task -+def tag_dev(c, level="patch"): -+ """ Tag development version. """ -+ c.run("bumpversion --list %s --message='Bump develop version [ci skip]' --no-tag" % level) -+ -+ -+@task(pre=[clean]) -+def docbuild(c): -+ """ Build documentation. """ -+ os.chdir("docs") -+ build_dir = os.environ.get("BUILD_DIR", "_build/html") -+ c.run("python -msphinx -W -b html -d _build/doctrees . %s" % build_dir) -+ -+ -+@task(docbuild) -+def docserve(c): -+ """ Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000). """ -+ from livereload import Server -+ -+ server = Server() -+ server.watch("docs/conf.py", lambda: docbuild(c)) -+ server.watch("CONTRIBUTING.rst", lambda: docbuild(c)) -+ server.watch("docs/*.rst", lambda: docbuild(c)) -+ server.serve(port=DOCS_PORT, root="_build/html") - -From bda90b6fb13fbdebbd05ea741e2562f14ca01d6b Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 10:49:04 +0000 -Subject: [PATCH 02/20] Updated the history - ---- - HISTORY.rst | 17 +++++++---------- - 1 file changed, 7 insertions(+), 10 deletions(-) - -diff --git a/HISTORY.rst b/HISTORY.rst -index 4e0f054..77bdfcc 100644 ---- a/HISTORY.rst -+++ b/HISTORY.rst -@@ -6,19 +6,16 @@ History - - .. towncrier release notes start - --1.0.0 (2020-12-21) --================== -- --Features ---------- -+(unreleased) -+============ - --- Add support for django-app-enabler (#63) --- Update tooling and drop Python 2 / Django < 2.2 compatibility (#10208) -+- Update tooling - --0.8.1 (2020-05-02) --================== -+0.9.0.dev8 (2020-11-23) -+======================= - --* Enable django CMS 3.7.2 on python 3 -+* Port to django CMS 4.0 -+* Fix djangocms-versioning integration - - 0.8.0 (2020-01-12) - ================== - -From 0ff3e573b5c72db4915fa237e7f411b88e8b2d36 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 10:55:30 +0000 -Subject: [PATCH 03/20] Update the test suite to cms4 - ---- - tox.ini | 178 +++++++++++++++++++++++++++++++++++++++++++------------- - 1 file changed, 137 insertions(+), 41 deletions(-) - -diff --git a/tox.ini b/tox.ini -index 62c446f..2432732 100644 ---- a/tox.ini -+++ b/tox.ini -@@ -1,61 +1,157 @@ - [tox] - envlist = -+ black -+ blacken - docs -- pep8 - isort -- py{35,36,37}-django{111,21}-cms40 -- py{35,36,37}-django22-cms40 -- --skip_missing_interpreters=True -+ isort_format -+ pep8 -+ pypi-description -+ towncrier -+ py{39,38,37}-django{32}-cms{40} -+ py{38,37,36}-django{22}-cms{40} - - [testenv] --commands = {env:COMMAND:python} setup.py test -- -+commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} - deps = -- -r{toxinidir}/requirements-test.txt -- -- # Django 1.11 installation requirements -- django111: Django>=1.11,<2.0 -- django111: django-formtools>=2.1<2.2 -- django111: django-sekizai<2.0.0 -- django111: djangocms_admin_style<2.0.0 -- django111: django-classy-tags<2.0.0 -- -- # Django 2.1 installation requirements -- django21: Django>=2.1,<2.2 -- django21: django-sekizai<2.0.0 -- django21: djangocms_admin_style<2.0.0 -- django21: django-classy-tags<2.0.0 -- -- django22: Django>=2.2,<2.3 -- -+ django22: Django>=2.2,<3.0 -+ django32: Django>=3.2,<3.3 - cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip -+ -r {toxinidir}/requirements-test.txt -+passenv = -+ COMMAND -+ PYTEST_* - -- --basepython = -- py35: python3.5 -- py36: python3.6 -- py37: python3.7 -+[testenv:pep8] -+commands = -+ {envpython} -m flake8 -+ {envpython} -minterrogate -c pyproject.toml djangocms_page_sitemap tests -+deps = -+ interrogate -+ flake8 -+ flake8-broken-line -+ flake8-bugbear -+ flake8-builtins -+ flake8-coding -+ flake8-commas -+ flake8-comprehensions -+ flake8-eradicate -+ flake8-quotes -+ flake8-tidy-imports -+ pep8-naming -+skip_install = true - - [testenv:isort] --commands = isort --recursive --check-only --diff {toxinidir} --deps = isort -+commands = -+ {envpython} -m isort -c --df djangocms_page_sitemap tests -+deps = isort>5,<6 - skip_install = true --basepython = python3.5 - --[testenv:pep8] --commands = flake8 --deps = flake8 -+[testenv:isort_format] -+commands = -+ {envpython} -m isort djangocms_page_sitemap tests -+deps = {[testenv:isort]deps} -+skip_install = true -+ -+[testenv:black] -+commands = -+ {envpython} -m black --check --diff . -+deps = black -+skip_install = true -+ -+[testenv:blacken] -+commands = -+ {envpython} -m black . -+deps = {[testenv:black]deps} - skip_install = true --basepython = python3.5 - - [testenv:docs] --changedir = docs --commands= -- sphinx-build -W -b html -d {envtmpdir}/doctrees . {toxinidir}/docs/_build/html -+commands = -+ {envpython} -m invoke docbuild - deps = -+ invoke - sphinx - sphinx-rtd-theme -- -rrequirements-docs.txt -+ sphinx-autobuild -+ livereload~=2.6 -+ -requirements-test.txt -+skip_install = true -+ -+[testenv:towncrier] -+commands = -+ {envpython} -m invoke towncrier-check -+deps = -+ invoke -+skip_install = true -+ -+[testenv:pypi-description] -+commands = -+ {envpython} -m invoke clean -+ {envpython} -m check_manifest -+ {envpython} -m pep517.build . -+ {envpython} -m twine check dist/* -+deps = -+ invoke -+ check-manifest -+ pep517 -+ twine -+skip_install = true -+ -+[testenv:release] -+commands = -+ {envpython} -m invoke clean -+ {envpython} -m check_manifest -+ {envpython} -m pep517.build . -+ {envpython} -m twine upload {posargs} dist/* -+deps = {[testenv:pypi-description]deps} -+passenv = -+ TWINE_* - skip_install = true --basepython = python3.5 -+ -+[flake8] -+exclude = *.egg-info,.git,.settings,.tox,build,dist,docs,requirements,tmp,*migrations*,tests,data -+ignore = E800, W503, C812, C813, C815, C818, C819, C408 -+max-line-length = 119 -+# flake8-quotes -+inline-quotes = double -+# flake8-coding -+no-accept-encodings = True -+# flake8-tidy-imports -+banned-modules = __future__ = this project supports python3 only -+ -+[isort] -+combine_as_imports = true -+default_section = THIRDPARTY -+force_grid_wrap = 0 -+include_trailing_comma = true -+known_first_party = djangocms_page_sitemap -+line_length = 119 -+multi_line_output = 3 -+skip = data, .tox -+use_parentheses = True -+ -+[check-manifest] -+ignore = -+ .* -+ *.ini -+ *.toml -+ *.json -+ *.txt -+ *.yml -+ *.yaml -+ .tx/** -+ changes/** -+ docs/** -+ cms_helper.py -+ aldryn_config.py -+ tasks.py -+ tests/** -+ *.mo -+ignore-bad-ideas = -+ *.mo -+ -+[pytest] -+DJANGO_SETTINGS_MODULE = cms_helper -+python_files = test_*.py -+traceback = short -+addopts = --reuse-db - -From 5b9a7d10c291a0bc50afe171e2fbe726b73ead1f Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 11:06:54 +0000 -Subject: [PATCH 04/20] Bring the github workflows in line with the tox - configuration - ---- - .github/workflows/test.yml | 10 ++++------ - 1 file changed, 4 insertions(+), 6 deletions(-) - -diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml -index bac4618..7a29250 100644 ---- a/.github/workflows/test.yml -+++ b/.github/workflows/test.yml -@@ -8,12 +8,10 @@ jobs: - runs-on: ubuntu-latest - strategy: - matrix: -- python-version: [3.8, 3.7, 3.6] -- django: [31, 30, 22] -- cms: [38, 37] -- exclude: -- - django: 31 -- cms: 37 -+ python-version: [39, 38, 37] -+ django: [32, 22] -+ cms: [40] -+ - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - -From 5634acd61372e8ff9b36fa70cf5bfb83fca68016 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 11:10:38 +0000 -Subject: [PATCH 05/20] Fix mismatch of python / django versions in tox and GH - actions - ---- - tox.ini | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/tox.ini b/tox.ini -index 2432732..21c93cc 100644 ---- a/tox.ini -+++ b/tox.ini -@@ -8,8 +8,7 @@ envlist = - pep8 - pypi-description - towncrier -- py{39,38,37}-django{32}-cms{40} -- py{38,37,36}-django{22}-cms{40} -+ py{39,38,37}-django{32,22}-cms{40} - - [testenv] - commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} - -From 15302a1d96ee0cd60b9bdce7926f8e1cc60f7d73 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 15:16:41 +0000 -Subject: [PATCH 06/20] Fix various mismatch issues - ---- - .github/workflows/test.yml | 2 +- - setup.cfg | 10 ++++++---- - 2 files changed, 7 insertions(+), 5 deletions(-) - -diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml -index 7a29250..1f298c8 100644 ---- a/.github/workflows/test.yml -+++ b/.github/workflows/test.yml -@@ -8,7 +8,7 @@ jobs: - runs-on: ubuntu-latest - strategy: - matrix: -- python-version: [39, 38, 37] -+ python-version: [3.9, 3.8, 3.7] - django: [32, 22] - cms: [40] - -diff --git a/setup.cfg b/setup.cfg -index 84a0f85..d01f83f 100644 ---- a/setup.cfg -+++ b/setup.cfg -@@ -1,5 +1,5 @@ - [bumpversion] --current_version = 1.0.0 -+current_version = 0.9.0.dev8 - parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) - serialize = - {major}.{minor}.{patch}.{release}{relver} -@@ -43,17 +43,19 @@ classifiers = - Natural Language :: English - Framework :: Django - Framework :: Django :: 2.2 -- Programming Language :: Python :: 3.6 -+ Framework :: Django :: 3.2 - Programming Language :: Python :: 3.7 -+ Programming Language :: Python :: 3.8 -+ Programming Language :: Python :: 3.9 - - [options] - include_package_data = True - install_requires = -- django-cms>=3.6 -+ django-cms>=3.7 - setup_requires = - setuptools - packages = djangocms_page_sitemap --python_requires = >=3.6 -+python_requires = >=3.7 - zip_safe = False - test_suite = cms_helper.run - - -From 0258afda9a6c6da21b2768b09f8e960f450ef342 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 15:20:41 +0000 -Subject: [PATCH 07/20] Removed all py2 # -*- coding: utf-8 -*- - ---- - djangocms_page_sitemap/__init__.py | 2 +- - djangocms_page_sitemap/admin.py | 2 +- - djangocms_page_sitemap/cms_toolbars.py | 2 +- - djangocms_page_sitemap/migrations/0001_initial.py | 2 +- - djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 2 +- - djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py | 2 +- - djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py | 2 +- - djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py | 2 +- - djangocms_page_sitemap/models.py | 2 +- - djangocms_page_sitemap/settings.py | 2 +- - djangocms_page_sitemap/sitemap.py | 2 +- - djangocms_page_sitemap/sitemap_urls.py | 2 +- - djangocms_page_sitemap/templatetags/__init__.py | 2 +- - djangocms_page_sitemap/templatetags/robots_index.py | 2 +- - djangocms_page_sitemap/utils.py | 2 +- - tests/__init__.py | 2 +- - tests/base.py | 2 +- - tests/test_models.py | 2 +- - tests/test_sitemap.py | 2 +- - tests/test_toolbar.py | 2 +- - tests/test_utils/__init__.py | 2 +- - tests/test_utils/urls.py | 2 +- - 22 files changed, 22 insertions(+), 22 deletions(-) - -diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py -index 7a4e315..59eeade 100644 ---- a/djangocms_page_sitemap/__init__.py -+++ b/djangocms_page_sitemap/__init__.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - __version__ = '0.9.0.dev8' # pragma: no cover -diff --git a/djangocms_page_sitemap/admin.py b/djangocms_page_sitemap/admin.py -index 05e9937..3ecd26c 100644 ---- a/djangocms_page_sitemap/admin.py -+++ b/djangocms_page_sitemap/admin.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from cms.extensions import PageExtensionAdmin -diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py -index 129edb9..50afdfd 100644 ---- a/djangocms_page_sitemap/cms_toolbars.py -+++ b/djangocms_page_sitemap/cms_toolbars.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from cms.toolbar_pool import toolbar_pool -diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py -index 2334e64..bf8ee0b 100644 ---- a/djangocms_page_sitemap/migrations/0001_initial.py -+++ b/djangocms_page_sitemap/migrations/0001_initial.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import unicode_literals - - import django.core.validators -diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -index b0ff842..4f12d95 100644 ---- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -+++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import unicode_literals - - from django.db import migrations, models -diff --git a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py -index 564f1f2..2228cd8 100644 ---- a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py -+++ b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import unicode_literals - - import django.core.validators -diff --git a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py -index 762a83e..7f1ed4b 100644 ---- a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py -+++ b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - # Generated by Django 1.10.8 on 2018-02-02 09:44 - from __future__ import unicode_literals - -diff --git a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py -index fda955a..1d70bc7 100644 ---- a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py -+++ b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - # Generated by Django 1.11.10 on 2018-03-24 09:50 - from __future__ import unicode_literals - -diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py -index f2597fc..0fc648b 100644 ---- a/djangocms_page_sitemap/models.py -+++ b/djangocms_page_sitemap/models.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from cms.extensions import PageExtension, extension_pool -diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py -index 406886f..41b6cfc 100644 ---- a/djangocms_page_sitemap/settings.py -+++ b/djangocms_page_sitemap/settings.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from cms.sitemaps import CMSSitemap -diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py -index b21c37d..b10704f 100644 ---- a/djangocms_page_sitemap/sitemap.py -+++ b/djangocms_page_sitemap/sitemap.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from collections import defaultdict -diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py -index cf65490..528ef50 100644 ---- a/djangocms_page_sitemap/sitemap_urls.py -+++ b/djangocms_page_sitemap/sitemap_urls.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from django.conf.urls import url -diff --git a/djangocms_page_sitemap/templatetags/__init__.py b/djangocms_page_sitemap/templatetags/__init__.py -index 40a96af..8b13789 100644 ---- a/djangocms_page_sitemap/templatetags/__init__.py -+++ b/djangocms_page_sitemap/templatetags/__init__.py -@@ -1 +1 @@ --# -*- coding: utf-8 -*- -+ -diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py -index 8a3c47c..56357f0 100644 ---- a/djangocms_page_sitemap/templatetags/robots_index.py -+++ b/djangocms_page_sitemap/templatetags/robots_index.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from classytags.arguments import Argument -diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py -index 9380a41..68d96a4 100644 ---- a/djangocms_page_sitemap/utils.py -+++ b/djangocms_page_sitemap/utils.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from cms.cache import _get_cache_key -diff --git a/tests/__init__.py b/tests/__init__.py -index 40a96af..8b13789 100644 ---- a/tests/__init__.py -+++ b/tests/__init__.py -@@ -1 +1 @@ --# -*- coding: utf-8 -*- -+ -diff --git a/tests/base.py b/tests/base.py -index 5ec4382..a00b496 100644 ---- a/tests/base.py -+++ b/tests/base.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from cms.utils.i18n import get_language_list -diff --git a/tests/test_models.py b/tests/test_models.py -index b753319..1953aa4 100644 ---- a/tests/test_models.py -+++ b/tests/test_models.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from django import template -diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py -index 1f229ea..bedb11a 100644 ---- a/tests/test_sitemap.py -+++ b/tests/test_sitemap.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from decimal import Decimal -diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py -index 73866e4..c947930 100644 ---- a/tests/test_toolbar.py -+++ b/tests/test_toolbar.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from cms.api import create_page -diff --git a/tests/test_utils/__init__.py b/tests/test_utils/__init__.py -index 40a96af..8b13789 100644 ---- a/tests/test_utils/__init__.py -+++ b/tests/test_utils/__init__.py -@@ -1 +1 @@ --# -*- coding: utf-8 -*- -+ -diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py -index 97cf06a..8b6b6ef 100644 ---- a/tests/test_utils/urls.py -+++ b/tests/test_utils/urls.py -@@ -1,4 +1,4 @@ --# -*- coding: utf-8 -*- -+ - from __future__ import absolute_import, print_function, unicode_literals - - from cms.utils.conf import get_cms_setting - -From 8bdbe1754a9a397ee321ba5739ca4d4e0ce3d24e Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 15:26:52 +0000 -Subject: [PATCH 08/20] Use a dj 3.2 compatible version - ---- - HISTORY.rst | 4 +++- - tox.ini | 3 ++- - 2 files changed, 5 insertions(+), 2 deletions(-) - -diff --git a/HISTORY.rst b/HISTORY.rst -index 77bdfcc..9ff65de 100644 ---- a/HISTORY.rst -+++ b/HISTORY.rst -@@ -9,7 +9,9 @@ History - (unreleased) - ============ - --- Update tooling -+* Update tooling and ci test suite to Github Actions -+* Add compatibility with Django 3.2 -+* Drop compatibility with Django < 2.2 - - 0.9.0.dev8 (2020-11-23) - ======================= -diff --git a/tox.ini b/tox.ini -index 21c93cc..44a23f1 100644 ---- a/tox.ini -+++ b/tox.ini -@@ -15,7 +15,8 @@ commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posar - deps = - django22: Django>=2.2,<3.0 - django32: Django>=3.2,<3.3 -- cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip -+ cms40: https://github.com/Aiky30/django-cms/archive/feature/cms-4-django-32-support.zip -+ #cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip - -r {toxinidir}/requirements-test.txt - passenv = - COMMAND - -From d6254030162e109e57a17751a338a3cb4cd07147 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 15:31:13 +0000 -Subject: [PATCH 09/20] Removed all __future__ imports - ---- - djangocms_page_sitemap/__init__.py | 3 --- - djangocms_page_sitemap/admin.py | 3 --- - djangocms_page_sitemap/cms_toolbars.py | 3 --- - djangocms_page_sitemap/migrations/0001_initial.py | 3 --- - djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 3 --- - djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py | 3 --- - djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py | 3 --- - djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py | 3 --- - djangocms_page_sitemap/models.py | 3 --- - djangocms_page_sitemap/settings.py | 3 --- - djangocms_page_sitemap/sitemap.py | 5 ----- - djangocms_page_sitemap/sitemap_urls.py | 3 --- - djangocms_page_sitemap/templatetags/robots_index.py | 3 --- - djangocms_page_sitemap/utils.py | 3 --- - tests/base.py | 4 +--- - tests/test_models.py | 3 --- - tests/test_sitemap.py | 3 --- - tests/test_toolbar.py | 3 --- - tests/test_utils/urls.py | 3 --- - 19 files changed, 1 insertion(+), 59 deletions(-) - -diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py -index 59eeade..7aa1eeb 100644 ---- a/djangocms_page_sitemap/__init__.py -+++ b/djangocms_page_sitemap/__init__.py -@@ -1,5 +1,2 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - __version__ = '0.9.0.dev8' # pragma: no cover - __author__ = 'Iacopo Spalletti ' # pragma: no cover -diff --git a/djangocms_page_sitemap/admin.py b/djangocms_page_sitemap/admin.py -index 3ecd26c..3f468f3 100644 ---- a/djangocms_page_sitemap/admin.py -+++ b/djangocms_page_sitemap/admin.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from cms.extensions import PageExtensionAdmin - from django.contrib import admin - -diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py -index 50afdfd..9705eb4 100644 ---- a/djangocms_page_sitemap/cms_toolbars.py -+++ b/djangocms_page_sitemap/cms_toolbars.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from cms.toolbar_pool import toolbar_pool - from cms.utils.conf import get_cms_setting - from cms.utils.permissions import has_page_permission -diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py -index bf8ee0b..29ad25a 100644 ---- a/djangocms_page_sitemap/migrations/0001_initial.py -+++ b/djangocms_page_sitemap/migrations/0001_initial.py -@@ -1,6 +1,3 @@ -- --from __future__ import unicode_literals -- - import django.core.validators - from django.db import models, migrations - -diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -index 4f12d95..0e2e8a7 100644 ---- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -+++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -@@ -1,6 +1,3 @@ -- --from __future__ import unicode_literals -- - from django.db import migrations, models - from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST - -diff --git a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py -index 2228cd8..f463f2f 100644 ---- a/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py -+++ b/djangocms_page_sitemap/migrations/0003_auto_20151018_1612.py -@@ -1,6 +1,3 @@ -- --from __future__ import unicode_literals -- - import django.core.validators - from django.db import migrations, models - -diff --git a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py -index 7f1ed4b..af89883 100644 ---- a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py -+++ b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py -@@ -1,7 +1,4 @@ -- - # Generated by Django 1.10.8 on 2018-02-02 09:44 --from __future__ import unicode_literals -- - from django.db import migrations, models - - -diff --git a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py -index 1d70bc7..2e0d79f 100644 ---- a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py -+++ b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py -@@ -1,7 +1,4 @@ -- - # Generated by Django 1.11.10 on 2018-03-24 09:50 --from __future__ import unicode_literals -- - from django.db import migrations, models - - -diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py -index 0fc648b..8882288 100644 ---- a/djangocms_page_sitemap/models.py -+++ b/djangocms_page_sitemap/models.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from cms.extensions import PageExtension, extension_pool - from cms.models import Page - from cms.utils.compat.dj import python_2_unicode_compatible -diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py -index 41b6cfc..ca95dbd 100644 ---- a/djangocms_page_sitemap/settings.py -+++ b/djangocms_page_sitemap/settings.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from cms.sitemaps import CMSSitemap - from cms.utils.conf import get_cms_setting - from django.conf import settings -diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py -index b10704f..8fd33ef 100644 ---- a/djangocms_page_sitemap/sitemap.py -+++ b/djangocms_page_sitemap/sitemap.py -@@ -1,8 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- --from collections import defaultdict -- - from cms.models import PageContent, PageUrl - from cms.sitemaps import CMSSitemap - from cms.utils import get_current_site -diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py -index 528ef50..b591de1 100644 ---- a/djangocms_page_sitemap/sitemap_urls.py -+++ b/djangocms_page_sitemap/sitemap_urls.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from django.conf.urls import url - from django.contrib.sitemaps.views import sitemap - -diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py -index 56357f0..8aa03a9 100644 ---- a/djangocms_page_sitemap/templatetags/robots_index.py -+++ b/djangocms_page_sitemap/templatetags/robots_index.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from classytags.arguments import Argument - from classytags.core import Options, Tag - from cms.templatetags.cms_tags import _get_page_by_untyped_arg -diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py -index 68d96a4..539253d 100644 ---- a/djangocms_page_sitemap/utils.py -+++ b/djangocms_page_sitemap/utils.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from cms.cache import _get_cache_key - from django.apps import apps - -diff --git a/tests/base.py b/tests/base.py -index a00b496..2213f9c 100644 ---- a/tests/base.py -+++ b/tests/base.py -@@ -1,11 +1,9 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -+from io import StringIO - - from cms.utils.i18n import get_language_list - from django.contrib.auth.models import User - from django.http import SimpleCookie - from django.test import RequestFactory, TestCase --from django.utils.six import StringIO - - from djangocms_page_sitemap.utils import is_versioning_enabled - -diff --git a/tests/test_models.py b/tests/test_models.py -index 1953aa4..3f6f7bb 100644 ---- a/tests/test_models.py -+++ b/tests/test_models.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from django import template - from django.contrib.auth.models import AnonymousUser - from django.contrib.sites.models import Site -diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py -index bedb11a..b32512d 100644 ---- a/tests/test_sitemap.py -+++ b/tests/test_sitemap.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from decimal import Decimal - from unittest import skipIf - -diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py -index c947930..f0e5c9b 100644 ---- a/tests/test_toolbar.py -+++ b/tests/test_toolbar.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from cms.api import create_page - from cms.test_utils.testcases import CMSTestCase - from cms.toolbar.items import Menu, ModalItem -diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py -index 8b6b6ef..a9c2894 100644 ---- a/tests/test_utils/urls.py -+++ b/tests/test_utils/urls.py -@@ -1,6 +1,3 @@ -- --from __future__ import absolute_import, print_function, unicode_literals -- - from cms.utils.conf import get_cms_setting - from django.conf import settings - from django.conf.urls import include, url - -From 9b1cd1adf1fbd2dc22f9b39faaa5d75c8708c446 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Tue, 21 Dec 2021 15:40:58 +0000 -Subject: [PATCH 10/20] Removed @python_2_unicode_compatible - ---- - djangocms_page_sitemap/models.py | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py -index 8882288..50611dc 100644 ---- a/djangocms_page_sitemap/models.py -+++ b/djangocms_page_sitemap/models.py -@@ -1,6 +1,5 @@ - from cms.extensions import PageExtension, extension_pool - from cms.models import Page --from cms.utils.compat.dj import python_2_unicode_compatible - from django.core.cache import cache - from django.core.validators import MaxValueValidator, MinValueValidator - from django.db import models -@@ -13,7 +12,6 @@ - - - @extension_pool.register --@python_2_unicode_compatible - class PageSitemapProperties(PageExtension): - changefreq = models.CharField( - _('Change frequency'), max_length=20, default='monthly', - -From 4ce98ca34b0dc914b81654116371a63c3739ee7a Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 09:18:42 +0000 -Subject: [PATCH 11/20] Update django limitation from 3.3 to 4.0 - ---- - setup.cfg | 2 +- - tox.ini | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/setup.cfg b/setup.cfg -index d01f83f..0a5b76e 100644 ---- a/setup.cfg -+++ b/setup.cfg -@@ -65,7 +65,7 @@ djangcms_page_sitemap = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po - - [options.extras_require] - docs = -- django<3.1 -+ django<4.0 - - [upload] - repository = https://upload.pypi.org/legacy/ -diff --git a/tox.ini b/tox.ini -index 44a23f1..87b31bf 100644 ---- a/tox.ini -+++ b/tox.ini -@@ -14,7 +14,7 @@ envlist = - commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} - deps = - django22: Django>=2.2,<3.0 -- django32: Django>=3.2,<3.3 -+ django32: Django>=3.2,<4.0 - cms40: https://github.com/Aiky30/django-cms/archive/feature/cms-4-django-32-support.zip - #cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip - -r {toxinidir}/requirements-test.txt - -From dd1bb823839bfc46d357d617c2d650ddd4140f6a Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 09:35:02 +0000 -Subject: [PATCH 12/20] Fix isort failures - ---- - djangocms_page_sitemap/migrations/0001_initial.py | 2 +- - djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py | 1 + - tests/test_toolbar.py | 1 - - 3 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py -index 29ad25a..6d9f90a 100644 ---- a/djangocms_page_sitemap/migrations/0001_initial.py -+++ b/djangocms_page_sitemap/migrations/0001_initial.py -@@ -1,5 +1,5 @@ - import django.core.validators --from django.db import models, migrations -+from django.db import migrations, models - - from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST - -diff --git a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -index 0e2e8a7..dd47306 100644 ---- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -+++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py -@@ -1,4 +1,5 @@ - from django.db import migrations, models -+ - from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST - - -diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py -index f0e5c9b..ee9f953 100644 ---- a/tests/test_toolbar.py -+++ b/tests/test_toolbar.py -@@ -12,7 +12,6 @@ - from djangocms_page_sitemap.models import PageSitemapProperties - from djangocms_page_sitemap.utils import is_versioning_enabled - -- - from .base import BaseTest - - - -From 812a0f0a61ab2bc29ab3f8208a14335834360889 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 09:36:44 +0000 -Subject: [PATCH 13/20] Fix installation dependancies - ---- - tox.ini | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tox.ini b/tox.ini -index 87b31bf..b58f0d7 100644 ---- a/tox.ini -+++ b/tox.ini -@@ -74,7 +74,7 @@ deps = - sphinx-rtd-theme - sphinx-autobuild - livereload~=2.6 -- -requirements-test.txt -+ -r requirements-test.txt - skip_install = true - - [testenv:towncrier] - -From 591df6231d76a11629bca4b6c4a6a2336b3d2d9c Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 09:58:14 +0000 -Subject: [PATCH 14/20] fixed lint failures - ---- - aldryn_config.py | 24 +++---- - cms_helper.py | 71 ++++++++++--------- - djangocms_page_sitemap/__init__.py | 4 +- - djangocms_page_sitemap/cms_toolbars.py | 12 ++-- - djangocms_page_sitemap/models.py | 20 +++--- - djangocms_page_sitemap/settings.py | 20 +++--- - djangocms_page_sitemap/sitemap.py | 4 +- - djangocms_page_sitemap/sitemap_urls.py | 4 +- - .../templatetags/robots_index.py | 18 ++--- - djangocms_page_sitemap/utils.py | 4 +- - 10 files changed, 91 insertions(+), 90 deletions(-) - -diff --git a/aldryn_config.py b/aldryn_config.py -index 66499b1..e8d0bb0 100644 ---- a/aldryn_config.py -+++ b/aldryn_config.py -@@ -5,28 +5,28 @@ - from aldryn_client import forms - - PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST = { -- 'always': 'always', -- 'hourly': 'hourly', -- 'daily': 'daily', -- 'weekly': 'weekly', -- 'monthly': 'monthly', -- 'yearly': 'yearly', -- 'never': 'never', -+ "always": "always", -+ "hourly": "hourly", -+ "daily": "daily", -+ "weekly": "weekly", -+ "monthly": "monthly", -+ "yearly": "yearly", -+ "never": "never", - } - - - class Form(forms.BaseForm): - PAGE_SITEMAP_DEFAULT_CHANGEFREQ = forms.SelectField( -- 'Default changefrequency (default: django CMS value -monthly-)', -+ "Default changefrequency (default: django CMS value -monthly-)", - choices=PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST.items(), - ) - PAGE_SITEMAP_CACHE_DURATION = forms.CharField( -- 'Cache duration (default: same as django CMS menu cache)', -+ "Cache duration (default: same as django CMS menu cache)", - required=False - ) - - def to_settings(self, data, settings): -- settings['PAGE_SITEMAP_DEFAULT_CHANGEFREQ'] = data['PAGE_SITEMAP_DEFAULT_CHANGEFREQ'] -- settings['PAGE_SITEMAP_CACHE_DURATION'] = data['PAGE_SITEMAP_CACHE_DURATION'] -- settings['ADDON_URLS'].insert(0, 'djangocms_page_sitemap.sitemap_urls') -+ settings["PAGE_SITEMAP_DEFAULT_CHANGEFREQ"] = data["PAGE_SITEMAP_DEFAULT_CHANGEFREQ"] -+ settings["PAGE_SITEMAP_CACHE_DURATION"] = data["PAGE_SITEMAP_CACHE_DURATION"] -+ settings["ADDON_URLS"].insert(0, "djangocms_page_sitemap.sitemap_urls") - return settings -diff --git a/cms_helper.py b/cms_helper.py -index 35d4008..0d61a7f 100755 ---- a/cms_helper.py -+++ b/cms_helper.py -@@ -16,54 +16,55 @@ def __getitem__(self, item): - def gettext(s): - return s - -+ - HELPER_SETTINGS = { -- 'NOSE_ARGS': [ -- '-s', -+ "NOSE_ARGS": [ -+ "-s", - ], -- 'CACHES': { -- 'default': { -- 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', -+ "CACHES": { -+ "default": { -+ "BACKEND": "django.core.cache.backends.locmem.LocMemCache", - } - }, -- 'CMS_CACHE_DURATIONS': { -- 'menus': 10, -- 'content': 10, -- 'permissions': 10, -+ "CMS_CACHE_DURATIONS": { -+ "menus": 10, -+ "content": 10, -+ "permissions": 10, - }, -- 'ROOT_URLCONF': 'tests.test_utils.urls', -+ "ROOT_URLCONF": "tests.test_utils.urls", - # FIXME: Django CMS migrtions with Django 2.2 produce an error when - # running tests, temporarily disabling migrations -- 'MIGRATION_MODULES': DisableMigrations(), -- 'INSTALLED_APPS': [ -- 'django.contrib.sitemaps', -+ "MIGRATION_MODULES": DisableMigrations(), -+ "INSTALLED_APPS": [ -+ "django.contrib.sitemaps", - ], -- 'LANGUAGE_CODE': 'en', -- 'TIME_ZONE': 'UTC', -- 'LANGUAGES': ( -- ('en', gettext('English')), -- ('fr', gettext('French')), -- ('it', gettext('Italiano')), -+ "LANGUAGE_CODE": "en", -+ "TIME_ZONE": "UTC", -+ "LANGUAGES": ( -+ ("en", gettext("English")), -+ ("fr", gettext("French")), -+ ("it", gettext("Italiano")), - ), -- 'CMS_LANGUAGES': { -+ "CMS_LANGUAGES": { - 1: [ - { -- 'code': 'en', -- 'name': gettext('English'), -- 'public': True, -+ "code": "en", -+ "name": gettext("English"), -+ "public": True, - }, - { -- 'code': 'it', -- 'name': gettext('Italiano'), -- 'public': True, -+ "code": "it", -+ "name": gettext("Italiano"), -+ "public": True, - }, - { -- 'code': 'fr', -- 'name': gettext('French'), -- 'public': True, -+ "code": "fr", -+ "name": gettext("French"), -+ "public": True, - }, - ], -- 'default': { -- 'hide_untranslated': False, -+ "default": { -+ "hide_untranslated": False, - }, - }, - -@@ -72,17 +73,17 @@ def gettext(s): - - def run(): - from app_helper import runner -- runner.cms('djangocms_page_sitemap') -+ runner.cms("djangocms_page_sitemap") - - - def setup(): - from app_helper import runner -- runner.setup('djangocms_page_sitemap', sys.modules[__name__], use_cms=True) -+ runner.setup("djangocms_page_sitemap", sys.modules[__name__], use_cms=True) - - --if __name__ == '__main__': -+if __name__ == "__main__": - run() - --if __name__ == 'cms_helper': -+if __name__ == "cms_helper": - # this is needed to run cms_helper in pycharm - setup() -diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py -index 7aa1eeb..466ef04 100644 ---- a/djangocms_page_sitemap/__init__.py -+++ b/djangocms_page_sitemap/__init__.py -@@ -1,2 +1,2 @@ --__version__ = '0.9.0.dev8' # pragma: no cover --__author__ = 'Iacopo Spalletti ' # pragma: no cover -+__version__ = "0.9.0.dev8" # pragma: no cover -+__author__ = "Iacopo Spalletti " # pragma: no cover -diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py -index 9705eb4..498e745 100644 ---- a/djangocms_page_sitemap/cms_toolbars.py -+++ b/djangocms_page_sitemap/cms_toolbars.py -@@ -13,7 +13,7 @@ - from cms.cms_toolbars import PageToolbar - - --PAGE_SITEMAP_MENU_TITLE = _('Sitemap properties') -+PAGE_SITEMAP_MENU_TITLE = _("Sitemap properties") - - - @toolbar_pool.register -@@ -25,9 +25,9 @@ def populate(self): - return - - # check global permissions if CMS_PERMISSIONS is active -- if get_cms_setting('PERMISSION'): -+ if get_cms_setting("PERMISSION"): - has_global_current_page_change_permission = has_page_permission( -- self.request.user, self.request.current_page, 'change' -+ self.request.user, self.request.current_page, "change" - ) - else: - has_global_current_page_change_permission = False -@@ -38,7 +38,7 @@ def populate(self): - ) - if has_global_current_page_change_permission or can_change: - not_edit_mode = not self.toolbar.edit_mode_active -- current_page_menu = self.toolbar.get_or_create_menu('page') -+ current_page_menu = self.toolbar.get_or_create_menu("page") - # Page tags - try: - page_extension = PageSitemapProperties.objects.get(extended_object_id=self.page.pk) -@@ -46,11 +46,11 @@ def populate(self): - page_extension = None - try: - if page_extension: -- url = reverse('admin:djangocms_page_sitemap_pagesitemapproperties_change', -+ url = reverse("admin:djangocms_page_sitemap_pagesitemapproperties_change", - args=(page_extension.pk,)) - else: - url = "%s?extended_object=%s" % ( -- reverse('admin:djangocms_page_sitemap_pagesitemapproperties_add'), -+ reverse("admin:djangocms_page_sitemap_pagesitemapproperties_add"), - self.page.pk) - except NoReverseMatch: # pragma: no cover - # not in urls -diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py -index 50611dc..83bc1e0 100644 ---- a/djangocms_page_sitemap/models.py -+++ b/djangocms_page_sitemap/models.py -@@ -14,29 +14,29 @@ - @extension_pool.register - class PageSitemapProperties(PageExtension): - changefreq = models.CharField( -- _('Change frequency'), max_length=20, default='monthly', -+ _("Change frequency"), max_length=20, default="monthly", - choices=PAGE_SITEMAP_CHANGEFREQ_LIST.items() - ) - priority = models.DecimalField( -- _('Priority'), decimal_places=1, max_digits=2, default=0.5, -+ _("Priority"), decimal_places=1, max_digits=2, default=0.5, - validators=[MinValueValidator(0), MaxValueValidator(1)] - ) -- include_in_sitemap = models.BooleanField(_('Include in sitemap'), default=True) -+ include_in_sitemap = models.BooleanField(_("Include in sitemap"), default=True) - noindex = models.BooleanField( -- _('Mark as no index'), default=False, -- help_text=_('Add meta tag robots with value noindex') -+ _("Mark as no index"), default=False, -+ help_text=_("Add meta tag robots with value noindex") - ) - noarchive = models.BooleanField( -- _('Mark as no archive'), default=False, -- help_text=_('Add meta tag robots with value noarchive') -+ _("Mark as no archive"), default=False, -+ help_text=_("Add meta tag robots with value noarchive") - ) - robots_extra = models.CharField( -- _('Extra robots value'), default='', max_length=200, blank=True, -- help_text=_('Extra values for robots meta tag') -+ _("Extra robots value"), default='', max_length=200, blank=True, -+ help_text=_("Extra values for robots meta tag") - ) - - def __str__(self): -- return _('Sitemap values for Page %s') % self.extended_object.pk -+ return _("Sitemap values for Page %s") % self.extended_object.pk - - - # Cache cleanup when deleting pages / editing page extensions -diff --git a/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py -index ca95dbd..5d3dca0 100644 ---- a/djangocms_page_sitemap/settings.py -+++ b/djangocms_page_sitemap/settings.py -@@ -4,18 +4,18 @@ - from django.utils.translation import ugettext_lazy as _ - - PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST = { -- 'always': _('always'), -- 'hourly': _('hourly'), -- 'daily': _('daily'), -- 'weekly': _('weekly'), -- 'monthly': _('monthly'), -- 'yearly': _('yearly'), -- 'never': _('never'), -+ "always": _("always"), -+ "hourly": _("hourly"), -+ "daily": _("daily"), -+ "weekly": _("weekly"), -+ "monthly": _("monthly"), -+ "yearly": _("yearly"), -+ "never": _("never"), - } - PAGE_SITEMAP_CHANGEFREQ_LIST = getattr( -- settings, 'PAGE_SITEMAP_CHANGEFREQ_LIST', PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST -+ settings, "PAGE_SITEMAP_CHANGEFREQ_LIST", PAGE_SITEMAP_CHANGEFREQ_DEFAULT_LIST - ) - PAGE_SITEMAP_DEFAULT_CHANGEFREQ = getattr( -- settings, 'PAGE_SITEMAP_DEFAULT_CHANGEFREQ', CMSSitemap.changefreq -+ settings, "PAGE_SITEMAP_DEFAULT_CHANGEFREQ", CMSSitemap.changefreq - ) --PAGE_SITEMAP_CACHE_DURATION = get_cms_setting('CACHE_DURATIONS')['menus'] -+PAGE_SITEMAP_CACHE_DURATION = get_cms_setting("CACHE_DURATIONS")["menus"] -diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py -index 8fd33ef..796a217 100644 ---- a/djangocms_page_sitemap/sitemap.py -+++ b/djangocms_page_sitemap/sitemap.py -@@ -20,7 +20,7 @@ def items(self): - site = get_current_site() - languages = get_public_languages(site_id=site.pk) - page_content_prefetch = Prefetch( -- 'page__pagecontent_set', -+ "page__pagecontent_set", - queryset=PageContent.objects.filter( - language__in=languages, - ) -@@ -37,7 +37,7 @@ def items(self): - page__node__site=site, - ) - .exclude(page__pagesitemapproperties__include_in_sitemap=False) -- .order_by('page__node__path') -+ .order_by("page__node__path") - ) - valid_urls = [] - for page_url in all_urls: -diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py -index b591de1..0225a6f 100644 ---- a/djangocms_page_sitemap/sitemap_urls.py -+++ b/djangocms_page_sitemap/sitemap_urls.py -@@ -1,8 +1,8 @@ --from django.conf.urls import url - from django.contrib.sitemaps.views import sitemap -+from django.urls import re_path - - from .sitemap import ExtendedSitemap - - urlpatterns = [ -- url(r'^sitemap\.xml$', sitemap, {'sitemaps': {'cmspages': ExtendedSitemap}}), -+ re_path(r"^sitemap\.xml$", sitemap, {"sitemaps": {"cmspages": ExtendedSitemap}}), - ] -diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py -index 8aa03a9..8115534 100644 ---- a/djangocms_page_sitemap/templatetags/robots_index.py -+++ b/djangocms_page_sitemap/templatetags/robots_index.py -@@ -8,19 +8,19 @@ - register = template.Library() - - --@register.tag(name='page_robots') -+@register.tag(name="page_robots") - class PageRobots(Tag): - """ - Generates the robots meta tag according to the extension attributes - """ -- name = 'page_robots' -+ name = "page_robots" - options = Options( -- Argument('page', required=False), -- Argument('site_id', required=False), -+ Argument("page", required=False), -+ Argument("site_id", required=False), - ) - - def render_tag(self, context, page, site_id): -- request = context.get('request') -+ request = context.get("request") - if not request: - return '' - if not site_id: -@@ -37,11 +37,11 @@ def render_tag(self, context, page, site_id): - return '' - try: - if page.pagesitemapproperties.noindex: -- content.append('noindex') -+ content.append("noindex") - if page.pagesitemapproperties.noarchive: -- content.append('noarchive') -+ content.append("noarchive") - if page.pagesitemapproperties.robots_extra: - content.append(page.pagesitemapproperties.robots_extra) -- return '' % ','.join(content) -+ return "" % ','.join(content) - except ObjectDoesNotExist: -- return '' -+ return "" -diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py -index 539253d..ecbc700 100644 ---- a/djangocms_page_sitemap/utils.py -+++ b/djangocms_page_sitemap/utils.py -@@ -10,13 +10,13 @@ def get_cache_key(page): - site_id = page.node.site_id - except AttributeError: - site_id = page.site_id -- return _get_cache_key('page_sitemap', page, 'default', site_id) -+ return _get_cache_key("page_sitemap", page, "default", site_id) - - - def is_versioning_enabled(): - from cms.models import PageContent - try: -- app_config = apps.get_app_config('djangocms_versioning') -+ app_config = apps.get_app_config("djangocms_versioning") - return app_config.cms_extension.is_content_model_versioned(PageContent) - except LookupError: - return False - -From a54ae9a06731938c88ea4f9d5b8fba7eca234431 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 10:00:27 +0000 -Subject: [PATCH 15/20] Fix missing secret key for the test suite - ---- - cms_helper.py | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/cms_helper.py b/cms_helper.py -index 0d61a7f..7fbacd6 100755 ---- a/cms_helper.py -+++ b/cms_helper.py -@@ -18,6 +18,7 @@ def gettext(s): - - - HELPER_SETTINGS = { -+ "SECRET_KEY": "djangocms-page-sitemap-test-suite-key", - "NOSE_ARGS": [ - "-s", - ], - -From f0a17c52a60b03fd234626b7b207d16764625cc4 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 10:16:54 +0000 -Subject: [PATCH 16/20] Fixed failing tests - ---- - tests/base.py | 21 +++------------------ - tests/test_toolbar.py | 6 +++--- - tests/test_utils/urls.py | 13 +++++++------ - 3 files changed, 13 insertions(+), 27 deletions(-) - -diff --git a/tests/base.py b/tests/base.py -index 2213f9c..aaaf6f1 100644 ---- a/tests/base.py -+++ b/tests/base.py -@@ -35,24 +35,9 @@ def get_pages(self): - create_title(language='fr', title='page un', page=page_1, created_by=self.user) - create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) - create_title(language='fr', title='page trois', page=page_3, created_by=self.user) -- page_content1 = create_title( -- title='pagecontent1_en', -- language='en', -- page=page_1, -- created_by=self.user -- ) -- page_content2 = create_title( -- title='pagecontent2_en', -- language='en', -- page=page_2, -- created_by=self.user -- ) -- page_content3 = create_title( -- title='pagecontent3_en', -- language='en', -- page=page_3, -- created_by=self.user -- ) -+ page_content1 = page_1.get_title_obj("en") -+ page_content2 = page_2.get_title_obj("en") -+ page_content3 = page_3.get_title_obj("en") - if is_versioning_enabled(): - page_content1.versions.first().publish(self.user) - page_content2.versions.first().publish(self.user) -diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py -index ee9f953..d1cd7eb 100644 ---- a/tests/test_toolbar.py -+++ b/tests/test_toolbar.py -@@ -6,7 +6,7 @@ - from django.test.utils import override_settings - from django.urls import reverse - from django.utils.encoding import force_text --from django.utils.translation import ugettext_lazy as _ -+from django.utils.translation import gettext_lazy as _ - - from djangocms_page_sitemap.cms_toolbars import PAGE_SITEMAP_MENU_TITLE - from djangocms_page_sitemap.models import PageSitemapProperties -@@ -147,8 +147,8 @@ def test_toolbar_buttons_are_not_duplicated(self): - - user = self.get_superuser() - page_1 = create_page('page-one', 'page.html', language='en', created_by=user) -- page_content = create_title(title='pagecontent1', language='en', page=page_1, -- created_by=user) -+ page_content = page_1.get_title_obj("en") -+ - if is_versioning_enabled(): - page_content.versions.first().publish(user) - preview_endpoint = get_object_preview_url(page_content, language='en') -diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py -index a9c2894..2f4a837 100644 ---- a/tests/test_utils/urls.py -+++ b/tests/test_utils/urls.py -@@ -1,26 +1,27 @@ - from cms.utils.conf import get_cms_setting - from django.conf import settings --from django.conf.urls import include, url - from django.conf.urls.i18n import i18n_patterns - from django.contrib import admin - from django.contrib.staticfiles.urls import staticfiles_urlpatterns - from django.views.static import serve -+from django.urls import include, re_path - - from djangocms_page_sitemap import sitemap_urls - -+ - admin.autodiscover() - - urlpatterns = [ -- url(r'^media/(?P.*)$', serve, -+ re_path(r'^media/(?P.*)$', serve, - {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), -- url(r'^media/cms/(?P.*)$', serve, -+ re_path(r'^media/cms/(?P.*)$', serve, - {'document_root': get_cms_setting('MEDIA_ROOT'), 'show_indexes': True}), -- url(r'^', include(sitemap_urls)), -+ re_path(r'^', include(sitemap_urls)), - ] - - urlpatterns += staticfiles_urlpatterns() - - urlpatterns += i18n_patterns( -- url(r'^admin/', admin.site.urls), -- url(r'^', include('cms.urls')), -+ re_path(r'^admin/', admin.site.urls), -+ re_path(r'^', include('cms.urls')), - ) - -From 2d4c09e44b70ce875a091620c398d5c2c77838bb Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 10:18:26 +0000 -Subject: [PATCH 17/20] Fix deprecation notices - ---- - djangocms_page_sitemap/models.py | 2 +- - tests/base.py | 2 +- - tests/test_toolbar.py | 16 ++++++++-------- - 3 files changed, 10 insertions(+), 10 deletions(-) - -diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py -index 83bc1e0..ee15911 100644 ---- a/djangocms_page_sitemap/models.py -+++ b/djangocms_page_sitemap/models.py -@@ -5,7 +5,7 @@ - from django.db import models - from django.db.models.signals import post_save, pre_delete - from django.dispatch import receiver --from django.utils.translation import ugettext_lazy as _ -+from django.utils.translation import gettext_lazy as _ - - from .settings import PAGE_SITEMAP_CHANGEFREQ_LIST - from .utils import get_cache_key -diff --git a/tests/base.py b/tests/base.py -index aaaf6f1..abf4c2e 100644 ---- a/tests/base.py -+++ b/tests/base.py -@@ -71,7 +71,7 @@ def get_page_request(self, page, user, path=None, edit=False, lang_code='en'): - else: - request.GET = {'edit_off': None} - request.current_page = page -- mid = ToolbarMiddleware() -+ mid = ToolbarMiddleware(request) - mid.process_request(request) - return request - -diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py -index d1cd7eb..764b9dd 100644 ---- a/tests/test_toolbar.py -+++ b/tests/test_toolbar.py -@@ -5,7 +5,7 @@ - from django.contrib.auth.models import Permission, User - from django.test.utils import override_settings - from django.urls import reverse --from django.utils.encoding import force_text -+from django.utils.encoding import force_str - from django.utils.translation import gettext_lazy as _ - - from djangocms_page_sitemap.cms_toolbars import PAGE_SITEMAP_MENU_TITLE -@@ -70,11 +70,11 @@ def test_perm(self): - page_menu = toolbar.menus['page'] - try: - self.assertEqual( -- len(page_menu.find_items(ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 -+ len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 - ) - except AssertionError: - self.assertEqual( -- len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 -+ len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 - ) - - @override_settings(CMS_PERMISSION=True) -@@ -104,11 +104,11 @@ def test_toolbar(self): - page_menu = toolbar.menus['page'] - try: - self.assertEqual( -- len(page_menu.find_items(ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 -+ len(page_menu.find_items(ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 - ) - except AssertionError: - self.assertEqual( -- len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1 -+ len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 1 - ) - - def test_toolbar_with_items(self): -@@ -125,14 +125,14 @@ def test_toolbar_with_items(self): - page_menu = toolbar.menus['page'] - try: - meta_menu = page_menu.find_items( -- ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE) -+ ModalItem, name="%s..." % force_str(PAGE_SITEMAP_MENU_TITLE) - )[0].item - except IndexError: - meta_menu = page_menu.find_items( -- ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE) -+ ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE) - )[0].item - self.assertTrue(meta_menu.url.startswith(reverse('admin:djangocms_page_sitemap_pagesitemapproperties_change', args=(page_ext.pk,)))) -- self.assertEqual(force_text(page_ext), force_text(_('Sitemap values for Page %s') % page1.pk)) -+ self.assertEqual(force_str(page_ext), force_str(_('Sitemap values for Page %s') % page1.pk)) - - - class VersioningToolbarTest(CMSTestCase): - -From 774ff10c7d0d20cdecc37b247e307c65ae375bcd Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 10:33:48 +0000 -Subject: [PATCH 18/20] Replace changelog entry with towncrier configuraton - ---- - HISTORY.rst | 7 ------- - tasks.py | 2 +- - 2 files changed, 1 insertion(+), 8 deletions(-) - -diff --git a/HISTORY.rst b/HISTORY.rst -index 9ff65de..61e02c1 100644 ---- a/HISTORY.rst -+++ b/HISTORY.rst -@@ -6,13 +6,6 @@ History - - .. towncrier release notes start - --(unreleased) --============ -- --* Update tooling and ci test suite to Github Actions --* Add compatibility with Django 3.2 --* Drop compatibility with Django < 2.2 -- - 0.9.0.dev8 (2020-11-23) - ======================= - -diff --git a/tasks.py b/tasks.py -index 82261dd..02be157 100644 ---- a/tasks.py -+++ b/tasks.py -@@ -8,7 +8,7 @@ - - DOCS_PORT = os.environ.get("DOCS_PORT", 8000) - #: branch prefixes for which some checks are skipped --SPECIAL_BRANCHES = ("master", "develop", "release") -+SPECIAL_BRANCHES = ("master", "develop", "release", "support/4.0.x") - - - @task - -From 2dfb2fc223200062d2c8fcd8808b315dcf390a75 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 11:35:45 +0000 -Subject: [PATCH 19/20] Fixed versioning tests - ---- - changes/910.feature | 3 +++ - cms_helper.py | 1 + - tests/base.py | 16 ++++++++++------ - tests/test_toolbar.py | 5 ++--- - 4 files changed, 16 insertions(+), 9 deletions(-) - create mode 100644 changes/910.feature - -diff --git a/changes/910.feature b/changes/910.feature -new file mode 100644 -index 0000000..9d140fd ---- /dev/null -+++ b/changes/910.feature -@@ -0,0 +1,3 @@ -+* Update tooling and ci test suite to Github Actions -+* Add compatibility with Django 3.2 -+* Drop compatibility with Django < 2.2 -diff --git a/cms_helper.py b/cms_helper.py -index 7fbacd6..9a78054 100755 ---- a/cms_helper.py -+++ b/cms_helper.py -@@ -38,6 +38,7 @@ def gettext(s): - "MIGRATION_MODULES": DisableMigrations(), - "INSTALLED_APPS": [ - "django.contrib.sitemaps", -+ 'djangocms_versioning', - ], - "LANGUAGE_CODE": "en", - "TIME_ZONE": "UTC", -diff --git a/tests/base.py b/tests/base.py -index abf4c2e..4f92837 100644 ---- a/tests/base.py -+++ b/tests/base.py -@@ -1,5 +1,6 @@ - from io import StringIO - -+from cms.models import PageContent - from cms.utils.i18n import get_language_list - from django.contrib.auth.models import User - from django.http import SimpleCookie -@@ -32,16 +33,19 @@ def get_pages(self): - page_1 = create_page('page one', 'page.html', language='en', created_by=self.user) - page_2 = create_page('page two', 'page.html', language='en', created_by=self.user) - page_3 = create_page('page three', 'page.html', language='en', created_by=self.user) -- create_title(language='fr', title='page un', page=page_1, created_by=self.user) -- create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) -- create_title(language='fr', title='page trois', page=page_3, created_by=self.user) -- page_content1 = page_1.get_title_obj("en") -- page_content2 = page_2.get_title_obj("en") -- page_content3 = page_3.get_title_obj("en") -+ page_1_content_fr = create_title(language='fr', title='page un', page=page_1, created_by=self.user) -+ page_1_content_it = create_title(language='it', title='pagina uno', page=page_1, created_by=self.user) -+ page_3_content_fr = create_title(language='fr', title='page trois', page=page_3, created_by=self.user) -+ page_content1 = PageContent._original_manager.get(page=page_1, language="en") -+ page_content2 = PageContent._original_manager.get(page=page_2, language="en") -+ page_content3 = PageContent._original_manager.get(page=page_3, language="en") - if is_versioning_enabled(): - page_content1.versions.first().publish(self.user) - page_content2.versions.first().publish(self.user) - page_content3.versions.first().publish(self.user) -+ page_1_content_fr.versions.first().publish(self.user) -+ page_1_content_it.versions.first().publish(self.user) -+ page_3_content_fr.versions.first().publish(self.user) - if hasattr(page_1, 'set_as_homepage'): - page_1.set_as_homepage() - -diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py -index 764b9dd..4a58273 100644 ---- a/tests/test_toolbar.py -+++ b/tests/test_toolbar.py -@@ -1,4 +1,5 @@ - from cms.api import create_page -+from cms.models import PageContent - from cms.test_utils.testcases import CMSTestCase - from cms.toolbar.items import Menu, ModalItem - from cms.toolbar.utils import get_object_preview_url -@@ -143,11 +144,9 @@ def test_toolbar_buttons_are_not_duplicated(self): - - This test Can be ran with or without versioning and should return the same result! - """ -- from cms.api import create_title -- - user = self.get_superuser() - page_1 = create_page('page-one', 'page.html', language='en', created_by=user) -- page_content = page_1.get_title_obj("en") -+ page_content = PageContent._original_manager.get(page=page_1, language="en") - - if is_versioning_enabled(): - page_content.versions.first().publish(user) - -From acc9942b4f9fd11e29164da5bcad2dd3c543ee58 Mon Sep 17 00:00:00 2001 -From: Andrew Aikman -Date: Wed, 22 Dec 2021 12:05:19 +0000 -Subject: [PATCH 20/20] Requirements added - ---- - requirements-test.txt | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/requirements-test.txt b/requirements-test.txt -index 4f6ebe2..51fb298 100644 ---- a/requirements-test.txt -+++ b/requirements-test.txt -@@ -3,3 +3,5 @@ coverage>5 - coveralls>2 - mock>=1.0.1 - django-app-helper>=2.0.0 -+ -+https://github.com/Aiky30/djangocms-versioning/tarball/feature/django-32-compat#egg=djangocms-versioning diff --git a/changes/82.feature b/changes/82.feature new file mode 100644 index 0000000..7ae4c66 --- /dev/null +++ b/changes/82.feature @@ -0,0 +1 @@ +Add support for django CMS 4+ diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index 3c0038a..90f253d 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -51,8 +51,8 @@ def test_sitemap_exclude(self): # unpublished since change, still in the sitemap self.assertEqual(len(sitemap.items()), 4) if hasattr(page1, "publish"): - page3.publish('en') - page3.publish('fr') + page3.publish("en") + page3.publish("fr") sitemap = ExtendedSitemap() # published, then no longer in the sitemap self.assertEqual(len(sitemap.items()), 4) From ad03a0e65aac39ed063dbe932733008cacda4686 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 12 May 2023 23:21:09 +0200 Subject: [PATCH 35/37] Ensure tests runs on django CMS 3 and 4 --- .github/workflows/test.yml | 6 ++- cms_helper.py | 8 +++- djangocms_page_sitemap/sitemap.py | 64 +++++++++++++++++-------------- djangocms_page_sitemap/utils.py | 14 ++++--- tests/base.py | 55 +++++++++++++++++--------- tests/test_sitemap.py | 41 ++++++++++++++------ tests/test_toolbar.py | 11 ++++-- tox.ini | 3 ++ 8 files changed, 132 insertions(+), 70 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8bc4fe0..6193409 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,13 +11,17 @@ jobs: matrix: python-version: ["3.11", "3.10", "3.9"] django: [42, 41, 32] - cms: [311, 39] + cms: [4, 311, 39] continue-on-error: [true] exclude: - django: 41 cms: 39 - django: 42 cms: 39 + - django: 41 + cms: 4 + - django: 42 + cms: 4 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/cms_helper.py b/cms_helper.py index adf8378..a9fabc7 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -16,10 +16,10 @@ def gettext(s): "content": 10, "permissions": 10, }, + "CMS_CONFIRM_VERSION4": True, "ROOT_URLCONF": "tests.test_utils.urls", "INSTALLED_APPS": [ "django.contrib.sitemaps", - "djangocms_versioning", ], "LANGUAGE_CODE": "en", "TIME_ZONE": "UTC", @@ -51,6 +51,12 @@ def gettext(s): }, }, } +try: + import djangocms_versioning # noqa: F401 + + HELPER_SETTINGS["INSTALLED_APPS"].append("djangocms_versioning") +except ImportError: + pass def run(): diff --git a/djangocms_page_sitemap/sitemap.py b/djangocms_page_sitemap/sitemap.py index 6d368cb..676459b 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -1,4 +1,3 @@ -from cms.models import PageContent, PageUrl from cms.sitemaps import CMSSitemap from cms.utils import get_current_site from cms.utils.i18n import get_public_languages @@ -15,36 +14,41 @@ class ExtendedSitemap(CMSSitemap): default_priority = CMSSitemap.priority def items(self): - # FIXME:This method was created from this commit: - # https://github.com/divio/django-cms/blob/2894ae8bcf92092d947a097499c01ab2bbb0e6df/cms/sitemaps/cms_sitemap.py - site = get_current_site() - languages = get_public_languages(site_id=site.pk) - page_content_prefetch = Prefetch( - "page__pagecontent_set", - queryset=PageContent.objects.filter( - language__in=languages, - ), - ) - all_urls = ( - PageUrl.objects.get_for_site(site) - .prefetch_related(page_content_prefetch) - .filter( - language__in=languages, - path__isnull=False, - page__login_required=False, - page__node__site=site, + try: + from cms.models import PageContent, PageUrl + + # FIXME:This method was created from this commit: + # https://github.com/divio/django-cms/blob/2894ae8bcf92092d947a097499c01ab2bbb0e6df/cms/sitemaps/cms_sitemap.py + site = get_current_site() + languages = get_public_languages(site_id=site.pk) + page_content_prefetch = Prefetch( + "page__pagecontent_set", + queryset=PageContent.objects.filter( + language__in=languages, + ), ) - .exclude(page__pagesitemapproperties__include_in_sitemap=False) - .order_by("page__node__path") - ) - valid_urls = [] - for page_url in all_urls: - for page_content in page_url.page.pagecontent_set.all(): - if page_url.language == page_content.language: - valid_urls.append(page_url) - break + all_urls = ( + PageUrl.objects.get_for_site(site) + .prefetch_related(page_content_prefetch) + .filter( + language__in=languages, + path__isnull=False, + page__login_required=False, + page__node__site=site, + ) + .exclude(page__pagesitemapproperties__include_in_sitemap=False) + .order_by("page__node__path") + ) + valid_urls = [] + for page_url in all_urls: + for page_content in page_url.page.pagecontent_set.all(): + if page_url.language == page_content.language: + valid_urls.append(page_url) + break - return valid_urls + return valid_urls + except ImportError: + return super().items().exclude(page__pagesitemapproperties__include_in_sitemap=False) def priority(self, title): ext_key = get_cache_key(title.page) @@ -82,6 +86,8 @@ def lastmod(self, page_url): # if versioning is enabled we return the latest version modified using the versioning # modified date. if versioning is disabled we return the page changed_date if is_versioning_enabled(): + from cms.models import PageContent + site = get_current_site() page_contents = PageContent.objects.filter( page=page_url.page, diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py index 78d61cf..d861a4e 100644 --- a/djangocms_page_sitemap/utils.py +++ b/djangocms_page_sitemap/utils.py @@ -14,10 +14,14 @@ def get_cache_key(page): def is_versioning_enabled(): - from cms.models import PageContent - + """Check if djangocms-versioning plugin is installed.""" try: - app_config = apps.get_app_config("djangocms_versioning") - return app_config.cms_extension.is_content_model_versioned(PageContent) - except LookupError: + from cms.models import PageContent + + try: + app_config = apps.get_app_config("djangocms_versioning") + return app_config.cms_extension.is_content_model_versioned(PageContent) + except LookupError: + return False + except ImportError: return False diff --git a/tests/base.py b/tests/base.py index ac74b67..4611dcf 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,6 +1,6 @@ from io import StringIO -from cms.models import PageContent +from cms.api import create_page, create_title from cms.utils.i18n import get_language_list from django.contrib.auth.models import User from django.http import HttpResponse, SimpleCookie @@ -30,17 +30,46 @@ def setUpClass(cls): cls.user_normal = User.objects.create(username="normal") def get_pages(self): - from cms.api import create_page, create_title + try: + from cms.models import PageContent # noqa: F401 + + return self._cms_4_pages() + except ImportError: + return self._cms_3_pages() + + def _cms_3_pages(self): + page_1 = create_page("page one", "page.html", language="en") + page_2 = create_page("page two", "page.html", language="en") + page_3 = create_page("page three", "page.html", language="en") + create_title(language="fr", title="page un", page=page_1) + create_title(language="it", title="pagina uno", page=page_1) + create_title(language="fr", title="page trois", page=page_3) + for lang in self.languages: + page_1.publish(lang) + page_2.publish("en") + page_3.publish("en") + page_3.publish("fr") + if hasattr(page_1, "set_as_homepage"): + page_1.set_as_homepage() + + return ( + page_1.get_draft_object(), + page_2.get_draft_object(), + page_3.get_draft_object(), + ) + + def _cms_4_pages(self): + from cms.models import PageContent # noqa: F401 page_1 = create_page("page one", "page.html", language="en", created_by=self.user) page_2 = create_page("page two", "page.html", language="en", created_by=self.user) page_3 = create_page("page three", "page.html", language="en", created_by=self.user) + page_content1 = PageContent._base_manager.get(page=page_1, language="en") + page_content2 = PageContent._base_manager.get(page=page_2, language="en") + page_content3 = PageContent._base_manager.get(page=page_3, language="en") page_1_content_fr = create_title(language="fr", title="page un", page=page_1, created_by=self.user) page_1_content_it = create_title(language="it", title="pagina uno", page=page_1, created_by=self.user) page_3_content_fr = create_title(language="fr", title="page trois", page=page_3, created_by=self.user) - page_content1 = PageContent._original_manager.get(page=page_1, language="en") - page_content2 = PageContent._original_manager.get(page=page_2, language="en") - page_content3 = PageContent._original_manager.get(page=page_3, language="en") if is_versioning_enabled(): page_content1.versions.first().publish(self.user) page_content2.versions.first().publish(self.user) @@ -50,19 +79,7 @@ def get_pages(self): page_3_content_fr.versions.first().publish(self.user) if hasattr(page_1, "set_as_homepage"): page_1.set_as_homepage() - if hasattr(page_1, "publish"): - for lang in self.languages: - page_1.publish(lang) - page_2.publish("en") - page_3.publish("en") - page_3.publish("fr") - return ( - page_1.get_draft_object(), - page_2.get_draft_object(), - page_3.get_draft_object(), - ) - else: - return page_1, page_2, page_3 + return page_1, page_2, page_3 def get_request(self, page, lang): request = self.request_factory.get(page.get_path(lang)) @@ -90,7 +107,7 @@ def get_page_request(self, page, user, path=None, edit=False, lang_code="en"): request.GET = {"edit_off": None} request.current_page = page if hasattr(ToolbarMiddleware, "process_request"): - mid = ToolbarMiddleware() + mid = ToolbarMiddleware(lambda req: HttpResponse()) mid.process_request(request) else: mid = ToolbarMiddleware(lambda req: HttpResponse()) diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index 90f253d..facd270 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -1,6 +1,7 @@ from decimal import Decimal from unittest import skipIf +import cms from cms.api import create_page, create_title from cms.test_utils.util.fuzzy_int import FuzzyInt from django.core.cache import cache @@ -17,11 +18,15 @@ class SitemapTest(BaseTest): def test_sitemap_base(self): page1, page2, page3 = self.get_pages() + try: + title_language = page1.get_title_obj().language + except AttributeError: + title_language = page1.get_page_content_obj_attribute("language") + sitemap = self.client.get("/sitemap.xml") test_string = ( "http://example.com/%s/%s" - "monthly0.5" - % (page1.get_title_obj().language, now().strftime("%Y-%m-%d")) + "monthly0.5" % (title_language, now().strftime("%Y-%m-%d")) ) self.assertContains(sitemap, test_string) @@ -30,10 +35,14 @@ def test_sitemap_extended(self): PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") if hasattr(page1, "publish"): page1.publish("it") + + try: + title_language = page1.get_title_obj().language + except AttributeError: + title_language = page1.get_page_content_obj_attribute("language") test_string = ( "http://example.com/%s/%s" - "never0.2" - % (page1.get_title_obj().language, now().strftime("%Y-%m-%d")) + "never0.2" % (title_language, now().strftime("%Y-%m-%d")) ) sitemap = self.client.get("/sitemap.xml") self.assertContains(sitemap, test_string) @@ -48,14 +57,17 @@ def test_sitemap_exclude(self): include_in_sitemap=False, ) sitemap = ExtendedSitemap() - # unpublished since change, still in the sitemap - self.assertEqual(len(sitemap.items()), 4) + # If publish is available, page must be published for property to be recognized if hasattr(page1, "publish"): + # unpublished since change, still in the sitemap + self.assertEqual(len(sitemap.items()), 6) page3.publish("en") page3.publish("fr") - sitemap = ExtendedSitemap() - # published, then no longer in the sitemap - self.assertEqual(len(sitemap.items()), 4) + sitemap = ExtendedSitemap() + # published, then no longer in the sitemap + self.assertEqual(len(sitemap.items()), 4) + else: + self.assertEqual(len(sitemap.items()), 4) def test_sitemap_cache(self): page1, page2, page3 = self.get_pages() @@ -111,6 +123,11 @@ def test_sitemap_items_query_performance(self): PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") PageSitemapProperties.objects.create(extended_object=page3, priority="0.8", changefreq="hourly") sitemap = ExtendedSitemap() - max_queries = 4 - with self.assertNumQueries(FuzzyInt(3, max_queries)): - self.assertEqual(len(sitemap.items()), 6) + + if cms.__version__ < "4.0": + with self.assertNumQueries(1): + self.assertEqual(len(sitemap.items()), 6) + else: + max_queries = 4 + with self.assertNumQueries(FuzzyInt(3, max_queries)): + self.assertEqual(len(sitemap.items()), 6) diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index f157068..af2ad15 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -1,8 +1,9 @@ +from unittest import skipIf + +import cms from cms.api import create_page -from cms.models import PageContent from cms.test_utils.testcases import CMSTestCase from cms.toolbar.items import Menu, ModalItem -from cms.toolbar.utils import get_object_preview_url from django.contrib.auth.models import Permission, User from django.test.utils import override_settings from django.urls import reverse @@ -169,12 +170,16 @@ def test_toolbar_with_items(self): class VersioningToolbarTest(CMSTestCase): + @skipIf(cms.__version__ < "4.0", "Versioning not available if django CMS < 4") def test_toolbar_buttons_are_not_duplicated(self): """ The toolbar for djangocms-page-sitemap doesn't affect the toolbar buttons. This test Can be ran with or without versioning and should return the same result! """ + from cms.models import PageContent + from cms.toolbar.utils import get_object_preview_url + user = self.get_superuser() page_1 = create_page("page-one", "page.html", language="en", created_by=user) page_content = PageContent._original_manager.get(page=page_1, language="en") @@ -190,5 +195,5 @@ def test_toolbar_buttons_are_not_duplicated(self): create_button_list = find_toolbar_buttons("Create", response.wsgi_request.toolbar) # Only one edit and create button should exist - self.assertEqual(len(edit_button_list), 1) self.assertEqual(len(create_button_list), 1) + self.assertEqual(len(edit_button_list), 1) diff --git a/tox.ini b/tox.ini index 97ce37b..460a976 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ envlist = ruff pypi-description towncrier + py{311,310,39}-django{42}-cms{4} py{311,310,39}-django{42,41}-cms{311} py{311,310,39}-django{32}-cms{311,39} @@ -19,6 +20,8 @@ deps = django42: Django~=4.2.0 cms39: https://github.com/django-cms/django-cms/archive/release/3.9.x.zip cms311: https://github.com/yakky/django-cms/archive/release/3.11.x.zip + cms4: https://github.com/django-cms/django-cms/archive/release/4.1.x.zip + cms4: https://github.com/django-cms/djangocms-versioning/archive/refs/heads/master.zip -r{toxinidir}/requirements-test.txt passenv = COMMAND From 1b3fbc17cf067cf61707a432c5751e6ab98e488f Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 12 May 2023 23:32:03 +0200 Subject: [PATCH 36/37] Fix test --- tests/test_toolbar.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index af2ad15..1ec9857 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -182,7 +182,7 @@ def test_toolbar_buttons_are_not_duplicated(self): user = self.get_superuser() page_1 = create_page("page-one", "page.html", language="en", created_by=user) - page_content = PageContent._original_manager.get(page=page_1, language="en") + page_content = PageContent._base_manager.get(page=page_1, language="en") if is_versioning_enabled(): page_content.versions.first().publish(user) @@ -192,8 +192,11 @@ def test_toolbar_buttons_are_not_duplicated(self): response = self.client.post(preview_endpoint) edit_button_list = find_toolbar_buttons("Edit", response.wsgi_request.toolbar) + new_draft_button_list = find_toolbar_buttons("New Draft", response.wsgi_request.toolbar) create_button_list = find_toolbar_buttons("Create", response.wsgi_request.toolbar) - # Only one edit and create button should exist self.assertEqual(len(create_button_list), 1) - self.assertEqual(len(edit_button_list), 1) + if is_versioning_enabled(): + self.assertEqual(len(new_draft_button_list), 1) + else: + self.assertEqual(len(edit_button_list), 1) From 55dbdac77f6f52344ef5da4aa6e38de4e59740b0 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 12 May 2023 23:45:04 +0200 Subject: [PATCH 37/37] Fix coverage --- djangocms_page_sitemap/utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/djangocms_page_sitemap/utils.py b/djangocms_page_sitemap/utils.py index d861a4e..2428efb 100644 --- a/djangocms_page_sitemap/utils.py +++ b/djangocms_page_sitemap/utils.py @@ -6,10 +6,7 @@ def get_cache_key(page): """ Create the cache key for the current page and language """ - try: - site_id = page.node.site_id - except AttributeError: - site_id = page.site_id + site_id = page.node.site_id return _get_cache_key("page_sitemap", page, "default", site_id) @@ -21,7 +18,7 @@ def is_versioning_enabled(): try: app_config = apps.get_app_config("djangocms_versioning") return app_config.cms_extension.is_content_model_versioned(PageContent) - except LookupError: + except LookupError: # pragma: no cover return False except ImportError: return False