From b423137577ed379b9b8f24fb55de6c9c70537fe1 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 2 May 2020 22:28:18 +0200 Subject: [PATCH 01/44] Temporarely pin tests to django CMS 3.7.1 (#53) --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 1b8e1b8..708b4cf 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ deps = 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 + cms37: django-cms==3.7.1 cmsdev: https://github.com/divio/django-cms/archive/develop.zip -r{toxinidir}/requirements-test.txt From ea486d2c8bb132f41f8466a415eb90c8df458b73 Mon Sep 17 00:00:00 2001 From: fp4code Date: Sat, 2 May 2020 22:31:55 +0200 Subject: [PATCH 02/44] Compatibility with Django-CMS 3.7.2 (#52) * Compatibility with Django-CMS 3.7.2 Co-authored-by: Fabrice Pardo --- djangocms_page_sitemap/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index f2597fc..8ff32df 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -3,7 +3,7 @@ from cms.extensions import PageExtension, extension_pool from cms.models import Page -from cms.utils.compat.dj import python_2_unicode_compatible +from six import python_2_unicode_compatible from django.core.cache import cache from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models From c4885df9a5123f4a777fd964f5b9c45cb06df5c8 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 2 May 2020 23:31:43 +0200 Subject: [PATCH 03/44] Enable django CMS 3.7.2 on python 3 (#54) --- djangocms_page_sitemap/models.py | 2 +- tox.ini | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index 8ff32df..d9d5cd7 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -3,13 +3,13 @@ from cms.extensions import PageExtension, extension_pool from cms.models import Page -from six import python_2_unicode_compatible from django.core.cache import cache from django.core.validators import MaxValueValidator, MinValueValidator 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 six import python_2_unicode_compatible from .settings import PAGE_SITEMAP_CHANGEFREQ_LIST from .utils import get_cache_key diff --git a/tox.ini b/tox.ini index 708b4cf..2cb2170 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,9 @@ deps = 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: django-cms==3.7.1 + py27-django111-cms37: django-cms==3.7.1 + py27-django111-cms37: django-formtools>=2.1,<2.2 + cms37: https://github.com/divio/django-cms/archive/release/3.7.x.zip cmsdev: https://github.com/divio/django-cms/archive/develop.zip -r{toxinidir}/requirements-test.txt From 2cb67c383bd3be05d17531245818483578620d0e Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 2 May 2020 23:39:37 +0200 Subject: [PATCH 04/44] Release 0.8.1 --- AUTHORS.rst | 1 + HISTORY.rst | 5 +++++ djangocms_page_sitemap/__init__.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 9055d72..b102b1c 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -12,4 +12,5 @@ Contributors * Anton Egorov * carderm +* Fabrice Pardo * Jeroen Peters diff --git a/HISTORY.rst b/HISTORY.rst index cf3126e..6e4c5d0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,11 @@ History ------- +0.8.1 (2020-05-02) +++++++++++++++++++ + +* Relicense under BSD license + 0.8.0 (2020-01-12) ++++++++++++++++++ diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 99aa543..95b875c 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.8.1' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover From c16fae82f9be2b628be33f2036401c8e3447d566 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 2 May 2020 23:54:04 +0200 Subject: [PATCH 05/44] Bump develop version [ci skip] --- HISTORY.rst | 5 +++++ djangocms_page_sitemap/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6e4c5d0..4af1bd6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,11 @@ History ------- +0.8.2 (unreleased) +++++++++++++++++++ + +* Nothing yet + 0.8.1 (2020-05-02) ++++++++++++++++++ diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 95b875c..79ccc64 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.1' # pragma: no cover +__version__ = '0.8.2.dev1' # pragma: no cover __author__ = 'Iacopo Spalletti ' # pragma: no cover From 05c93d561c96185fc44f48342fab8886c1662505 Mon Sep 17 00:00:00 2001 From: Leonardo Cavallucci Date: Thu, 12 Nov 2020 17:14:26 +0100 Subject: [PATCH 06/44] Update tooling and drop Python 2 / Django < 2.2 (#62) * Bump develop version [ci skip] * Remove useless try/except as it is an old syntax * Fix HISTORY.rst syntax * Remove leftovers from template project Co-authored-by: Iacopo Spalletti --- .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 | 522 +++++++++++++++++- .pre-commit-config.yaml | 62 +++ .pyup.yml | 7 + .readthedocs.yaml | 19 + .travis.yml | 66 --- .tx/config | 1 - CONTRIBUTING.rst | 105 +++- HISTORY.rst | 39 +- LICENSE | 4 +- MANIFEST.in | 3 +- Makefile | 46 -- aldryn_config.py | 26 +- changes/10208.feature | 1 + cms_helper.py | 78 +-- djangocms_page_sitemap/__init__.py | 7 +- djangocms_page_sitemap/admin.py | 3 - djangocms_page_sitemap/cms_toolbars.py | 43 +- .../locale/ar/LC_MESSAGES/django.po | 2 +- .../locale/de/LC_MESSAGES/django.po | 2 +- .../locale/en/LC_MESSAGES/django.po | 2 +- .../locale/es/LC_MESSAGES/django.po | 2 +- .../locale/it/LC_MESSAGES/django.po | 2 +- .../locale/lt/LC_MESSAGES/django.po | 2 +- .../locale/pt_BR/LC_MESSAGES/django.po | 2 +- .../locale/ru/LC_MESSAGES/django.po | 2 +- .../locale/tr/LC_MESSAGES/django.po | 2 +- .../migrations/0001_initial.py | 59 +- .../migrations/0002_auto_20151018_1451.py | 22 +- .../migrations/0003_auto_20151018_1612.py | 31 +- .../migrations/0004_auto_20180202_1044.py | 35 +- .../migrations/0005_auto_20180324_1050.py | 16 +- djangocms_page_sitemap/models.py | 39 +- djangocms_page_sitemap/settings.py | 27 +- djangocms_page_sitemap/sitemap.py | 19 +- djangocms_page_sitemap/sitemap_urls.py | 5 +- .../templatetags/__init__.py | 1 - .../templatetags/robots_index.py | 26 +- djangocms_page_sitemap/utils.py | 10 +- 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 | 8 +- requirements.txt | 2 +- setup.cfg | 84 ++- setup.py | 64 +-- tasks.py | 140 +++++ tests/__init__.py | 1 - tests/base.py | 52 +- tests/test_models.py | 84 ++- tests/test_sitemap.py | 53 +- tests/test_toolbar.py | 72 +-- tests/test_utils/__init__.py | 1 - tests/test_utils/urls.py | 23 +- tox.ini | 163 +++++- 72 files changed, 1827 insertions(+), 724 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 changes/10208.feature 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..0137a63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,524 @@ + +# 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 + +# 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 145e3e2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,66 +0,0 @@ -language: python -dist: xenial - -python: - - 3.7 - - 3.6 - - 3.5 - - 2.7 - -env: - matrix: - - 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' - - -# 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='cms37' - - python: 2.7 - env: DJANGO='django21' CMS='cms37' - - python: 2.7 - env: DJANGO='django21' CMS='cms36' 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 4af1bd6..10fb5f8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,25 +1,26 @@ .. :changelog: +******* History -------- +******* 0.8.2 (unreleased) -++++++++++++++++++ +================== * Nothing yet 0.8.1 (2020-05-02) -++++++++++++++++++ +================== * Relicense under BSD license 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 @@ -27,36 +28,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 @@ -64,45 +65,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/aldryn_config.py b/aldryn_config.py index 66499b1..f0eeab7 100644 --- a/aldryn_config.py +++ b/aldryn_config.py @@ -1,32 +1,30 @@ -# -*- coding: utf-8 -*- try: from divio_cli import forms except ImportError: 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)', - required=False + "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/changes/10208.feature b/changes/10208.feature new file mode 100644 index 0000000..517cf37 --- /dev/null +++ b/changes/10208.feature @@ -0,0 +1 @@ +Update tooling and drop Python 2 / Django < 2.2 compatibility diff --git a/cms_helper.py b/cms_helper.py index cd2a474..4dae60a 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -1,77 +1,77 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - -import sys 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', - 'INSTALLED_APPS': [ - 'django.contrib.sitemaps', + "ROOT_URLCONF": "tests.test_utils.urls", + "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, }, }, - } def run(): from app_helper import runner - runner.cms('djangocms_page_sitemap') + + 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) + + 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 79ccc64..48c86b9 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,5 +1,2 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - -__version__ = '0.8.2.dev1' # pragma: no cover -__author__ = 'Iacopo Spalletti ' # pragma: no cover +__version__ = "0.8.2.dev1" +__author__ = "Iacopo Spalletti " diff --git a/djangocms_page_sitemap/admin.py b/djangocms_page_sitemap/admin.py index 05e9937..3f468f3 100644 --- a/djangocms_page_sitemap/admin.py +++ b/djangocms_page_sitemap/admin.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -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 f44693c..e69b64a 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -1,6 +1,3 @@ -# -*- 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 @@ -13,7 +10,7 @@ from .models import PageSitemapProperties -PAGE_SITEMAP_MENU_TITLE = _('Sitemap properties') +PAGE_SITEMAP_MENU_TITLE = _("Sitemap properties") @toolbar_pool.register @@ -26,26 +23,18 @@ 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 # 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: - 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 - current_page_menu = self.toolbar.get_or_create_menu('page') - position = current_page_menu.find_first( - Break, identifier=PAGE_MENU_THIRD_BREAK) - 1 + 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) @@ -53,16 +42,22 @@ 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, position=position + PAGE_SITEMAP_MENU_TITLE, + url=url, + disabled=not_edit_mode, + position=position, ) 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.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.po b/djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po index cb1d926..0111082 100644 --- a/djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/en/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: msgid "" msgstr "" diff --git a/djangocms_page_sitemap/locale/es/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/es/LC_MESSAGES/django.po index 324a86e..5357db0 100644 --- a/djangocms_page_sitemap/locale/es/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/es/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: msgid "" msgstr "" diff --git a/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po index 7c40d93..2b68f21 100644 --- a/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/it/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: # yakky , 2015 msgid "" diff --git a/djangocms_page_sitemap/locale/lt/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/lt/LC_MESSAGES/django.po index 2c6f54b..fe95979 100644 --- a/djangocms_page_sitemap/locale/lt/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/lt/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: # Matas Dailyda , 2015 msgid "" diff --git a/djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.po index f24abf0..13f356f 100644 --- a/djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/pt_BR/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: msgid "" msgstr "" 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.po b/djangocms_page_sitemap/locale/tr/LC_MESSAGES/django.po index 01d66de..a4a1eda 100644 --- a/djangocms_page_sitemap/locale/tr/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/tr/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: msgid "" msgstr "" diff --git a/djangocms_page_sitemap/migrations/0001_initial.py b/djangocms_page_sitemap/migrations/0001_initial.py index a560ff6..fafdbc7 100644 --- a/djangocms_page_sitemap/migrations/0001_initial.py +++ b/djangocms_page_sitemap/migrations/0001_initial.py @@ -1,8 +1,5 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - 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 @@ -10,21 +7,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 b0ff842..43f8ebd 100644 --- a/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py +++ b/djangocms_page_sitemap/migrations/0002_auto_20151018_1451.py @@ -1,25 +1,27 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models + from djangocms_page_sitemap.settings import PAGE_SITEMAP_CHANGEFREQ_LIST 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 564f1f2..15998da 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 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - import django.core.validators from django.db import migrations, models @@ -10,18 +7,32 @@ 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 762a83e..410bae4 100644 --- a/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py +++ b/djangocms_page_sitemap/migrations/0004_auto_20180202_1044.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.8 on 2018-02-02 09:44 -from __future__ import unicode_literals from django.db import migrations, models @@ -8,23 +6,36 @@ 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 fda955a..4b43821 100644 --- a/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py +++ b/djangocms_page_sitemap/migrations/0005_auto_20180324_1050.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.10 on 2018-03-24 09:50 -from __future__ import unicode_literals from django.db import migrations, models @@ -8,13 +6,19 @@ 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 d9d5cd7..e835f7b 100644 --- a/djangocms_page_sitemap/models.py +++ b/djangocms_page_sitemap/models.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from cms.extensions import PageExtension, extension_pool from cms.models import Page from django.core.cache import cache @@ -9,39 +6,47 @@ from django.db.models.signals import post_save, pre_delete from django.dispatch import receiver from django.utils.translation import ugettext_lazy as _ -from six import python_2_unicode_compatible from .settings import PAGE_SITEMAP_CHANGEFREQ_LIST from .utils import get_cache_key @extension_pool.register -@python_2_unicode_compatible 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) + 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 406886f..ab08b1e 100644 --- a/djangocms_page_sitemap/settings.py +++ b/djangocms_page_sitemap/settings.py @@ -1,24 +1,17 @@ -# -*- coding: utf-8 -*- -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 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 -) -PAGE_SITEMAP_DEFAULT_CHANGEFREQ = getattr( - settings, 'PAGE_SITEMAP_DEFAULT_CHANGEFREQ', CMSSitemap.changefreq -) -PAGE_SITEMAP_CACHE_DURATION = get_cms_setting('CACHE_DURATIONS')['menus'] +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 0dad866..eb9a47c 100644 --- a/djangocms_page_sitemap/sitemap.py +++ b/djangocms_page_sitemap/sitemap.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from cms.sitemaps import CMSSitemap from django.core.cache import cache @@ -14,9 +11,7 @@ class ExtendedSitemap(CMSSitemap): default_priority = CMSSitemap.priority def items(self): - return super(ExtendedSitemap, self).items().exclude( - page__pagesitemapproperties__include_in_sitemap=False - ) + return super().items().exclude(page__pagesitemapproperties__include_in_sitemap=False) def priority(self, title): ext_key = get_cache_key(title.page) @@ -25,7 +20,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 @@ -37,7 +36,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/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py index cf65490..732b3df 100644 --- a/djangocms_page_sitemap/sitemap_urls.py +++ b/djangocms_page_sitemap/sitemap_urls.py @@ -1,11 +1,8 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from django.conf.urls import url from django.contrib.sitemaps.views import sitemap from .sitemap import ExtendedSitemap urlpatterns = [ - url(r'^sitemap\.xml$', sitemap, {'sitemaps': {'cmspages': ExtendedSitemap}}), + url(r"^sitemap\.xml$", sitemap, {"sitemaps": {"cmspages": ExtendedSitemap}}), ] diff --git a/djangocms_page_sitemap/templatetags/__init__.py b/djangocms_page_sitemap/templatetags/__init__.py index 40a96af..e69de29 100644 --- a/djangocms_page_sitemap/templatetags/__init__.py +++ b/djangocms_page_sitemap/templatetags/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/djangocms_page_sitemap/templatetags/robots_index.py b/djangocms_page_sitemap/templatetags/robots_index.py index 8a3c47c..e916e97 100644 --- a/djangocms_page_sitemap/templatetags/robots_index.py +++ b/djangocms_page_sitemap/templatetags/robots_index.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -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 @@ -11,21 +8,22 @@ 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 '' + return "" if not site_id: site_id = get_current_site(request).pk if not page: @@ -37,14 +35,14 @@ 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') + 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 f68cf52..e7b4c9a 100644 --- a/djangocms_page_sitemap/utils.py +++ b/djangocms_page_sitemap/utils.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from cms.cache import _get_cache_key @@ -8,8 +5,5 @@ 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 - return _get_cache_key('page_sitemap', page, 'default', site_id) + site_id = page.node.site_id + return _get_cache_key("page_sitemap", page, "default", site_id) 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..92d3767 --- /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..01b9c1b 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,5 +1,7 @@ -coverage<5.0 +-r requirements.txt +coverage coveralls -flake8>=2.1.0 -tox>=2.0 +mock>=1.0.1 +flake8 +tox django-app-helper 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..9d77665 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 = 0.8.2.dev1 +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 +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 3c6b4c9..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, - install_requires=[ - 'django-cms>=3.6', - ], - 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', - ], -) +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") diff --git a/tests/__init__.py b/tests/__init__.py index 40a96af..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tests/base.py b/tests/base.py index 5989930..35e4c15 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,49 +1,52 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - 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 six import StringIO 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') - 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") + 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_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.get_draft_object(), + page_2.get_draft_object(), + page_3.get_draft_object(), + ) def get_request(self, page, lang): request = self.request_factory.get(page.get_path(lang)) @@ -55,19 +58,20 @@ 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() mid.process_request(request) diff --git a/tests/test_models.py b/tests/test_models.py index aff04f2..57c8711 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -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 @@ -12,7 +9,6 @@ class RobotsTest(BaseTest): - def _test_robots_tag(self, template_string, context, expected): tpl_obj = template.Template(template_string) @@ -23,26 +19,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 @@ -55,82 +49,74 @@ 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' - ) - page1.publish('en') + 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())} + template = "{% load robots_index %}{% page_robots %}" + expected = "" + context = {"request": self.get_page_request(page2.get_public_object(), AnonymousUser())} self._test_robots_tag(template, context, expected) extension.noindex = True extension.save() - page1.publish('en') - expected = '' + 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() - page1.publish('en') + page1.publish("en") expected = '' self._test_robots_tag(template, context, expected) - extension.robots_extra = 'nodmoz' + extension.robots_extra = "nodmoz" extension.save() - page1.publish('en') + 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' - ) - page1.publish('en') + 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())} + expected = "" + context = {"request": self.get_page_request(page2.get_public_object(), 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' - ) - page1.publish('en') + 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())} + expected = "" + context = {"request": self.get_page_request(page2.get_public_object(), 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' - ) - page1.publish('en') + 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())} + template = "{%% load robots_index %%}{%% page_robots None %s %%}" % site_2.pk + expected = "" + context = {"request": self.get_page_request(page2.get_public_object(), AnonymousUser())} self._test_robots_tag(template, context, expected) diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index aa87b88..23208e0 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from decimal import Decimal from django.core.cache import cache @@ -14,61 +11,63 @@ class SitemapTest(BaseTest): - def test_sitemap_base(self): - test_string = 'http://example.com/it/%smonthly0.5' % now().strftime('%Y-%m-%d') + test_string = ( + "http://example.com/it/" + "%smonthly0.5" % now().strftime("%Y-%m-%d") + ) self.get_pages() - sitemap = self.client.get('/sitemap.xml') + sitemap = self.client.get("/sitemap.xml") 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/it/" + "%snever0.2" % now().strftime("%Y-%m-%d") ) - page1.publish('it') - sitemap = self.client.get('/sitemap.xml') + page1, page2, page3 = self.get_pages() + 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) 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 self.assertEqual(len(sitemap.items()), 6) - 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) 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' - ) - page1.publish('fr') + PageSitemapProperties.objects.create(extended_object=page1, priority="0.2", changefreq="never") + PageSitemapProperties.objects.create(extended_object=page3, priority="0.8", changefreq="hourly") + page1.publish("fr") page1 = page1.get_public_object() - page3.publish('fr') + page3.publish("fr") page3 = page3.get_public_object() 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() diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index af132b2..e9131b4 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from cms.toolbar.items import Menu, ModalItem from django.contrib.auth.models import Permission, User from django.test.utils import override_settings @@ -15,16 +12,16 @@ 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): @@ -32,11 +29,12 @@ 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) @@ -45,20 +43,23 @@ 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_text(PAGE_SITEMAP_MENU_TITLE))), 1 + len(page_menu.find_items(ModalItem, name="%s..." % force_text(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_text(PAGE_SITEMAP_MENU_TITLE))), + 1, ) @override_settings(CMS_PERMISSION=True) @@ -67,13 +68,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): @@ -81,18 +83,21 @@ 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_text(PAGE_SITEMAP_MENU_TITLE))), 1 + len(page_menu.find_items(ModalItem, name="%s..." % force_text(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_text(PAGE_SITEMAP_MENU_TITLE))), + 1, ) def test_toolbar_with_items(self): @@ -100,20 +105,23 @@ 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_text(PAGE_SITEMAP_MENU_TITLE) - )[0].item + meta_menu = page_menu.find_items(ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE))[0].item except IndexError: - meta_menu = page_menu.find_items( - ModalItem, name="%s ..." % force_text(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)) + meta_menu = page_menu.find_items(ModalItem, name="%s ..." % force_text(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)) diff --git a/tests/test_utils/__init__.py b/tests/test_utils/__init__.py index 40a96af..e69de29 100644 --- a/tests/test_utils/__init__.py +++ b/tests/test_utils/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py index 97cf06a..4ceba77 100644 --- a/tests/test_utils/urls.py +++ b/tests/test_utils/urls.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -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 @@ -14,16 +11,22 @@ admin.autodiscover() urlpatterns = [ - url(r'^media/(?P.*)$', serve, - {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), - url(r'^media/cms/(?P.*)$', serve, - {'document_root': get_cms_setting('MEDIA_ROOT'), 'show_indexes': True}), - url(r'^', include(sitemap_urls)), + url( + r"^media/(?P.*)$", + serve, + {"document_root": settings.MEDIA_ROOT, "show_indexes": True}, + ), + url( + r"^media/cms/(?P.*)$", + serve, + {"document_root": get_cms_setting("MEDIA_ROOT"), "show_indexes": True}, + ), + url(r"^", include(sitemap_urls)), ] urlpatterns += staticfiles_urlpatterns() urlpatterns += i18n_patterns( - url(r'^admin/', admin.site.urls), - url(r'^', include('cms.urls')), + url(r"^admin/", admin.site.urls), + url(r"^", include("cms.urls")), ) diff --git a/tox.ini b/tox.ini index 2cb2170..60f1f11 100644 --- a/tox.ini +++ b/tox.ini @@ -1,36 +1,161 @@ [tox] -envlist = docs,pep8,isort,py{37,36,35}-django{22}-cms{37},py{37,36,35}-django{21,111}-cms{37,36} +envlist = + black + blacken + docs + isort + isort_format + pep8 + pypi-description + towncrier + py{38,37,36}-django{31}-cms{38} + py{38,37,36}-django{30}-cms{38,37} + py{38,37,36}-django{22}-cms{38,37} [testenv] -commands = {env:COMMAND:python} setup.py test +commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} deps = - django111: Django>=1.11,<2.0 - 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 - py27-django111-cms37: django-cms==3.7.1 - py27-django111-cms37: django-formtools>=2.1,<2.2 + django22: Django>=2.2,<3.0 + django30: Django>=3.0,<3.1 + django31: Django>=3.1,<3.2 cms37: https://github.com/divio/django-cms/archive/release/3.7.x.zip - cmsdev: https://github.com/divio/django-cms/archive/develop.zip + cms38: https://github.com/divio/django-cms/archive/release/3.8.x.zip -r{toxinidir}/requirements-test.txt +passenv = + COMMAND + PYTEST_* + +[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 -c -rc -deps = isort +commands = + {envpython} -m isort -c --df djangocms_page_sitemap tests +deps = isort>5,<6 skip_install = true -[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 [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 + .[docs] + -rrequirements-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 + +[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 4075185af8175ef8525e026b4655f3914d32beb6 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 21 Dec 2020 00:16:29 +0100 Subject: [PATCH 07/44] Update authors file --- AUTHORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index b102b1c..c1486a3 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -13,4 +13,6 @@ Contributors * Anton Egorov * carderm * Fabrice Pardo +* fp4code * Jeroen Peters +* Leonardo Cavallucci From fa325210ff414c0448b10d2bd6da0a7d29c7ec49 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 21 Dec 2020 09:15:00 +0100 Subject: [PATCH 08/44] Add configuration for django-app-enabler (#65) * Add support for django-app-enabler * Update readme * Update dependencies --- README.rst | 102 +++++++++++++++++------------- addon.json | 7 +- changes/63.feature | 1 + djangocms_page_sitemap/addon.json | 12 ++++ requirements-test.txt | 10 ++- setup.cfg | 2 +- tox.ini | 1 - 7 files changed, 76 insertions(+), 59 deletions(-) mode change 100644 => 120000 addon.json create mode 100644 changes/63.feature create mode 100644 djangocms_page_sitemap/addon.json diff --git a/README.rst b/README.rst index 211fe7d..858e290 100644 --- a/README.rst +++ b/README.rst @@ -40,68 +40,79 @@ Quickstart pip install djangocms-page-sitemap -* Add to ``INSTALLED_APPS`` with ``django.contrib.sitemaps``:: +* Add to ``INSTALLED_APPS`` with ``django.contrib.sitemaps``: - INSTALLED_APPS = [ - ... - 'django.contrib.sitemaps', - 'djangocms_page_sitemap', - ] - -* 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")), + ... + ] -* Add the following snippets to the django CMS templates:: +* 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): - {% load robots_index %} + .. code-block:: html+django - ... - - - {% page_robots %} - - ... + {% load robots_index %} + + ... + + + {% 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 ----- @@ -116,7 +127,7 @@ 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 @@ -137,6 +148,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/changes/63.feature b/changes/63.feature new file mode 100644 index 0000000..3da4e2e --- /dev/null +++ b/changes/63.feature @@ -0,0 +1 @@ +Add support for django-app-enabler 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/requirements-test.txt b/requirements-test.txt index 01b9c1b..4f6ebe2 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,5 @@ --r requirements.txt -coverage -coveralls +-e .[docs] +coverage>5 +coveralls>2 mock>=1.0.1 -flake8 -tox -django-app-helper +django-app-helper>=2.0.0 diff --git a/setup.cfg b/setup.cfg index 9d77665..23705c4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,7 +34,7 @@ long_description = file: README.rst, HISTORY.rst long_description_content_type = text/x-rst license = BSD license_file = LICENSE -keywords = django cms, sitemap +keywords = django cms, sitemap, django-app-enabler addon classifiers = Development Status :: 5 - Production/Stable Framework :: Django diff --git a/tox.ini b/tox.ini index 60f1f11..ecd3e50 100644 --- a/tox.ini +++ b/tox.ini @@ -77,7 +77,6 @@ deps = sphinx-rtd-theme sphinx-autobuild livereload~=2.6 - .[docs] -rrequirements-test.txt skip_install = true From 1d6d55311e344b8510fcf2c89ccdfd27eada0ae3 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 21 Dec 2020 09:36:17 +0100 Subject: [PATCH 09/44] Compile po file --- .../locale/ar/LC_MESSAGES/django.mo | Bin 1210 -> 1169 bytes .../locale/de/LC_MESSAGES/django.mo | Bin 1051 -> 1010 bytes .../locale/en/LC_MESSAGES/django.mo | Bin 378 -> 1458 bytes .../locale/es/LC_MESSAGES/django.mo | Bin 493 -> 452 bytes .../locale/it/LC_MESSAGES/django.mo | Bin 1070 -> 1029 bytes .../locale/lt/LC_MESSAGES/django.mo | Bin 1159 -> 1118 bytes .../locale/pt_BR/LC_MESSAGES/django.mo | Bin 510 -> 469 bytes .../locale/ru/LC_MESSAGES/django.mo | Bin 1342 -> 1301 bytes .../locale/tr/LC_MESSAGES/django.mo | Bin 492 -> 451 bytes 9 files changed, 0 insertions(+), 0 deletions(-) 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/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/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( j3O0O_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/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`{S3OS|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/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{ Date: Mon, 21 Dec 2020 09:40:20 +0100 Subject: [PATCH 10/44] Release 1.0.0 --- HISTORY.rst | 12 +++++++++--- README.rst | 13 ++++++++----- changes/.directory | 0 changes/10208.feature | 1 - changes/63.feature | 1 - djangocms_page_sitemap/__init__.py | 2 +- pyproject.toml | 2 +- setup.cfg | 2 +- 8 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 changes/.directory delete mode 100644 changes/10208.feature delete mode 100644 changes/63.feature diff --git a/HISTORY.rst b/HISTORY.rst index 10fb5f8..4e0f054 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,15 +4,21 @@ History ******* -0.8.2 (unreleased) +.. towncrier release notes start + +1.0.0 (2020-12-21) ================== -* Nothing yet +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) ================== -* Relicense under BSD license +* Enable django CMS 3.7.2 on python 3 0.8.0 (2020-01-12) ================== diff --git a/README.rst b/README.rst index 858e290..edada5c 100644 --- a/README.rst +++ b/README.rst @@ -23,8 +23,9 @@ Supported django CMS versions: .. 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. +******** Features --------- +******** * Support for changefreq and priority customisation per-page * Option to exclude a page from the Sitemap @@ -33,8 +34,9 @@ Features * Available on Divio Cloud +********** Quickstart ----------- +********** * Install djangocms-page-sitemap:: @@ -114,8 +116,9 @@ Fully using this package will require some changes that cannot be modified by `` Check documentation above for details. +********** Usage ------ +********** After installing as above, you will be able to tune the sitemap setting for each page. @@ -131,7 +134,7 @@ For each page you will be able to set the following flags / values: * Provide any additional robots meta tag values page_robots options -------------------- +=================== ``page_robots`` meta tag accepts the following parameters: @@ -140,7 +143,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-) diff --git a/changes/.directory b/changes/.directory new file mode 100644 index 0000000..e69de29 diff --git a/changes/10208.feature b/changes/10208.feature deleted file mode 100644 index 517cf37..0000000 --- a/changes/10208.feature +++ /dev/null @@ -1 +0,0 @@ -Update tooling and drop Python 2 / Django < 2.2 compatibility diff --git a/changes/63.feature b/changes/63.feature deleted file mode 100644 index 3da4e2e..0000000 --- a/changes/63.feature +++ /dev/null @@ -1 +0,0 @@ -Add support for django-app-enabler diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 48c86b9..353c46f 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,2 +1,2 @@ -__version__ = "0.8.2.dev1" +__version__ = "1.0.0" __author__ = "Iacopo Spalletti " diff --git a/pyproject.toml b/pyproject.toml index 92d3767..f1ec81a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ target-version = ["py36"] include = 'djangocms_page_sitemap/*py' [tool.towncrier] -package = "djangocms-page-sitemap" +package = "djangocms_page_sitemap" directory = "changes" filename = "HISTORY.rst" title_format = "{version} ({project_date})" diff --git a/setup.cfg b/setup.cfg index 23705c4..84a0f85 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.8.2.dev1 +current_version = 1.0.0 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) serialize = {major}.{minor}.{patch}.{release}{relver} From e1efa53bfc908267989e418ad80de27a16660027 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 21 Dec 2021 10:42:41 +0000 Subject: [PATCH 11/44] 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 12/44] 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 13/44] 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 14/44] 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 15/44] 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 16/44] 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 17/44] 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 18/44] 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 19/44] 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 20/44] 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 21/44] 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 22/44] 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 23/44] 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 24/44] 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 25/44] 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 26/44] 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 27/44] 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 28/44] 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 29/44] 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 30/44] 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 fae85d12aea6b044029c9c47cb18d4c207112e2b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 27 Aug 2022 17:19:35 +0200 Subject: [PATCH 31/44] Upgrade to GitHub-native Dependabot (#69) Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml 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" From 9db580be39dbecb8dc16fe24e125e6288eab5f4a Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 17:42:39 +0200 Subject: [PATCH 32/44] feat: Backport cms 4.0.x - Django 3.2 with Python 3.8 & 3.9 support, including update tooling --- .github/dependabot.yml | 11 ++ .github/workflows/lint.yml | 12 +- .github/workflows/publish.yml | 10 +- .github/workflows/test.yml | 15 +-- .gitignore | 1 - .pre-commit-config.yaml | 19 +-- AUTHORS.rst | 7 +- HISTORY.rst | 14 ++ README.rst | 124 ++++++++++-------- addon.json | 7 +- aldryn_config.py | 4 +- changes/.directory | 0 changes/74.bugfix | 1 + changes/74.feature | 1 + cms_helper.py | 25 +--- djangocms_page_sitemap/__init__.py | 4 +- djangocms_page_sitemap/addon.json | 12 ++ djangocms_page_sitemap/cms_toolbars.py | 21 ++- .../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 | 2 +- .../locale/es/LC_MESSAGES/django.mo | Bin 493 -> 452 bytes .../locale/es/LC_MESSAGES/django.po | 2 +- .../locale/it/LC_MESSAGES/django.mo | Bin 1070 -> 1029 bytes .../locale/it/LC_MESSAGES/django.po | 2 +- .../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 | 2 +- .../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 | 2 +- .../migrations/0001_initial.py | 54 ++++++-- .../migrations/0002_auto_20151018_1451.py | 18 ++- .../migrations/0003_auto_20151018_1612.py | 28 +++- .../migrations/0004_auto_20180202_1044.py | 34 +++-- .../migrations/0005_auto_20180324_1050.py | 15 ++- djangocms_page_sitemap/models.py | 23 ++-- djangocms_page_sitemap/settings.py | 10 +- djangocms_page_sitemap/sitemap.py | 14 +- .../templatetags/__init__.py | 1 - .../templatetags/robots_index.py | 7 +- djangocms_page_sitemap/utils.py | 1 + requirements-test.txt | 11 +- setup.cfg | 4 +- tasks.py | 22 ++-- tests/__init__.py | 1 - tests/base.py | 35 ++--- tests/test_models.py | 67 ++++------ tests/test_sitemap.py | 77 +++++------ tests/test_toolbar.py | 63 ++++----- tests/test_utils/__init__.py | 1 - tests/test_utils/urls.py | 17 ++- tox.ini | 9 +- 58 files changed, 453 insertions(+), 365 deletions(-) create mode 100644 .github/dependabot.yml mode change 100644 => 120000 addon.json create mode 100644 changes/.directory create mode 100644 changes/74.bugfix create mode 100644 changes/74.feature create mode 100644 djangocms_page_sitemap/addon.json 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/lint.yml b/.github/workflows/lint.yml index d03bb3c..919d1c7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,26 +8,26 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]')" strategy: matrix: - python-version: [3.8] + python-version: [3.10.x] toxenv: [pep8, isort, black, pypi-description, docs, towncrier] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 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 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Cache pip - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.toxenv }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.toxenv }} - name: Cache tox - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .tox key: ${{ runner.os }}-lint-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }} @@ -35,7 +35,7 @@ jobs: ${{ runner.os }}-lint-${{ matrix.toxenv }}- - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools tox>=1.8 + python -m pip install --upgrade pip setuptools tox>=3.23 - name: Test with tox run: | tox -e${{ matrix.toxenv }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 07b9e64..c275874 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,20 +8,20 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Cache pip - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.toxenv }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.toxenv }} - name: Cache tox - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .tox key: ${{ runner.os }}-tox-release-${{ hashFiles('setup.cfg') }} @@ -29,7 +29,7 @@ jobs: ${{ runner.os }}-tox-release- - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools tox>=1.8 + python -m pip install --upgrade pip setuptools tox>=3.23 - name: Build and publish env: TWINE_USERNAME: __token__ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f298c8..96560a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,22 +11,21 @@ jobs: python-version: [3.9, 3.8, 3.7] django: [32, 22] cms: [40] - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Cache pip - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.toxenv }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.toxenv }} - name: Cache tox - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .tox key: ${{ runner.os }}-tox-${{ format('{{py{0}-django{1}-cms{2}}}', matrix.python-version, matrix.django, matrix.cms) }}-${{ hashFiles('setup.cfg') }} @@ -35,7 +34,7 @@ jobs: - name: Install dependencies run: | sudo apt-get install gettext - python -m pip install --upgrade pip tox>=3.5 + python -m pip install --upgrade pip setuptools tox>3.23 - name: Test with tox env: TOX_ENV: ${{ format('py-django{1}-cms{2}', matrix.python-version, matrix.django, matrix.cms) }} @@ -46,11 +45,11 @@ jobs: tox -e$TOX_ENV .tox/$TOX_ENV/bin/coverage xml .tox/$TOX_ENV/bin/coveralls - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} flags: unittests - file: ./coverage.xml + files: ./coverage.xml fail_ci_if_error: false services: redis: diff --git a/.gitignore b/.gitignore index 1125109..0137a63 100644 --- a/.gitignore +++ b/.gitignore @@ -268,7 +268,6 @@ 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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30dc5aa..0826147 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: "(.idea|node_modules|.tox)" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.3.0 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -16,16 +16,16 @@ 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.10.1" hooks: - id: isort - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.6.0 hooks: - id: black - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + - repo: https://github.com/PyCQA/flake8 + rev: 3.9.2 hooks: - id: flake8 additional_dependencies: @@ -40,14 +40,14 @@ repos: - flake8-tidy-imports - pep8-naming - repo: https://github.com/econchick/interrogate - rev: 1.3.1 + rev: 1.5.0 hooks: - id: interrogate args: - "-cpyproject.toml" - "--quiet" - repo: https://github.com/asottile/pyupgrade - rev: v2.7.3 + rev: v2.37.3 hooks: - id: pyupgrade args: @@ -60,3 +60,6 @@ repos: language: system pass_filenames: false always_run: true +ci: + skip: + - towncrier diff --git a/AUTHORS.rst b/AUTHORS.rst index 108dad2..e410f3e 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -1,6 +1,6 @@ -======= +=========== Credits -======= +=========== Development Lead ---------------- @@ -12,5 +12,8 @@ Contributors * Anton Egorov * carderm +* Fabrice Pardo +* fp4code * Jeroen Peters +* Leonardo Cavallucci * vipulnarang95 diff --git a/HISTORY.rst b/HISTORY.rst index 61e02c1..9d5bb38 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,12 +6,26 @@ History .. towncrier release notes start +1.0.0 (2020-12-21) +================== + +Features +-------- + +- Add support for django-app-enabler (#63) +- Update tooling and drop Python 2 / Django < 2.2 compatibility (#10208) + 0.9.0.dev8 (2020-11-23) ======================= * Port to django CMS 4.0 * Fix djangocms-versioning integration +0.8.1 (2020-05-02) +================== + +* Enable django CMS 3.7.2 on python 3 + 0.8.0 (2020-01-12) ================== 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..f0eeab7 100644 --- a/aldryn_config.py +++ b/aldryn_config.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- try: from divio_cli import forms except ImportError: @@ -21,8 +20,7 @@ class Form(forms.BaseForm): choices=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/changes/74.bugfix b/changes/74.bugfix new file mode 100644 index 0000000..2a8a5de --- /dev/null +++ b/changes/74.bugfix @@ -0,0 +1 @@ +Add support for Django 3.2 / django CMS 3.10 diff --git a/changes/74.feature b/changes/74.feature new file mode 100644 index 0000000..cd453dc --- /dev/null +++ b/changes/74.feature @@ -0,0 +1 @@ +Backport cms 4.0.x - Django 3.2 with Python 3.8 & 3.9 support diff --git a/cms_helper.py b/cms_helper.py index 9a78054..70b9bfb 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): @@ -19,9 +7,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 +18,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 +51,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..353c46f 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.0.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..5df981d 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,16 @@ 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" % ( + url = "{}?extended_object={}".format( reverse("admin:djangocms_page_sitemap_pagesitemapproperties_add"), - self.page.pk) + 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( j3O0O_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..2b68f21 100644 --- a/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/it/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: # yakky , 2015 msgid "" 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{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{" % ','.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/requirements-test.txt b/requirements-test.txt index 51fb298..1e6c7fa 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,6 @@ --e .[docs] -coverage>5 -coveralls>2 -mock>=1.0.1 -django-app-helper>=2.0.0 - +coverage<5.0 +coveralls +flake8>=2.1.0 +tox>=2.0 +django-app-helper https://github.com/Aiky30/djangocms-versioning/tarball/feature/django-32-compat#egg=djangocms-versioning diff --git a/setup.cfg b/setup.cfg index 0a5b76e..cdd4e69 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.0.dev8 +current_version = 1.0.0 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) serialize = {major}.{minor}.{patch}.{release}{relver} @@ -43,10 +43,12 @@ classifiers = Natural Language :: English Framework :: Django Framework :: Django :: 2.2 + Framework :: Django :: 3.0 Framework :: Django :: 3.2 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 [options] include_package_data = True diff --git a/tasks.py b/tasks.py index 02be157..80cec9f 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,19 +90,19 @@ 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") c.run("report -m") @@ -110,19 +110,19 @@ def coverage(c): @task def tag_release(c, level): - """ Tag release version. """ + """Tag release version.""" c.run("bumpversion --list %s --no-tag" % level) @task def tag_dev(c, level="patch"): - """ Tag development version. """ + """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. """ + """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 +130,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..e087e4f 100644 --- a/tests/base.py +++ b/tests/base.py @@ -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,19 +63,20 @@ 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) diff --git a/tests/test_models.py b/tests/test_models.py index 3f6f7bb..f525670 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -9,7 +9,6 @@ class RobotsTest(BaseTest): - def _test_robots_tag(self, template_string, context, expected): tpl_obj = template.Template(template_string) @@ -20,26 +19,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,29 +49,27 @@ 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") 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 = '' + 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) @@ -83,44 +78,38 @@ def test_robots_page_parameter(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_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") 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") 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") 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..d7ac5de 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,11 +47,12 @@ 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) @@ -62,13 +61,14 @@ 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 @@ -84,13 +84,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 +99,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 +119,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 +146,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..a094aa9 100644 --- a/tests/test_utils/urls.py +++ b/tests/test_utils/urls.py @@ -3,25 +3,24 @@ 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 django.views.static import serve 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} + ), + re_path(r"^", 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), + re_path(r"^", include("cms.urls")), ) diff --git a/tox.ini b/tox.ini index b58f0d7..c061eea 100644 --- a/tox.ini +++ b/tox.ini @@ -15,9 +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,<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 + cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip + -r{toxinidir}/requirements-test.txt passenv = COMMAND PYTEST_* @@ -44,7 +43,7 @@ skip_install = true [testenv:isort] commands = {envpython} -m isort -c --df djangocms_page_sitemap tests -deps = isort>5,<6 +deps = isort>5.10,<5.11 skip_install = true [testenv:isort_format] @@ -74,7 +73,7 @@ deps = sphinx-rtd-theme sphinx-autobuild livereload~=2.6 - -r requirements-test.txt + -rrequirements-test.txt skip_install = true [testenv:towncrier] From deefc8ce1d9f292478073caca6db32d09cc099c5 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 17:48:17 +0200 Subject: [PATCH 33/44] Update Python / Django / django CMS compatibility (#75) * Add support for Django 3.2 / django CMS 3.10 * Fix github actions matrix --- .github/workflows/lint.yml | 12 ++++++------ .github/workflows/publish.yml | 10 +++++----- .github/workflows/test.yml | 24 +++++++++++++----------- .pre-commit-config.yaml | 19 +++++++++++-------- .pyup.yml | 7 ------- README.rst | 9 ++++----- changes/74.bugfix | 1 + djangocms_page_sitemap/cms_toolbars.py | 2 +- djangocms_page_sitemap/models.py | 2 +- djangocms_page_sitemap/settings.py | 2 +- djangocms_page_sitemap/sitemap_urls.py | 4 ++-- setup.cfg | 12 ++++++++---- tasks.py | 22 +++++++++++----------- tests/base.py | 3 ++- tests/test_utils/urls.py | 13 +++++++------ tox.ini | 14 ++++++++------ 16 files changed, 81 insertions(+), 75 deletions(-) delete mode 100644 .pyup.yml create mode 100644 changes/74.bugfix diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d03bb3c..919d1c7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,26 +8,26 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]')" strategy: matrix: - python-version: [3.8] + python-version: [3.10.x] toxenv: [pep8, isort, black, pypi-description, docs, towncrier] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 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 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Cache pip - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.toxenv }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.toxenv }} - name: Cache tox - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .tox key: ${{ runner.os }}-lint-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }} @@ -35,7 +35,7 @@ jobs: ${{ runner.os }}-lint-${{ matrix.toxenv }}- - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools tox>=1.8 + python -m pip install --upgrade pip setuptools tox>=3.23 - name: Test with tox run: | tox -e${{ matrix.toxenv }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 07b9e64..c275874 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,20 +8,20 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Cache pip - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.toxenv }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.toxenv }} - name: Cache tox - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .tox key: ${{ runner.os }}-tox-release-${{ hashFiles('setup.cfg') }} @@ -29,7 +29,7 @@ jobs: ${{ runner.os }}-tox-release- - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools tox>=1.8 + python -m pip install --upgrade pip setuptools tox>=3.23 - name: Build and publish env: TWINE_USERNAME: __token__ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bac4618..9f7ebe8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,27 +8,29 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.7, 3.6] - django: [31, 30, 22] - cms: [38, 37] + python-version: [3.10.x, 3.9, 3.8, 3.7] + django: [32,22] + cms: [39,38,37] exclude: - - django: 31 + - django: 32 cms: 37 + - django: 32 + cms: 38 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Cache pip - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.toxenv }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.toxenv }} - name: Cache tox - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .tox key: ${{ runner.os }}-tox-${{ format('{{py{0}-django{1}-cms{2}}}', matrix.python-version, matrix.django, matrix.cms) }}-${{ hashFiles('setup.cfg') }} @@ -37,7 +39,7 @@ jobs: - name: Install dependencies run: | sudo apt-get install gettext - python -m pip install --upgrade pip tox>=3.5 + python -m pip install --upgrade pip setuptools tox>3.23 - name: Test with tox env: TOX_ENV: ${{ format('py-django{1}-cms{2}', matrix.python-version, matrix.django, matrix.cms) }} @@ -48,11 +50,11 @@ jobs: tox -e$TOX_ENV .tox/$TOX_ENV/bin/coverage xml .tox/$TOX_ENV/bin/coveralls - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} flags: unittests - file: ./coverage.xml + files: ./coverage.xml fail_ci_if_error: false services: redis: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30dc5aa..0826147 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: "(.idea|node_modules|.tox)" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.3.0 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -16,16 +16,16 @@ 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.10.1" hooks: - id: isort - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.6.0 hooks: - id: black - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + - repo: https://github.com/PyCQA/flake8 + rev: 3.9.2 hooks: - id: flake8 additional_dependencies: @@ -40,14 +40,14 @@ repos: - flake8-tidy-imports - pep8-naming - repo: https://github.com/econchick/interrogate - rev: 1.3.1 + rev: 1.5.0 hooks: - id: interrogate args: - "-cpyproject.toml" - "--quiet" - repo: https://github.com/asottile/pyupgrade - rev: v2.7.3 + rev: v2.37.3 hooks: - id: pyupgrade args: @@ -60,3 +60,6 @@ repos: language: system pass_filenames: false always_run: true +ci: + skip: + - towncrier diff --git a/.pyup.yml b/.pyup.yml deleted file mode 100644 index 2809577..0000000 --- a/.pyup.yml +++ /dev/null @@ -1,7 +0,0 @@ -update: all -pin: False -branch: -schedule: "every day" -search: True -branch_prefix: pyup/ -close_prs: True diff --git a/README.rst b/README.rst index edada5c..c260223 100644 --- a/README.rst +++ b/README.rst @@ -8,20 +8,19 @@ 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 diff --git a/changes/74.bugfix b/changes/74.bugfix new file mode 100644 index 0000000..2a8a5de --- /dev/null +++ b/changes/74.bugfix @@ -0,0 +1 @@ +Add support for Django 3.2 / django CMS 3.10 diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py index e69b64a..2e6fd8c 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -6,7 +6,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 diff --git a/djangocms_page_sitemap/models.py b/djangocms_page_sitemap/models.py index e835f7b..ea2fb99 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/djangocms_page_sitemap/settings.py b/djangocms_page_sitemap/settings.py index ab08b1e..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"), diff --git a/djangocms_page_sitemap/sitemap_urls.py b/djangocms_page_sitemap/sitemap_urls.py index 732b3df..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/setup.cfg b/setup.cfg index 84a0f85..cdd4e69 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,17 +43,21 @@ classifiers = Natural Language :: English Framework :: Django Framework :: Django :: 2.2 - Programming Language :: Python :: 3.6 + Framework :: Django :: 3.0 + Framework :: Django :: 3.2 Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 [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 @@ -63,7 +67,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/tasks.py b/tasks.py index 82261dd..753283c 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,19 +90,19 @@ 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") c.run("report -m") @@ -110,19 +110,19 @@ def coverage(c): @task def tag_release(c, level): - """ Tag release version. """ + """Tag release version.""" c.run("bumpversion --list %s --no-tag" % level) @task def tag_dev(c, level="patch"): - """ Tag development version. """ + """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. """ + """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 +130,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/base.py b/tests/base.py index 35e4c15..58f7a4d 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,8 +1,9 @@ +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 six import StringIO class BaseTest(TestCase): diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py index 4ceba77..7dcc2db 100644 --- a/tests/test_utils/urls.py +++ b/tests/test_utils/urls.py @@ -1,9 +1,10 @@ from cms.utils.conf import get_cms_setting from django.conf import settings -from django.conf.urls import include, url +from django.conf.urls import include 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 re_path from django.views.static import serve from djangocms_page_sitemap import sitemap_urls @@ -11,22 +12,22 @@ admin.autodiscover() urlpatterns = [ - url( + re_path( r"^media/(?P.*)$", serve, {"document_root": settings.MEDIA_ROOT, "show_indexes": True}, ), - url( + 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")), ) diff --git a/tox.ini b/tox.ini index ecd3e50..99c2541 100644 --- a/tox.ini +++ b/tox.ini @@ -8,18 +8,20 @@ envlist = pep8 pypi-description towncrier - py{38,37,36}-django{31}-cms{38} - py{38,37,36}-django{30}-cms{38,37} - py{38,37,36}-django{22}-cms{38,37} + py{310}-django{32}-cms{311,310} + py{39,38,37}-django{32}-cms{311,310,39} + py{39,38,37}-django{22}-cms{311,310,39,38,37} [testenv] commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posargs} deps = django22: Django>=2.2,<3.0 - django30: Django>=3.0,<3.1 - django31: Django>=3.1,<3.2 + django32: Django>=3.2,<4.0 cms37: https://github.com/divio/django-cms/archive/release/3.7.x.zip cms38: https://github.com/divio/django-cms/archive/release/3.8.x.zip + cms39: https://github.com/divio/django-cms/archive/release/3.9.x.zip + cms310: https://github.com/divio/django-cms/archive/release/3.10.x.zip + cms311: https://github.com/divio/django-cms/archive/release/3.11.x.zip -r{toxinidir}/requirements-test.txt passenv = COMMAND @@ -47,7 +49,7 @@ skip_install = true [testenv:isort] commands = {envpython} -m isort -c --df djangocms_page_sitemap tests -deps = isort>5,<6 +deps = isort>5.10,<5.11 skip_install = true [testenv:isort_format] From 0193739acfa2db8d751b950b616cb7ba3354395f Mon Sep 17 00:00:00 2001 From: Dennis Schwertel Date: Sat, 27 Aug 2022 17:54:22 +0200 Subject: [PATCH 34/44] bug/73-fix serialization issue (#72) * fix serialization issue * added newsfragment Co-authored-by: Iacopo Spalletti --- aldryn_config.py | 2 +- changes/73.bugfix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changes/73.bugfix diff --git a/aldryn_config.py b/aldryn_config.py index f0eeab7..195fca4 100644 --- a/aldryn_config.py +++ b/aldryn_config.py @@ -17,7 +17,7 @@ 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 diff --git a/changes/73.bugfix b/changes/73.bugfix new file mode 100644 index 0000000..b1d0ee5 --- /dev/null +++ b/changes/73.bugfix @@ -0,0 +1 @@ +Fixed serialization issue when trying to upload the addon to Divio Cloud. From 3ce5db8cda1dee152f22ee18025d00c2b305f458 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 18:29:03 +0200 Subject: [PATCH 35/44] Exclude whitespace checks on setup.cfg --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0826147..13d7e02 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,7 @@ repos: rev: v4.3.0 hooks: - id: trailing-whitespace + exclude: "setup.cfg" - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files From 120f3650c7ea9da181333ad9065ca5b640586f56 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 18:56:27 +0200 Subject: [PATCH 36/44] Fix error when populating the toolbar on page types (#76) * Fix error when populating the toolbar on page types * Add test --- changes/67.bugfix | 1 + djangocms_page_sitemap/cms_toolbars.py | 4 +++- tests/test_toolbar.py | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 changes/67.bugfix diff --git a/changes/67.bugfix b/changes/67.bugfix new file mode 100644 index 0000000..92577ea --- /dev/null +++ b/changes/67.bugfix @@ -0,0 +1 @@ +Fix error when populating the toolbar on page types diff --git a/djangocms_page_sitemap/cms_toolbars.py b/djangocms_page_sitemap/cms_toolbars.py index 2e6fd8c..01c8a13 100644 --- a/djangocms_page_sitemap/cms_toolbars.py +++ b/djangocms_page_sitemap/cms_toolbars.py @@ -19,7 +19,9 @@ def populate(self): # always use draft if we have a page self.page = get_page_draft(self.request.current_page) if not self.page: - # Nothing to do + return + if self.page.is_page_type: + # we don't need this on page types return # check global permissions if CMS_PERMISSIONS is active diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index e9131b4..8404c8a 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -38,6 +38,32 @@ def test_no_perm(self): 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_text(PAGE_SITEMAP_MENU_TITLE))), + 0, + ) + except AssertionError: + self.assertEqual( + len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), + 0, + ) + def test_perm(self): """ Test that page meta menu is present if user has Page.change_perm From defde22cb80f512e127d1733b2ade319d7f29e1c Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 19:10:21 +0200 Subject: [PATCH 37/44] Update invoke tasks --- tasks.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tasks.py b/tasks.py index 753283c..ce8eaf5 100644 --- a/tasks.py +++ b/tasks.py @@ -109,15 +109,19 @@ def coverage(c): @task -def tag_release(c, level): +def tag_release(c, level, new_version=""): """Tag release version.""" - c.run("bumpversion --list %s --no-tag" % level) + 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"): +def tag_dev(c, level="patch", new_version=""): """Tag development version.""" - c.run("bumpversion --list %s --message='Bump develop version [ci skip]' --no-tag" % level) + 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]) From f8cabcab08e88cf83d719b01a337b9cd42616679 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 19:13:56 +0200 Subject: [PATCH 38/44] Fix tests --- cms_helper.py | 1 + tox.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cms_helper.py b/cms_helper.py index 70b9bfb..e3a23d5 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -7,6 +7,7 @@ def gettext(s): HELPER_SETTINGS = { "SECRET_KEY": "djangocms-page-sitemap-test-suite-key", + "CMS_CONFIRM_VERSION4": True, "CACHES": { "default": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", diff --git a/tox.ini b/tox.ini index c061eea..caa971a 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ commands = {env:COMMAND:python} cms_helper.py djangocms_page_sitemap test {posar deps = django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 - cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip + cms40: https://github.com/django-cms/django-cms/archive/refs/heads/develop-4.zip -r{toxinidir}/requirements-test.txt passenv = COMMAND From d2a49629e1c1078e91f2eef1708c45d70468fc8f Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 19:20:08 +0200 Subject: [PATCH 39/44] Replace force_text with force_str --- tests/test_toolbar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index 33ec54e..5e34171 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -73,12 +73,12 @@ def test_page_types(self): page_menu = toolbar.menus["page"] try: self.assertEqual( - len(page_menu.find_items(ModalItem, name="%s..." % force_text(PAGE_SITEMAP_MENU_TITLE))), + 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_text(PAGE_SITEMAP_MENU_TITLE))), + len(page_menu.find_items(ModalItem, name="%s ..." % force_str(PAGE_SITEMAP_MENU_TITLE))), 0, ) From fa5425f18ebf74d6f27568f890bd0c4055b0eb99 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 19:41:34 +0200 Subject: [PATCH 40/44] Update authors --- AUTHORS.rst | 3 ++- djangocms_page_sitemap/__init__.py | 2 +- djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po | 2 +- djangocms_page_sitemap/locale/es/LC_MESSAGES/django.po | 2 +- djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po | 4 ++-- djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.po | 2 +- djangocms_page_sitemap/locale/tr/LC_MESSAGES/django.po | 2 +- setup.cfg | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index c1486a3..dcb7ec3 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -5,13 +5,14 @@ Credits Development Lead ---------------- -* Iacopo Spalletti +* Iacopo Spalletti Contributors ------------ * Anton Egorov * carderm +* Dennis Schwertel * Fabrice Pardo * fp4code * Jeroen Peters diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 353c46f..fb3aae2 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,2 +1,2 @@ __version__ = "1.0.0" -__author__ = "Iacopo Spalletti " +__author__ = "Iacopo Spalletti " diff --git a/djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po index 0111082..64a60b0 100644 --- a/djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/en/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2019-08-11 22:56+0200\n" "PO-Revision-Date: 2018-02-07 20:51+0000\n" -"Last-Translator: yakky \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.po b/djangocms_page_sitemap/locale/es/LC_MESSAGES/django.po index 5357db0..84014e4 100644 --- a/djangocms_page_sitemap/locale/es/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/es/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-10-18 15:49+0200\n" "PO-Revision-Date: 2015-10-18 13:49+0000\n" -"Last-Translator: yakky \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.po b/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po index 2b68f21..f694a08 100644 --- a/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/it/LC_MESSAGES/django.po @@ -3,14 +3,14 @@ # 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/pt_BR/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.po index 13f356f..08e7de7 100644 --- a/djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/pt_BR/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-10-18 15:49+0200\n" "PO-Revision-Date: 2015-10-18 13:49+0000\n" -"Last-Translator: yakky \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/tr/LC_MESSAGES/django.po b/djangocms_page_sitemap/locale/tr/LC_MESSAGES/django.po index a4a1eda..404bca8 100644 --- a/djangocms_page_sitemap/locale/tr/LC_MESSAGES/django.po +++ b/djangocms_page_sitemap/locale/tr/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-10-18 15:49+0200\n" "PO-Revision-Date: 2015-10-18 13:49+0000\n" -"Last-Translator: yakky \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/setup.cfg b/setup.cfg index cdd4e69..2ac27c8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,7 @@ 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 +author_email = i.spalletti@nephila.digital description = django CMS page extension to handle sitemap customization long_description = file: README.rst, HISTORY.rst long_description_content_type = text/x-rst From 766dc6ee956e4ea282bae83e3285ed9d79dfda9e Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 19:42:00 +0200 Subject: [PATCH 41/44] Release 1.1.0 --- HISTORY.rst | 11 +++++ changes/67.bugfix | 1 - changes/73.bugfix | 1 - changes/74.bugfix | 1 - djangocms_page_sitemap/__init__.py | 2 +- setup.cfg | 64 +++++++++++++++--------------- 6 files changed, 44 insertions(+), 36 deletions(-) delete mode 100644 changes/67.bugfix delete mode 100644 changes/73.bugfix delete mode 100644 changes/74.bugfix diff --git a/HISTORY.rst b/HISTORY.rst index 4e0f054..abe535c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,6 +6,17 @@ History .. towncrier release notes start +1.1.0 (2022-08-27) +================== + +Bugfixes +-------- + +- Fix error when populating the toolbar on page types (#67) +- Fixed serialization issue when trying to upload the addon to Divio Cloud. (#73) +- Add support for Django 3.2 / django CMS 3.10 (#74) + + 1.0.0 (2020-12-21) ================== diff --git a/changes/67.bugfix b/changes/67.bugfix deleted file mode 100644 index 92577ea..0000000 --- a/changes/67.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix error when populating the toolbar on page types diff --git a/changes/73.bugfix b/changes/73.bugfix deleted file mode 100644 index b1d0ee5..0000000 --- a/changes/73.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fixed serialization issue when trying to upload the addon to Divio Cloud. diff --git a/changes/74.bugfix b/changes/74.bugfix deleted file mode 100644 index 2a8a5de..0000000 --- a/changes/74.bugfix +++ /dev/null @@ -1 +0,0 @@ -Add support for Django 3.2 / django CMS 3.10 diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index fb3aae2..1317582 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,2 +1,2 @@ -__version__ = "1.0.0" +__version__ = "1.1.0" __author__ = "Iacopo Spalletti " diff --git a/setup.cfg b/setup.cfg index 2ac27c8..27e4bfb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,9 @@ [bumpversion] -current_version = 1.0.0 +current_version = 1.1.0 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) -serialize = - {major}.{minor}.{patch}.{release}{relver} - {major}.{minor}.{patch} +serialize = + {major}.{minor}.{patch}.{release}{relver} + {major}.{minor}.{patch} commit = True tag = True sign_tags = True @@ -12,12 +12,12 @@ message = Release {new_version} [bumpversion:part:release] optional_value = gamma -values = - dev - a - b - rc - gamma +values = + dev + a + b + rc + gamma [bumpversion:file:djangocms_page_sitemap/__init__.py] @@ -25,8 +25,8 @@ values = 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/ +project_urls = + Documentation = https://djangocms-page-sitemap.readthedocs.io/ author = Iacopo Spalletti author_email = i.spalletti@nephila.digital description = django CMS page extension to handle sitemap customization @@ -35,27 +35,27 @@ 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 - Framework :: Django :: 3.0 - Framework :: Django :: 3.2 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 +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 + Framework :: Django :: 3.0 + Framework :: Django :: 3.2 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 [options] include_package_data = True -install_requires = - django-cms>=3.7 -setup_requires = - setuptools +install_requires = + django-cms>=3.7 +setup_requires = + setuptools packages = djangocms_page_sitemap python_requires = >=3.7 zip_safe = False @@ -66,8 +66,8 @@ test_suite = cms_helper.run djangcms_page_sitemap = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po [options.extras_require] -docs = - django<4.0 +docs = + django<4.0 [upload] repository = https://upload.pypi.org/legacy/ From 6c7d744f4759c193618d0d8737e6d6be59dfa3c0 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 19:46:46 +0200 Subject: [PATCH 42/44] Bump develop version [ci skip] --- djangocms_page_sitemap/__init__.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 1317582..1a9f52c 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,2 +1,2 @@ -__version__ = "1.1.0" +__version__ = "1.1.1.dev0" __author__ = "Iacopo Spalletti " diff --git a/setup.cfg b/setup.cfg index 27e4bfb..c6e406c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.1.0 +current_version = 1.1.1.dev0 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) serialize = {major}.{minor}.{patch}.{release}{relver} From 10c4d66c4ae0631b8a7849d5db78858b635c51c1 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 19:51:42 +0200 Subject: [PATCH 43/44] Bump develop version 2.0.0.dev1 --- HISTORY.rst | 9 +++++++++ djangocms_page_sitemap/__init__.py | 2 +- setup.cfg | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 9d5bb38..b86ed80 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,6 +6,15 @@ History .. towncrier release notes start + +2.0.0.dev1 (2020-12-21) +======================== + +Features +-------- + +* Port to django CMS 4.0 + 1.0.0 (2020-12-21) ================== diff --git a/djangocms_page_sitemap/__init__.py b/djangocms_page_sitemap/__init__.py index 353c46f..b59dabe 100644 --- a/djangocms_page_sitemap/__init__.py +++ b/djangocms_page_sitemap/__init__.py @@ -1,2 +1,2 @@ -__version__ = "1.0.0" +__version__ = "2.0.0.dev1" __author__ = "Iacopo Spalletti " diff --git a/setup.cfg b/setup.cfg index cdd4e69..f737be0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.0 +current_version = 2.0.0.dev1 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.?)(?P[a-z]*)(?P\d*) serialize = {major}.{minor}.{patch}.{release}{relver} From 7c3c42c31ffcc4eedc18516a1506d940744f70c2 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 27 Aug 2022 19:54:47 +0200 Subject: [PATCH 44/44] Port fix for issue #73 --- aldryn_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aldryn_config.py b/aldryn_config.py index f0eeab7..195fca4 100644 --- a/aldryn_config.py +++ b/aldryn_config.py @@ -17,7 +17,7 @@ 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