diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..1229820 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,44 @@ +name: CodeCov + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + coverage: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: [ 3.7, 3.8, 3.9, "3.10",] # latest release minus two + requirements-file: [ + dj22_cms38.txt, + dj32_cms38.txt, + dj32_cms39.txt, + dj32_cms310.txt, + dj32_cms311.txt, + dj40_cms311.txt, + ] + os: [ + ubuntu-20.04, + ] + exclude: + - python-version: 3.7 + requirements-file: dj40_cms311.txt + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '2' + + - name: Setup Python + uses: actions/setup-python@master + with: + python-version: ${{ matrix.python-version }} + - name: Generate Report + run: | + pip install -r tests/requirements/${{ matrix.requirements-file }} + coverage run setup.py test + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v1 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..3398842 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,74 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '34 0 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml new file mode 100644 index 0000000..fc5d65d --- /dev/null +++ b/.github/workflows/lint-pr.yml @@ -0,0 +1,20 @@ +name: "Lint PR" + +# Validates PR titles against the conventional commit spec +# https://github.com/commitizen/conventional-commit-types + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0076679 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,43 @@ +name: Lint + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + flake8: + name: flake8 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.9 + - name: Install flate8 + run: pip install --upgrade flake8 + - name: Run flake8 + uses: liskin/gh-problem-matcher-wrap@v1 + with: + linters: flake8 + run: flake8 + + isort: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.9 + - run: python -m pip install isort + - name: isort + uses: liskin/gh-problem-matcher-wrap@v1 + with: + linters: isort + run: isort -c --df djangocms_file + diff --git a/.github/workflows/publish-to-live-pypi.yml b/.github/workflows/publish-to-live-pypi.yml new file mode 100644 index 0000000..52f112f --- /dev/null +++ b/.github/workflows/publish-to-live-pypi.yml @@ -0,0 +1,39 @@ +name: Publish Python 🐍 distributions 📦 to pypi + +on: + release: + types: + - published + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to pypi + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: '3.10' + + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml new file mode 100644 index 0000000..b38a5ca --- /dev/null +++ b/.github/workflows/publish-to-test-pypi.yml @@ -0,0 +1,40 @@ +name: Publish Python 🐍 distributions 📦 to TestPyPI + +on: + push: + branches: + - master + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to TestPyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: '3.10' + + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0fce6c0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -language: python - -dist: xenial - -matrix: - include: - - python: 3.5 - env: TOX_ENV='flake8' - - python: 3.5 - env: TOX_ENV='isort' - # Django 2.2 - - python: 3.5 - env: DJANGO='dj22' CMS='cms37' - - python: 3.6 - env: DJANGO='dj22' CMS='cms37' - - python: 3.7 - env: DJANGO='dj22' CMS='cms37' - - python: 3.8 - env: DJANGO='dj22' CMS='cms37' - # Django 3.0, always run the lowest supported version - - python: 3.6 - env: DJANGO='dj30' CMS='cms37' - # Django 3.1, always run the lowest supported version - - python: 3.6 - env: DJANGO='dj31' CMS='cms38' - allow_failures: - - python: 3.6 - env: DJANGO='dj31' CMS='cms38' - -install: - - pip install coverage isort tox - - "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PY_VER=py35; fi" - - "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export PY_VER=py36; fi" - - "if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then export PY_VER=py37; fi" - - "if [[ $TRAVIS_PYTHON_VERSION == '3.8' ]]; then export PY_VER=py38; fi" - - "if [[ ${DJANGO}z != 'z' ]]; then export TOX_ENV=$PY_VER-$DJANGO-$CMS; fi" - -script: - - tox -e $TOX_ENV - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bfe3dc1..75a411e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,8 @@ Changelog ========= +* Added support for Django 3.2, Django 4.0 +* Added github actions 3.0.0 (2020-09-02) ================== diff --git a/README.rst b/README.rst index 08c2f87..972fdff 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ django CMS File =============== -|pypi| |build| |coverage| +|pypi| |build| |coverage| |python| |django| |djangocms| **django CMS File** is a set of plugins for `django CMS `_ that allow you to add files to your site You can either choose a single file or @@ -10,8 +10,7 @@ an entire folder. It uses files managed by `Django Filer `_. -This addon is compatible with `Divio Cloud `_ and is also available on the -`django CMS Marketplace `_ +This addon is compatible with `Divio Cloud `_ for easy installation. .. image:: preview.gif @@ -39,8 +38,6 @@ Documentation See ``REQUIREMENTS`` in the `setup.py `_ file for additional dependencies: -|python| |django| |djangocms| - * Django Filer 1.7 or higher Make sure `django-filer `_ @@ -71,7 +68,7 @@ setting:: ('feature', _('Featured Version')), ] -You'll need to create the `feature` folder inside ``templates/djangocms_file/`` +You'll need to create the ``feature`` folder inside ``templates/djangocms_file/`` otherwise you will get a *template does not exist* error. You can do this by copying the ``default`` folder inside that directory and renaming it to ``feature``. @@ -90,14 +87,14 @@ You can run tests by executing:: .. |pypi| image:: https://badge.fury.io/py/djangocms-file.svg :target: http://badge.fury.io/py/djangocms-file -.. |build| image:: https://travis-ci.org/divio/djangocms-file.svg?branch=master +.. |build| image:: https://travis-ci.org/django-cms/djangocms-file.svg?branch=master :target: https://travis-ci.org/divio/djangocms-file -.. |coverage| image:: https://codecov.io/gh/divio/djangocms-file/branch/master/graph/badge.svg +.. |coverage| image:: https://codecov.io/gh/django-cms/djangocms-file/branch/master/graph/badge.svg :target: https://codecov.io/gh/divio/djangocms-file .. |python| image:: https://img.shields.io/badge/python-3.5+-blue.svg :target: https://pypi.org/project/djangocms-file/ -.. |django| image:: https://img.shields.io/badge/django-2.2,%203.0,%203.1-blue.svg +.. |django| image:: https://img.shields.io/badge/django-2.2--4.0-blue.svg :target: https://www.djangoproject.com/ .. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.7%2B-blue.svg :target: https://www.django-cms.org/ diff --git a/djangocms_file/migrations/0012_alter_file_cmsplugin_ptr_alter_folder_cmsplugin_ptr.py b/djangocms_file/migrations/0012_alter_file_cmsplugin_ptr_alter_folder_cmsplugin_ptr.py new file mode 100644 index 0000000..f7f829f --- /dev/null +++ b/djangocms_file/migrations/0012_alter_file_cmsplugin_ptr_alter_folder_cmsplugin_ptr.py @@ -0,0 +1,25 @@ +# Generated by Django 4.0.8 on 2022-10-13 19:36 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cms', '0022_auto_20180620_1551'), + ('djangocms_file', '0011_auto_20181211_0357'), + ] + + operations = [ + migrations.AlterField( + model_name='file', + name='cmsplugin_ptr', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='%(app_label)s_%(class)s', serialize=False, to='cms.cmsplugin'), + ), + migrations.AlterField( + model_name='folder', + name='cmsplugin_ptr', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='%(app_label)s_%(class)s', serialize=False, to='cms.cmsplugin'), + ), + ] diff --git a/djangocms_file/templates/djangocms_file/default/file.html b/djangocms_file/templates/djangocms_file/default/file.html index bab815d..6820946 100644 --- a/djangocms_file/templates/djangocms_file/default/file.html +++ b/djangocms_file/templates/djangocms_file/default/file.html @@ -1,7 +1,7 @@ + {{ instance.attributes_str }}> {% if instance.file_name %} {{ instance.file_name }} {% else %} @@ -17,10 +17,10 @@ {{ instance.file_src }} {{ instance.file_src.extension }} # Available variables: - {{ instance.template }} + {{ instance.template }} {{ instance.file_name }} {{ instance.link_target }} {{ instance.link_title }} {{ instance.show_file_size }} - {{ instance.attributes_str }} + {{ instance.attributes_str }} {% endcomment %} diff --git a/djangocms_file/templates/djangocms_file/default/folder.html b/djangocms_file/templates/djangocms_file/default/folder.html index 1aaf90d..aae4959 100644 --- a/djangocms_file/templates/djangocms_file/default/folder.html +++ b/djangocms_file/templates/djangocms_file/default/folder.html @@ -3,7 +3,7 @@ {% for file in folder_files %} + {{ instance.attributes_str }}> {{ file }} {% if instance.show_file_size %} {{ file.size|filesizeformat }} @@ -19,8 +19,8 @@ {{ instance.folder_src }} {{ instance.get_files }} or {{ folder_files }} # Available variables: - {{ instance.template }} + {{ instance.template }} {{ instance.link_target }} {{ instance.show_file_size }} - {{ instance.attributes_str }} + {{ instance.attributes_str }} {% endcomment %} diff --git a/setup.py b/setup.py index 3b825da..3c5614e 100644 --- a/setup.py +++ b/setup.py @@ -23,13 +23,20 @@ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Framework :: Django', 'Framework :: Django :: 2.2', 'Framework :: Django :: 3.0', 'Framework :: Django :: 3.1', + 'Framework :: Django :: 3.2', + 'Framework :: Django :: 4.0', 'Framework :: Django CMS', 'Framework :: Django CMS :: 3.7', 'Framework :: Django CMS :: 3.8', + 'Framework :: Django CMS :: 3.9', + 'Framework :: Django CMS :: 3.10', + 'Framework :: Django CMS :: 3.11', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Software Development', @@ -48,6 +55,7 @@ license='BSD-3-Clause', description='Adds file plugin to django CMS', long_description=open('README.rst').read(), + long_description_content_type='text/x-rst', packages=find_packages(), include_package_data=True, zip_safe=False, diff --git a/tests/requirements.txt b/tests/requirements/base.txt similarity index 88% rename from tests/requirements.txt rename to tests/requirements/base.txt index 77fedde..0bf3eb7 100644 --- a/tests/requirements.txt +++ b/tests/requirements/base.txt @@ -3,3 +3,4 @@ tox coverage isort flake8 +wheel diff --git a/tests/requirements/dj22_cms38.txt b/tests/requirements/dj22_cms38.txt new file mode 100644 index 0000000..b8cbc6a --- /dev/null +++ b/tests/requirements/dj22_cms38.txt @@ -0,0 +1,4 @@ +-r base.txt + +Django>=2.2,<2.3 +django-cms>=3.8,<3.9 diff --git a/tests/requirements/dj32_cms310.txt b/tests/requirements/dj32_cms310.txt new file mode 100644 index 0000000..4b2996f --- /dev/null +++ b/tests/requirements/dj32_cms310.txt @@ -0,0 +1,4 @@ +-r base.txt + +Django>=3.2,<3.3 +django-cms>=3.10,<3.11 diff --git a/tests/requirements/dj32_cms311.txt b/tests/requirements/dj32_cms311.txt new file mode 100644 index 0000000..f54dae0 --- /dev/null +++ b/tests/requirements/dj32_cms311.txt @@ -0,0 +1,4 @@ +-r base.txt + +Django>=3.2,<3.3 +django-cms>=3.11,<3.12 diff --git a/tests/requirements/dj32_cms38.txt b/tests/requirements/dj32_cms38.txt new file mode 100644 index 0000000..4c2ed20 --- /dev/null +++ b/tests/requirements/dj32_cms38.txt @@ -0,0 +1,4 @@ +-r base.txt + +Django>=3.2,<3.3 +django-cms>=3.8,<3.9 diff --git a/tests/requirements/dj32_cms39.txt b/tests/requirements/dj32_cms39.txt new file mode 100644 index 0000000..41f9321 --- /dev/null +++ b/tests/requirements/dj32_cms39.txt @@ -0,0 +1,4 @@ +-r base.txt + +Django>=3.2,<3.3 +django-cms>=3.9,<4.0 diff --git a/tests/requirements/dj40_cms311.txt b/tests/requirements/dj40_cms311.txt new file mode 100644 index 0000000..d13ece8 --- /dev/null +++ b/tests/requirements/dj40_cms311.txt @@ -0,0 +1,5 @@ +-r base.txt + +django-filer>=2.2 +Django>=4.0,<4.1 +django-cms>=3.11 diff --git a/tests/requirements/dj41_cms311.txt b/tests/requirements/dj41_cms311.txt new file mode 100644 index 0000000..052c7ba --- /dev/null +++ b/tests/requirements/dj41_cms311.txt @@ -0,0 +1,5 @@ +-r base.txt + +django-filer>=2.2 +Django>=4.1,<4.2 +django-cms>=3.11 diff --git a/tests/test_migrations.py b/tests/test_migrations.py index 29c4a94..1f8ec7c 100644 --- a/tests/test_migrations.py +++ b/tests/test_migrations.py @@ -19,7 +19,7 @@ def test_for_missing_migrations(self): } try: - call_command('makemigrations', **options) + call_command('makemigrations', 'djangocms_file', **options) except SystemExit as e: status_code = str(e) else: diff --git a/tox.ini b/tox.ini index 45afd03..5aa44fb 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,9 @@ envlist = isort py{35,36,37,38}-dj{22}-cms{37,38} py{36,37,38}-dj{30}-cms{37,38} - py{36,37,38}-dj{31}-cms{38} + py{36,37,38}-dj{31}-cms{38,39} + py{37,38,39,310,311}-dj{32}-cms{310,311} + py{37,38,39,310,311}-dj{32,40}-cms{311} skip_missing_interpreters=True @@ -22,29 +24,35 @@ exclude = docs, *migrations*, requirements, - tmp + tmp, + *.venv*, + *site-packages* [isort] line_length = 79 skip = manage.py, *migrations*, .tox, .eggs, data include_trailing_comma = true multi_line_output = 5 -not_skip = __init__.py lines_after_imports = 2 default_section = THIRDPARTY -sections = FUTURE, STDLIB, DJANGO, CMS, THIRDPARTY, FIRSTPARTY, LIB, LOCALFOLDER +sections = FUTURE, STDLIB, DJANGO, CMS, THIRDPARTY, FIRSTPARTY, LOCALFOLDER known_first_party = djangocms_file known_cms = cms, menus known_django = django [testenv] deps = - -r{toxinidir}/tests/requirements.txt + -r{toxinidir}/tests/requirements/base.txt dj22: Django>=2.2,<3.0 dj30: Django>=3.0,<3.1 dj31: Django>=3.1,<3.2 + dj32: Django>=3.2,<3.3 + dj40: Django>=4.0,<4.1 cms37: django-cms>=3.7,<3.8 cms38: django-cms>=3.8,<3.9 + cms39: django-cms>=3.9,<3.10 + cms310: django-cms>=3.10,<3.11 + cms311: django-cms>=3.11,<3.12 commands = {envpython} --version {env:COMMAND:coverage} erase @@ -57,5 +65,5 @@ commands = flake8 [testenv:isort] deps = isort -commands = isort -c -rc -df djangocms_file +commands = isort -c --df djangocms_file skip_install = true