From 8761fe12d0a541b90df0a76644488f5905a0508e Mon Sep 17 00:00:00 2001 From: Aiky30 Date: Tue, 2 Oct 2018 17:28:58 +0100 Subject: [PATCH 01/10] Implemented unlock icons and revised the disabled logic slightly --- .../monkeypatch/admin.py | 27 +++++++++---------- .../djangocms_version_locking/svg/lock.svg | 1 + .../djangocms_version_locking/svg/unlock.svg | 1 + .../admin/locked_icon.html | 4 ++- .../admin/unlock_disabled_icon.html | 2 -- .../admin/unlock_icon.html | 8 ++++-- 6 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 djangocms_version_locking/static/djangocms_version_locking/svg/lock.svg create mode 100644 djangocms_version_locking/static/djangocms_version_locking/svg/unlock.svg delete mode 100644 djangocms_version_locking/templates/djangocms_version_locking/admin/unlock_disabled_icon.html diff --git a/djangocms_version_locking/monkeypatch/admin.py b/djangocms_version_locking/monkeypatch/admin.py index 09062fa..e98b2b9 100644 --- a/djangocms_version_locking/monkeypatch/admin.py +++ b/djangocms_version_locking/monkeypatch/admin.py @@ -11,6 +11,7 @@ from cms.utils.urlutils import admin_reverse from djangocms_versioning import admin, models, constants +from djangocms_versioning.helpers import version_list_url from djangocms_version_locking.helpers import ( create_version_lock, @@ -89,11 +90,7 @@ def _unlock_view(self, request, object_id): messages.success(request, _("Version unlocked")) # Redirect - url = admin_reverse('{app}_{model}_changelist'.format( - app=self.model._meta.app_label, - model=self.model._meta.model_name, - )) + '?grouper=' + str(version.grouper.pk) - + url = version_list_url(version.content) return redirect(url) admin.VersionAdmin._unlock_view = _unlock_view @@ -103,23 +100,25 @@ def _get_unlock_link(self, obj, request): Generate an unlock link for the Versioning Admin """ # If the version is not draft no action should be present - if obj.state != constants.DRAFT: + if obj.state != constants.DRAFT or not version_is_locked(obj): return "" + disabled = True # Check whether the lock can be removed # Check that the user has unlock permission if version_is_locked(obj) and request.user.has_perm('djangocms_version_locking.delete_versionlock'): - unlock_url = reverse('admin:{app}_{model}_unlock'.format( - app=obj._meta.app_label, model=self.model._meta.model_name, - ), args=(obj.pk,)) + disabled = False - return render_to_string( - 'djangocms_version_locking/admin/unlock_icon.html', - {'unlock_url': unlock_url} - ) + unlock_url = reverse('admin:{app}_{model}_unlock'.format( + app=obj._meta.app_label, model=self.model._meta.model_name, + ), args=(obj.pk,)) return render_to_string( - 'djangocms_version_locking/admin/unlock_disabled_icon.html', + 'djangocms_version_locking/admin/unlock_icon.html', + { + 'unlock_url': unlock_url, + 'disabled': disabled + } ) admin.VersionAdmin._get_unlock_link = _get_unlock_link diff --git a/djangocms_version_locking/static/djangocms_version_locking/svg/lock.svg b/djangocms_version_locking/static/djangocms_version_locking/svg/lock.svg new file mode 100644 index 0000000..3b640ec --- /dev/null +++ b/djangocms_version_locking/static/djangocms_version_locking/svg/lock.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/djangocms_version_locking/static/djangocms_version_locking/svg/unlock.svg b/djangocms_version_locking/static/djangocms_version_locking/svg/unlock.svg new file mode 100644 index 0000000..fe0cd91 --- /dev/null +++ b/djangocms_version_locking/static/djangocms_version_locking/svg/unlock.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/djangocms_version_locking/templates/djangocms_version_locking/admin/locked_icon.html b/djangocms_version_locking/templates/djangocms_version_locking/admin/locked_icon.html index 625be0c..b374300 100644 --- a/djangocms_version_locking/templates/djangocms_version_locking/admin/locked_icon.html +++ b/djangocms_version_locking/templates/djangocms_version_locking/admin/locked_icon.html @@ -1,2 +1,4 @@ {% load static i18n %} -{% trans "Yes" %} + + + diff --git a/djangocms_version_locking/templates/djangocms_version_locking/admin/unlock_disabled_icon.html b/djangocms_version_locking/templates/djangocms_version_locking/admin/unlock_disabled_icon.html deleted file mode 100644 index 2306620..0000000 --- a/djangocms_version_locking/templates/djangocms_version_locking/admin/unlock_disabled_icon.html +++ /dev/null @@ -1,2 +0,0 @@ -{% load static i18n %} -{% trans "Unlock" %} diff --git a/djangocms_version_locking/templates/djangocms_version_locking/admin/unlock_icon.html b/djangocms_version_locking/templates/djangocms_version_locking/admin/unlock_icon.html index 1f6959c..cb7a269 100644 --- a/djangocms_version_locking/templates/djangocms_version_locking/admin/unlock_icon.html +++ b/djangocms_version_locking/templates/djangocms_version_locking/admin/unlock_icon.html @@ -1,5 +1,9 @@ {% load static i18n %} + +{% if disabled %} + +{% else %} - {% trans "Unlock" %} +{% endif %} + - From fc8a24b4a284c6a793097be88abd2d1ff562dc5b Mon Sep 17 00:00:00 2001 From: Aiky30 Date: Thu, 4 Oct 2018 15:30:08 +0100 Subject: [PATCH 02/10] Add django 2.2 support to fix security vunerability --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9c6629c..98d2133 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ INSTALL_REQUIREMENTS = [ - 'Django>=1.11,<2.1', + 'Django>=1.11,<2.2', 'django-cms>=3.5', ] From ba8e5679162c145eddf1d71556cda8ef4e8f7694 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Fri, 1 Nov 2019 11:55:54 +0000 Subject: [PATCH 03/10] Circle CI config taken from Versioning --- .circleci/Dockerfile | 7 +++ .circleci/config.yml | 146 +++++++++++++++++++++++++++++++++++++++++++ tox.ini | 37 +++++++++++ 3 files changed, 190 insertions(+) create mode 100644 .circleci/Dockerfile create mode 100644 .circleci/config.yml create mode 100644 tox.ini diff --git a/.circleci/Dockerfile b/.circleci/Dockerfile new file mode 100644 index 0000000..421f6bb --- /dev/null +++ b/.circleci/Dockerfile @@ -0,0 +1,7 @@ +ARG PYTHON_VERSION=3.6 +FROM circleci/python:$PYTHON_VERSION + +WORKDIR /home/circleci/app/ +COPY . /home/circleci/app/ +RUN sudo chown -R circleci:circleci . +RUN sudo pip install tox diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..ba5db00 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,146 @@ +version: 2.0 + +py34default: &py34default + docker: + - image: circleci/python:3.4 + steps: + - setup_remote_docker: + docker_layer_caching: true + - checkout + - attach_workspace: + at: /tmp/images + - run: docker load -i /tmp/images/py34.tar || true + - run: docker run py34 tox -e $CIRCLE_STAGE + +py35default: &py35default + docker: + - image: circleci/python:3.5 + steps: + - setup_remote_docker: + docker_layer_caching: true + - checkout + - attach_workspace: + at: /tmp/images + - run: docker load -i /tmp/images/py35.tar || true + - run: docker run py35 tox -e $CIRCLE_STAGE + +py36default: &py36default + docker: + - image: circleci/python:3.6 + steps: + - setup_remote_docker: + docker_layer_caching: true + - checkout + - attach_workspace: + at: /tmp/images + - run: docker load -i /tmp/images/py36.tar || true + - run: docker run py36 tox -e $CIRCLE_STAGE + +py34_requires: &py34_requires + requires: + - py34_base + +py35_requires: &py35_requires + requires: + - py35_base + +py36_requires: &py36_requires + requires: + - py36_base + +jobs: + py34_base: + docker: + - image: circleci/python:3.4 + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: docker build -f .circleci/Dockerfile --build-arg PYTHON_VERSION=3.4 -t py34 . + - run: mkdir images + - run: docker save -o images/py34.tar py34 + - persist_to_workspace: + root: images + paths: py34.tar + py35_base: + docker: + - image: circleci/python:3.5 + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: docker build -f .circleci/Dockerfile --build-arg PYTHON_VERSION=3.5 -t py35 . + - run: mkdir images + - run: docker save -o images/py35.tar py35 + - persist_to_workspace: + root: images + paths: py35.tar + py36_base: + docker: + - image: circleci/python:3.6 + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: docker build -f .circleci/Dockerfile --build-arg PYTHON_VERSION=3.6 -t py36 . + - run: mkdir images + - run: docker save -o images/py36.tar py36 + - persist_to_workspace: + root: images + paths: py36.tar + + flake8: + <<: *py35default + isort: + <<: *py35default + py34-dj111-sqlite-cms40: + <<: *py34default + py35-dj111-sqlite-cms40: + <<: *py35default + py36-dj111-sqlite-cms40: + <<: *py36default + py35-dj20-sqlite-cms40: + <<: *py35default + py36-dj20-sqlite-cms40: + <<: *py36default + py35-dj21-sqlite-cms40: + <<: *py35default + py36-dj21-sqlite-cms40: + <<: *py36default + +####################### + +workflows: + version: 2 + build: + jobs: + - py34_base + - py35_base + - py36_base + - flake8: + requires: + - py35_base + - isort: + requires: + - py35_base + - py34-dj111-sqlite-cms40: + requires: + - py34_base + - py35-dj111-sqlite-cms40: + requires: + - py35_base + - py36-dj111-sqlite-cms40: + requires: + - py36_base + - py35-dj20-sqlite-cms40: + requires: + - py35_base + - py36-dj20-sqlite-cms40: + requires: + - py36_base + - py35-dj21-sqlite-cms40: + requires: + - py35_base + - py36-dj21-sqlite-cms40: + requires: + - py36_base diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..43fda09 --- /dev/null +++ b/tox.ini @@ -0,0 +1,37 @@ +[tox] +envlist = + flake8 + isort + py{34,35,36}-dj{111,20}-sqlite-cms40 + py{35,36}-dj21-sqlite-cms40 + +skip_missing_interpreters=True + +[testenv] +deps = + -r{toxinidir}/tests/requirements.txt + + dj111: Django>=1.11,<2.0 + dj20: Django>=2.0,<2.1 + dj21: Django>=2.1,<2.2 + + cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip + +basepython = + py34: python3.4 + py35: python3.5 + py36: python3.6 + +commands = + {envpython} --version + {env:COMMAND:coverage} erase + {env:COMMAND:coverage} run setup.py test + {env:COMMAND:coverage} report + +[testenv:flake8] +commands = flake8 +basepython = python3.5 + +[testenv:isort] +commands = isort --recursive --check-only --diff {toxinidir} +basepython = python3.5 From 5b900daaa2d4420107060cc397ea4e5b9219544e Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Fri, 1 Nov 2019 12:06:07 +0000 Subject: [PATCH 04/10] Disabled docker layer caching --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ba5db00..4903471 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ py35default: &py35default - image: circleci/python:3.5 steps: - setup_remote_docker: - docker_layer_caching: true + docker_layer_caching: false - checkout - attach_workspace: at: /tmp/images @@ -29,7 +29,7 @@ py36default: &py36default - image: circleci/python:3.6 steps: - setup_remote_docker: - docker_layer_caching: true + docker_layer_caching: false - checkout - attach_workspace: at: /tmp/images @@ -55,7 +55,7 @@ jobs: steps: - checkout - setup_remote_docker: - docker_layer_caching: true + docker_layer_caching: false - run: docker build -f .circleci/Dockerfile --build-arg PYTHON_VERSION=3.4 -t py34 . - run: mkdir images - run: docker save -o images/py34.tar py34 @@ -68,7 +68,7 @@ jobs: steps: - checkout - setup_remote_docker: - docker_layer_caching: true + docker_layer_caching: false - run: docker build -f .circleci/Dockerfile --build-arg PYTHON_VERSION=3.5 -t py35 . - run: mkdir images - run: docker save -o images/py35.tar py35 @@ -81,7 +81,7 @@ jobs: steps: - checkout - setup_remote_docker: - docker_layer_caching: true + docker_layer_caching: false - run: docker build -f .circleci/Dockerfile --build-arg PYTHON_VERSION=3.6 -t py36 . - run: mkdir images - run: docker save -o images/py36.tar py36 From 32c90db509d86df1be125c657c52ce7baaed09fd Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Fri, 1 Nov 2019 14:54:30 +0000 Subject: [PATCH 05/10] Add test dependancies --- setup.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 448207d..38139e2 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,10 @@ 'django-cms>=3.5', ] +TEST_REQUIREMENTS = [ + 'djangocms_text_ckeditor', + 'djangocms_versioning', +] setup( name='djangocms-version-locking', @@ -26,7 +30,13 @@ install_requires=INSTALL_REQUIREMENTS, author='Fidelity International', test_suite='test_settings.run', + tests_require=TEST_REQUIREMENTS, url='http://github.com/divio/djangocms-version-locking', license='BSD', - zip_safe=False + zip_safe=False, + dependency_links=[ + 'http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms', + 'http://github.com/divio/djangocms-versioning/tarball/master#egg=djangocms-versioning', + 'http://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djangocms-text-ckeditor', + ] ) From f19e7ed332e4579d36e6a27419e49ff9af9f4c0a Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Fri, 1 Nov 2019 15:32:31 +0000 Subject: [PATCH 06/10] Repair missed docker layer change --- .circleci/config.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4903471..318beb6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ py34default: &py34default - image: circleci/python:3.4 steps: - setup_remote_docker: - docker_layer_caching: true + docker_layer_caching: false - checkout - attach_workspace: at: /tmp/images diff --git a/setup.py b/setup.py index 38139e2..7ab31f9 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ INSTALL_REQUIREMENTS = [ - 'Django>=1.11,<2.2', + 'Django>=1.11,<3.0' 'django-cms>=3.5', ] From 8e63f27bb9a8db55261e2cd551dff09c6555afa5 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 19 Feb 2020 14:56:17 +0000 Subject: [PATCH 07/10] Changed the install requirements to less than 2.2 --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7ab31f9..a4c1f0b 100644 --- a/setup.py +++ b/setup.py @@ -4,13 +4,15 @@ INSTALL_REQUIREMENTS = [ - 'Django>=1.11,<3.0' + 'Django>=1.11,<2.2' 'django-cms>=3.5', ] TEST_REQUIREMENTS = [ + "djangocms_helper", 'djangocms_text_ckeditor', 'djangocms_versioning', + "factory-boy", ] setup( From 471678356a18dabc2445d113cb7750624eadf31a Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 19 Feb 2020 15:08:59 +0000 Subject: [PATCH 08/10] Added specific versions to the test requirements --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index a4c1f0b..094c71f 100644 --- a/setup.py +++ b/setup.py @@ -37,8 +37,8 @@ license='BSD', zip_safe=False, dependency_links=[ - 'http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms', - 'http://github.com/divio/djangocms-versioning/tarball/master#egg=djangocms-versioning', - 'http://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djangocms-text-ckeditor', + 'http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms-4.0.0', + 'http://github.com/divio/djangocms-versioning/tarball/master#egg=djangocms-versioning-0.0.24', + 'http://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djangocms-text-ckeditor-4.0.0dev1', ] ) From 7e25ecfab4ee1e80764e8b40323271ce8c1c2ea1 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 19 Feb 2020 15:12:09 +0000 Subject: [PATCH 09/10] Added flak8 to the test requirements --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 094c71f..a7c9d7b 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ 'djangocms_text_ckeditor', 'djangocms_versioning', "factory-boy", + "flake8", ] setup( From e3aef7fbc65ce559f668fe0af497df84f89bff1b Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Wed, 19 Feb 2020 15:23:46 +0000 Subject: [PATCH 10/10] Added missing tox test requirements --- setup.py | 1 - tests/requirements.txt | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a7c9d7b..094c71f 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,6 @@ 'djangocms_text_ckeditor', 'djangocms_versioning', "factory-boy", - "flake8", ] setup( diff --git a/tests/requirements.txt b/tests/requirements.txt index 2b00a89..e0b1126 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,8 @@ # test libraries coverage +pyflakes>=2.1.1 +flake8 +isort +mock djangocms_helper factory-boy