Skip to content

Commit

Permalink
Primarily dropping python 2. Added pre-commit and github actions for …
Browse files Browse the repository at this point in the history
…flake8 & isort, plus pyupgrade in the pre-commit.
  • Loading branch information
marksweb committed Nov 5, 2021
1 parent ac1c2c7 commit 87714d8
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 38 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: linters

on: [push, pull_request]

jobs:
flake8:
name: flake8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install --upgrade flake8
- name: flake8
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: flake8
run: flake8

isort:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
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 -rc -df djangocms_column

27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
hooks:
- id: pyupgrade
args: ["--py36-plus"]

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
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/pycqa/isort
rev: 5.9.3
hooks:
- id: isort
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ This plugin requires `django CMS` 3.4.5 or higher to be properly installed.
Usage
-----

There are 2 plugins: MultiColumn and Column
The first is MultiColumn that should be added to your placeholder conf.
MultiColumn only allows one plugin as a child: the Column plugin.
The Column plugin has a parameter width. With this parameter you can control the width
There are 2 plugins: `MultiColumn` and `Column`
The first is `MultiColumn` that should be added to your placeholder conf.
`MultiColumn` only allows one plugin as a child: the `Column` plugin.
The `Column` plugin has a parameter width. With this parameter you can control the width
of the column.

You can add a new setting to your settings.py called `COLUMN_WIDTH_CHOICES`
Expand Down
4 changes: 1 addition & 3 deletions djangocms_column/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

__version__ = "1.11.0"
__version__ = '1.11.0'
6 changes: 3 additions & 3 deletions djangocms_column/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from cms.plugin_pool import plugin_pool

from .forms import MultiColumnForm
from .models import MultiColumns, Column
from .models import Column, MultiColumns


class MultiColumnPlugin(CMSPluginBase):
Expand All @@ -18,10 +18,10 @@ class MultiColumnPlugin(CMSPluginBase):
form = MultiColumnForm

def save_model(self, request, obj, form, change):
response = super(MultiColumnPlugin, self).save_model(
response = super().save_model(
request, obj, form, change
)
for x in range(int(form.cleaned_data['create'])):
for _x in range(int(form.cleaned_data['create'])):
col = Column(
parent=obj,
placeholder=obj.placeholder,
Expand Down
2 changes: 1 addition & 1 deletion djangocms_column/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django import forms
from django.utils.translation import ugettext_lazy as _

from .models import MultiColumns, WIDTH_CHOICES
from .models import WIDTH_CHOICES, MultiColumns


class MultiColumnForm(forms.ModelForm):
Expand Down
5 changes: 1 addition & 4 deletions djangocms_column/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import django.db.models.deletion
from django.db import models, migrations
from django.db import migrations, models

from djangocms_column.models import WIDTH_CHOICES

Expand Down
3 changes: 0 additions & 3 deletions djangocms_column/migrations/0002_auto_20160915_0818.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import django.db.models.deletion
from django.db import migrations, models

Expand Down
8 changes: 2 additions & 6 deletions djangocms_column/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from six import python_2_unicode_compatible

from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
Expand All @@ -20,7 +18,6 @@
)


@python_2_unicode_compatible
class MultiColumns(CMSPlugin):
"""
A plugin that has sub Column classes
Expand All @@ -34,10 +31,9 @@ class MultiColumns(CMSPlugin):

def __str__(self):
plugins = self.child_plugin_instances or []
return _(u"%s columns") % len(plugins)
return _("%s columns") % len(plugins)


@python_2_unicode_compatible
class Column(CMSPlugin):
"""
A Column for the MultiColumns Plugin
Expand All @@ -56,4 +52,4 @@ class Column(CMSPlugin):
)

def __str__(self):
return u"%s" % self.get_width_display()
return "%s" % self.get_width_display()
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
django-cms>=3.4.5,<4.1
django-cms>=3.4.5,<4.1
pre-commit==2.15.0
12 changes: 12 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
max-line-length = 119
extend-ignore = A003,B009,B010,C101,C408,C812,C815,E501,E800,N400,Q000
exclude = .env,.venv,migrations,docs

[isort]
combine_as_imports = true
include_trailing_comma = true
known_django = django
line_length = 119
multi_line_output = 5
sections = FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
26 changes: 13 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup

from djangocms_column import __version__


INSTALL_REQUIRES = [
'django-cms>=3.4.5',
'Django>=1.11,<3.3',
'six>=1.9.0',
'Django>=1.11,<3.3'
]

CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Topic :: Communications',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Message Boards',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Communications',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Message Boards',
]

setup(
name='djangocms-column',
version=__version__,
description='Column Plugin for django CMS',
author='Divio AG',
author_email='info@divio.ch',
url='https://github.com/divio/djangocms-column',
author='Django CMS Association and contributors',
author_email='info@django-cms.org',
url='https://github.com/django-cms/djangocms-column',
packages=[
'djangocms_column',
'djangocms_column.migrations',
Expand Down

0 comments on commit 87714d8

Please sign in to comment.