Skip to content

Commit

Permalink
Addon code alignments (django-cms#166)
Browse files Browse the repository at this point in the history
* cleaned up files

* applying isort

* fix flake8

* use lowercase

* use two spaces
  • Loading branch information
FinalAngel authored Jan 21, 2019
1 parent fbb6741 commit 666b565
Show file tree
Hide file tree
Showing 29 changed files with 171 additions and 57 deletions.
25 changes: 21 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
*.pyc
*.py[cod]
*$py.class
*.egg-info
*.egg/
*.log
*.pot
.DS_Store
.coverage/
.eggs/
.idea/
.project/
.pydevproject/
.settings/
.tox/
.eggs/
dist/
__pycache__/
build/
dist/
env/

/~
/node_modules
.sass-cache
*.css.map
npm-debug.log
package-lock.json

local.sqlite
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@ matrix:
include:
- python: 3.5
env: TOX_ENV='flake8'
# Django 1.11
- python: 3.5
env: TOX_ENV='isort'
# Django 1.11
- python: 2.7
env: DJANGO='dj111' CMS='cms34'
- python: 3.5
- python: 3.4
env: DJANGO='dj111' CMS='cms35'
- python: 3.5
env: DJANGO='dj111' CMS='cms36'
# Django 2.0
- python: 3.5
env: DJANGO='dj20' CMS='cms36'
# Django 2.1
- python: 3.5
- python: 3.6
env: DJANGO='dj21' CMS='cms36'

install:
- pip install tox coverage
- pip install coverage isort tox
- "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PY_VER=py27; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.4' ]]; then export PY_VER=py34; fi"
- "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 [[ ${DJANGO}z != 'z' ]]; then export TOX_ENV=$PY_VER-$DJANGO-$CMS; fi"

script:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Changelog
=========


2.3.2 (unreleased)
==================

* Extended test matrix
* Added isort and adapted imports
* Adapted code base to align with other supported addons


2.3.1 (2018-12-20)
==================

Expand Down
19 changes: 13 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
django CMS Link
===============


|pypi| |build| |coverage|

**django CMS Link** is a plugin for `django CMS <http://django-cms.org>`_ that
Expand All @@ -26,6 +25,10 @@ feedback in the form of issues and pull requests. Before submitting your
pull request, please review our `contribution guidelines
<http://docs.django-cms.org/en/latest/contributing/index.html>`_.

We're grateful to all contributors who have helped create and maintain this package.
Contributors are listed at the `contributors <https://github.com/divio/djangocms-link/graphs/contributors>`_
section.

One of the easiest contributions you can make is helping to translate this addon on
`Transifex <https://www.transifex.com/projects/p/djangocms-link/>`_.

Expand All @@ -36,8 +39,7 @@ Documentation
See ``REQUIREMENTS`` in the `setup.py <https://github.com/divio/djangocms-link/blob/master/setup.py>`_
file for additional dependencies:

* Python 2.7, 3.4 or higher
* Django 1.11 or higher
|python| |django| |djangocms|


Installation
Expand Down Expand Up @@ -106,9 +108,7 @@ for simpler use of internal links. You need to manually enable it by:
Running Tests
-------------

You can run tests by executing:

.. code-block:: bash
You can run tests by executing::

virtualenv env
source env/bin/activate
Expand All @@ -122,3 +122,10 @@ You can run tests by executing:
:target: https://travis-ci.org/divio/djangocms-link
.. |coverage| image:: https://codecov.io/gh/divio/djangocms-link/branch/master/graph/badge.svg
:target: https://codecov.io/gh/divio/djangocms-link

.. |python| image:: https://img.shields.io/badge/python-2.7%20%7C%203.4+-blue.svg
:target: https://pypi.org/project/djangocms-link/
.. |django| image:: https://img.shields.io/badge/django-1.11%20%7C%202.0%20%7C%202.1-blue.svg
:target: https://www.djangoproject.com/
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.4%2B-blue.svg
:target: https://www.django-cms.org/
4 changes: 2 additions & 2 deletions djangocms_link/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _
from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
Expand Down Expand Up @@ -59,7 +59,7 @@ def get_form(self, request, obj=None, **kwargs):
site = obj.page.site
elif self.page and self.page.site:
site = self.page.site
except:
except: # noqa
site = Site.objects.get_current()
else:
site = Site.objects.get_current()
Expand Down
8 changes: 5 additions & 3 deletions djangocms_link/fields.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
from django.conf import settings


ENABLE_SELECT2 = getattr(settings, 'DJANGOCMS_LINK_USE_SELECT2', False)

if ENABLE_SELECT2 and 'django_select2' in settings.INSTALLED_APPS:
try:
from djangocms_link.fields_select2 import Select2PageSearchField as PageSearchField
from djangocms_link.fields_select2 import Select2PageSearchField as PageSearchField # noqa
except ImportError:
from djangocms_link.fields_select2_legacy import Select2LegacyPageSearchField as PageSearchField
from djangocms_link.fields_select2_legacy import Select2LegacyPageSearchField as PageSearchField # noqa
else:
from cms.forms.fields import PageSelectFormField as PageSearchField
from cms.forms.fields import PageSelectFormField as PageSearchField # noqa
4 changes: 3 additions & 1 deletion djangocms_link/fields_select2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from cms.models import Page
# -*- coding: utf-8 -*-
from django import forms

from cms.models import Page

from django_select2.forms import ModelSelect2Widget


Expand Down
2 changes: 2 additions & 0 deletions djangocms_link/fields_select2_legacy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from cms.models import Page

from django_select2.fields import AutoModelSelect2Field


Expand Down
1 change: 1 addition & 0 deletions djangocms_link/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.forms.models import ModelForm
from django.utils.translation import ugettext_lazy as _

Expand Down
2 changes: 1 addition & 1 deletion djangocms_link/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion djangocms_link/migrations/0002_auto_20140929_1705.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion djangocms_link/migrations/0003_auto_20150212_1310.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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


class Migration(migrations.Migration):
Expand Down
3 changes: 2 additions & 1 deletion djangocms_link/migrations/0004_auto_20150708_1133.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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

import djangocms_link.validators
from djangocms_link.models import HOSTNAME

Expand Down
2 changes: 1 addition & 1 deletion djangocms_link/migrations/0005_auto_20151003_1710.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Generated by Django 1.9.2 on 2016-02-26 14:19
from __future__ import unicode_literals

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


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Generated by Django 1.9.2 on 2016-03-04 04:44
from __future__ import unicode_literals

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


class Migration(migrations.Migration):
Expand Down
1 change: 1 addition & 0 deletions djangocms_link/migrations/0008_link_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import unicode_literals

from django.db import migrations

import djangocms_attributes_field.fields


Expand Down
1 change: 1 addition & 0 deletions djangocms_link/migrations/0009_auto_20160705_1344.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import unicode_literals

from django.db import migrations

import djangocms_attributes_field.fields


Expand Down
4 changes: 3 additions & 1 deletion djangocms_link/migrations/0010_adapted_fields.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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

import djangocms_attributes_field.fields

from djangocms_link.models import get_templates


Expand Down
1 change: 1 addition & 0 deletions djangocms_link/migrations/0012_removed_null.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

from django.db import migrations, models

import djangocms_link.validators


Expand Down
1 change: 1 addition & 0 deletions djangocms_link/migrations/0013_fix_hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

from django.db import migrations, models

import djangocms_link.validators
from djangocms_link.models import HOSTNAME

Expand Down
11 changes: 7 additions & 4 deletions djangocms_link/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"""
from __future__ import unicode_literals

from django.contrib.sites.models import Site
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.encoding import python_2_unicode_compatible, force_text
from django.utils.translation import ugettext, ugettext_lazy as _
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _

from cms.models import CMSPlugin, Page

Expand Down Expand Up @@ -51,7 +52,9 @@ class AbstractLink(CMSPlugin):
# used by django CMS search
search_fields = ('name', )

url_validators = [IntranetURLValidator(intranet_host_re=HOSTNAME),]
url_validators = [
IntranetURLValidator(intranet_host_re=HOSTNAME),
]

template = models.CharField(
verbose_name=_('Template'),
Expand Down
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,35 @@
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Framework :: Django',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
]


setup(
name='djangocms-link',
version=__version__,
description='Adds a link plugin to django CMS',
author='Divio AG',
author_email='[email protected]',
url='https://github.com/divio/djangocms-link',
license='BSD',
description='Adds a link plugin to django CMS',
long_description=open('README.rst').read(),
packages=find_packages(exclude=['tests']),
include_package_data=True,
Expand Down
4 changes: 2 additions & 2 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# requirements from setup.py
django-select2>=5.11
# other requirements
djangocms-text-ckeditor
html5lib<0.99999999
djangocms-helper>=1.1.0,<1.2.0
# other requirements
djangocms-helper
tox
coverage
2 changes: 2 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
HELPER_SETTINGS = {
'INSTALLED_APPS': [
'django_select2',
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_field.py → tests/test_field.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from djangocms_helper.base_test import BaseTestCase

from djangocms_link.fields import PageSearchField
from djangocms_link.fields_select2 import Select2PageSearchField

Expand Down
Loading

0 comments on commit 666b565

Please sign in to comment.