Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit ffbe35b

Browse files
authored
Fix django 3.2 tests, pypi release actions and pre-commit (#594)
* Added pypi actions * Update manifest for private and tests. Exclude tests from setuptools * Remove django 3.0 and EOL python. Removed testing django 3.2 against cms 3.8 Added python 3.10 to test workflow * Added pre-commit hooks. * Revert changes to classifiers and remove testing against django 3.2 * Ran pre-commit hooks * Fixed django 3.2 tests * Update changelog * Add pre-commit instructions to readme. * Fix link
1 parent a9266f2 commit ffbe35b

31 files changed

+262
-173
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ jobs:
2020
uses: liskin/gh-problem-matcher-wrap@v1
2121
with:
2222
linters: flake8
23-
run: |
24-
flake8 --exit-zero
23+
run: flake8
2524

2625
isort:
2726
runs-on: ubuntu-latest
@@ -37,4 +36,4 @@ jobs:
3736
uses: liskin/gh-problem-matcher-wrap@v1
3837
with:
3938
linters: isort
40-
run: isort -c -rc -df djangocms_text_ckeditor
39+
run: isort -c -df djangocms_text_ckeditor
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish Python 🐍 distributions 📦 to pypi
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
build-n-publish:
10+
name: Build and publish Python 🐍 distributions 📦 to pypi
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@master
14+
- name: Set up Python 3.9
15+
uses: actions/setup-python@v1
16+
with:
17+
python-version: 3.9
18+
19+
- name: Install pypa/build
20+
run: >-
21+
python -m
22+
pip install
23+
build
24+
--user
25+
- name: Build a binary wheel and a source tarball
26+
run: >-
27+
python -m
28+
build
29+
--sdist
30+
--wheel
31+
--outdir dist/
32+
.
33+
34+
- name: Publish distribution 📦 to PyPI
35+
if: startsWith(github.ref, 'refs/tags')
36+
uses: pypa/gh-action-pypi-publish@master
37+
with:
38+
user: __token__
39+
password: ${{ secrets.PYPI_API_TOKEN }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish Python 🐍 distributions 📦 to TestPyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-n-publish:
10+
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@master
14+
- name: Set up Python 3.9
15+
uses: actions/setup-python@v1
16+
with:
17+
python-version: 3.9
18+
19+
- name: Install pypa/build
20+
run: >-
21+
python -m
22+
pip install
23+
build
24+
--user
25+
- name: Build a binary wheel and a source tarball
26+
run: >-
27+
python -m
28+
build
29+
--sdist
30+
--wheel
31+
--outdir dist/
32+
.
33+
34+
- name: Publish distribution 📦 to Test PyPI
35+
uses: pypa/gh-action-pypi-publish@master
36+
with:
37+
user: __token__
38+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
39+
repository_url: https://test.pypi.org/legacy/
40+
skip_existing: true

.github/workflows/test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
python-version: [ 3.7, 3.8, 3.9, ] # latest release minus two
11+
python-version: [ 3.7, 3.8, 3.9, '3.10']
1212
requirements-file: [
1313
dj22_cms37.txt,
1414
dj22_cms38.txt,
15-
dj30_cms37.txt,
16-
dj30_cms38.txt,
1715
dj31_cms38.txt,
16+
dj32_cms39.txt
1817
]
1918
os: [
2019
ubuntu-20.04,

.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v2.31.0
4+
hooks:
5+
- id: pyupgrade
6+
args: ["--py37-plus"]
7+
8+
- repo: https://github.com/adamchainz/django-upgrade
9+
rev: '1.4.0'
10+
hooks:
11+
- id: django-upgrade
12+
args: [--target-version, "2.2"]
13+
14+
- repo: https://github.com/PyCQA/flake8
15+
rev: 4.0.1
16+
hooks:
17+
- id: flake8
18+
additional_dependencies:
19+
- flake8-broken-line
20+
- flake8-bugbear
21+
- flake8-builtins
22+
- flake8-coding
23+
- flake8-commas
24+
- flake8-comprehensions
25+
- flake8-eradicate
26+
- flake8-quotes
27+
- flake8-tidy-imports
28+
- pep8-naming
29+
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.10.1
32+
hooks:
33+
- id: isort

CHANGELOG.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ Unreleased
66
==========
77

88
* Add dark mode feature and dark mode patch for skin moono-lisa
9-
10-
4.0.1 (unreleased)
11-
==================
12-
139
* Added support for Django 3.2
10+
* Drop support for python 3.5, 3.6 and django 3.0
11+
* Added pre-commit hooks for developer workflow to ensure code quality
1412

1513

1614
4.0.0 (2020-09-15)

MANIFEST.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,20 @@ include README.rst
33
recursive-include djangocms_text_ckeditor/locale *
44
recursive-include djangocms_text_ckeditor/static *
55
recursive-include djangocms_text_ckeditor/templates *
6+
recursive-include private/moono-lisa/dev *.png
7+
recursive-include private/moono-lisa/dev *.svg
8+
recursive-include private/moono-lisa/dev *.json
9+
recursive-include private/moono-lisa/images/hidpi *.png
10+
recursive-include private/moono-lisa/iamges *.gif
11+
recursive-include private/moono-lisa/images *.png
12+
recursive-include private/moono-lisa *.css
13+
recursive-include private/moono-lisa *.js
14+
recursive-include private/moono-lisa *.md
15+
recursive-include private *.md
16+
recursive-include private *.py
17+
recursive-include tests .eslintrc
18+
recursive-include tests *.html
19+
recursive-include tests *.js
20+
recursive-include tests *.py
21+
recursive-include tests *.txt
622
recursive-exclude * *.py[co]

README.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ directly to your web pages. Enhance your website experience with our community
1010
maintained editor. This package aims to integrate CKEditor into django CMS as
1111
a text plugin.
1212

13-
.. note::
14-
13+
.. note::
14+
1515
This project is endorsed by the `django CMS Association <https://www.django-cms.org/en/about-us/>`_.
16-
That means that it is officially accepted by the dCA as being in line with our roadmap vision and development/plugin policy.
16+
That means that it is officially accepted by the dCA as being in line with our roadmap vision and development/plugin policy.
1717
Join us on `Slack <https://www.django-cms.org/slack/>`_.
1818

1919

@@ -32,8 +32,8 @@ Contribute to this project and win rewards
3232

3333
Because this is a an open-source project, we welcome everyone to
3434
`get involved in the project <https://www.django-cms.org/en/contribute/>`_ and
35-
`receive a reward <https://www.django-cms.org/en/bounty-program/>`_ for their contribution.
36-
Become part of a fantastic community and help us make django CMS the best CMS in the world.
35+
`receive a reward <https://www.django-cms.org/en/bounty-program/>`_ for their contribution.
36+
Become part of a fantastic community and help us make django CMS the best CMS in the world.
3737

3838
We'll be delighted to receive your
3939
feedback in the form of issues and pull requests. Before submitting your
@@ -441,6 +441,13 @@ to make text content using Haystack.
441441
Development
442442
===========
443443

444+
pre-commit hooks
445+
----------------
446+
447+
The repo uses pre-commit git hooks to run tools which ensure code quality.
448+
449+
To utilise this, run ``pip install pre-commit`` and then ``pre-commit install``.
450+
444451
Building the JavaScript
445452
-----------------------
446453

@@ -455,8 +462,7 @@ This command also updates the file name loaded based on the file contents.
455462
Updating the CKEditor
456463
---------------------
457464

458-
Make sure to use the url in `build config
459-
<https://github.com/divio/djangocms-text-ckeditor/blob/master/djangocms_text_ckeditor/static/djangocms_text_ckeditor/ckeditor/build-config.js#L16>_`.
465+
Make sure to use the url in `build config <https://github.com/divio/djangocms-text-ckeditor/blob/master/djangocms_text_ckeditor/static/djangocms_text_ckeditor/ckeditor/build-config.js#L16>`_.
460466

461467

462468
Running Tests

aldryn_config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ class Form(forms.BaseForm):
1212
)
1313

1414
def clean(self):
15-
data = super(Form, self).clean()
15+
data = super().clean()
1616

1717
if data.get('content_css'):
1818
files = data['content_css'].split(',')
1919
data['content_css'] = [item.strip() for item in files if item]
2020
return data
2121

2222
def to_settings(self, data, settings):
23-
CKEDITOR_SETTINGS = {
23+
ckeditor_settings = {
2424
'height': 300,
2525
'language': '{{ language }}',
2626
'toolbar': 'CMS',
2727
'skin': 'moono-lisa',
2828
}
2929

3030
if data.get('content_css'):
31-
CKEDITOR_SETTINGS['contentsCss'] = data['content_css']
31+
ckeditor_settings['contentsCss'] = data['content_css']
3232
else:
33-
CKEDITOR_SETTINGS['contentsCss'] = ['/static/css/base.css']
33+
ckeditor_settings['contentsCss'] = ['/static/css/base.css']
3434

3535
if data.get('style_set'):
3636
style_set = data['style_set']
3737
else:
3838
style_set = ''
3939

40-
CKEDITOR_SETTINGS['stylesSet'] = 'default:{}'.format(style_set)
40+
ckeditor_settings['stylesSet'] = f'default:{style_set}'
4141

42-
settings['CKEDITOR_SETTINGS'] = CKEDITOR_SETTINGS
42+
settings['CKEDITOR_SETTINGS'] = ckeditor_settings
4343
return settings

djangocms_text_ckeditor/cms_plugins.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
from django.core.exceptions import PermissionDenied, ValidationError
88
from django.db import transaction
99
from django.forms.fields import CharField
10-
from django.http import (
11-
Http404, HttpResponse, HttpResponseBadRequest, HttpResponseForbidden,
12-
HttpResponseRedirect,
13-
)
10+
from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect
1411
from django.shortcuts import get_object_or_404
1512
from django.template import RequestContext
1613
from django.urls import re_path, reverse
@@ -28,15 +25,11 @@
2825
from cms.utils.urlutils import admin_reverse
2926

3027
from . import settings
31-
from .forms import (
32-
ActionTokenValidationForm, DeleteOnCancelForm, RenderPluginForm, TextForm,
33-
)
28+
from .forms import ActionTokenValidationForm, DeleteOnCancelForm, RenderPluginForm, TextForm
3429
from .models import Text
3530
from .utils import (
36-
OBJ_ADMIN_WITH_CONTENT_RE_PATTERN, _plugin_tags_to_html,
37-
plugin_tags_to_admin_html, plugin_tags_to_id_list,
38-
plugin_tags_to_user_html, plugin_to_tag, random_comment_exempt,
39-
replace_plugin_tags,
31+
OBJ_ADMIN_WITH_CONTENT_RE_PATTERN, _plugin_tags_to_html, plugin_tags_to_admin_html, plugin_tags_to_id_list,
32+
plugin_tags_to_user_html, plugin_to_tag, random_comment_exempt, replace_plugin_tags,
4033
)
4134
from .widgets import TextEditorWidget
4235

@@ -193,11 +186,11 @@ class TextPlugin(CMSPluginBase):
193186
_has_do_post_copy = True
194187

195188
@classmethod
196-
def do_post_copy(self, instance, source_map):
189+
def do_post_copy(cls, instance, source_map):
197190
ids = plugin_tags_to_id_list(instance.body)
198191
ids_map = {pk: source_map[pk].pk for pk in ids if pk in source_map}
199192
new_text = replace_plugin_tags(instance.body, ids_map)
200-
self.model.objects.filter(pk=instance.pk).update(body=new_text)
193+
cls.model.objects.filter(pk=instance.pk).update(body=new_text)
201194

202195
@staticmethod
203196
def get_translation_export_content(field, plugin_data):
@@ -329,7 +322,7 @@ def add_view(self, request, form_url='', extra_context=None):
329322
# The instance is a record that points to the Text plugin
330323
# but is not a real text plugin instance.
331324
return super().add_view(
332-
request, form_url, extra_context
325+
request, form_url, extra_context,
333326
)
334327

335328
if not self.has_add_permission(request):
@@ -395,7 +388,7 @@ def pattern(regex, func):
395388

396389
def get_admin_url_name(self, name):
397390
plugin_type = self.__class__.__name__.lower()
398-
url_name = '%s_%s_%s' % (self.model._meta.app_label, plugin_type, name)
391+
url_name = f'{self.model._meta.app_label}_{plugin_type}_{name}'
399392
return url_name
400393

401394
def _get_text_plugin_from_request(self, request, data):
@@ -513,7 +506,7 @@ def render(self, context, instance, placeholder):
513506
context,
514507
),
515508
'placeholder': placeholder,
516-
'object': instance
509+
'object': instance,
517510
})
518511
return context
519512

0 commit comments

Comments
 (0)