Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
*.pyc
*.py[cod]
*$py.class
*.egg-info
*.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.2.1 (unreleased)
==================

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


2.2.0 (2018-12-12)
==================

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ include LICENSE.txt
include README.rst
recursive-include djangocms_file/locale *
recursive-include djangocms_file/templates *
recursive-exclude * *.pyc
recursive-exclude * *.py[co]
24 changes: 15 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
django CMS File
===============


|pypi| |build| |coverage|

**django CMS File** is a set of plugins for `django CMS <http://django-cms.org>`_
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-file/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-file/>`_.

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

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

* Django Filer 1.2.4 or higher

Make sure `django Filer <http://django-filer.readthedocs.io/en/latest/installation.html>`_
Expand All @@ -62,9 +65,7 @@ to adapt and override them to your project's requirements.

This addon provides a ``default`` template for all instances. You can provide
additional template choices by adding a ``DJANGOCMS_FILE_TEMPLATES``
setting:

.. code-block:: python
setting::

DJANGOCMS_FILE_TEMPLATES = [
('feature', _('Featured Version')),
Expand All @@ -79,9 +80,7 @@ copying the ``default`` folder inside that directory and renaming it to
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 @@ -95,3 +94,10 @@ You can run tests by executing:
:target: https://travis-ci.org/divio/djangocms-file
.. |coverage| image:: https://codecov.io/gh/divio/djangocms-file/branch/master/graph/badge.svg
:target: https://codecov.io/gh/divio/djangocms-file

.. |python| image:: https://img.shields.io/badge/python-2.7%20%7C%203.4+-blue.svg
:target: https://pypi.org/project/djangocms-file/
.. |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/
3 changes: 2 additions & 1 deletion djangocms_file/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext_lazy as _

from .models import File, Folder

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

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

import cms.models.pluginmodel


class Migration(migrations.Migration):

Expand Down
3 changes: 2 additions & 1 deletion djangocms_file/migrations/0006_migrate_to_filer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from __future__ import unicode_literals

import django.db.models.deletion
import filer.fields.file
from django.db import migrations, models

import filer.fields.file


def migrate_to_filer(apps, schema_editor):
# Because filer is polymorphic, Djangos migration can't handle
Expand Down
3 changes: 2 additions & 1 deletion djangocms_file/migrations/0007_adapted_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from __future__ import unicode_literals

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

import djangocms_attributes_field.fields
import filer.fields.file
from django.db import migrations, models

from djangocms_file.models import get_templates

Expand Down
3 changes: 2 additions & 1 deletion djangocms_file/migrations/0008_add_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from __future__ import unicode_literals

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

import djangocms_attributes_field.fields
import filer.fields.folder
from django.db import migrations, models

from djangocms_file.models import get_templates

Expand Down
3 changes: 1 addition & 2 deletions djangocms_file/migrations/0011_auto_20181211_0357.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Generated by Django 2.1.2 on 2018-12-11 03:57

# -*- coding: utf-8 -*-
from django.db import migrations, models


Expand Down
7 changes: 6 additions & 1 deletion djangocms_file/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
Enables the user to add a "File" plugin that displays a file wrapped by
an <anchor> tag.
"""
from cms.models import CMSPlugin
from __future__ import unicode_literals

from django.conf import settings
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _

from cms.models import CMSPlugin

from djangocms_attributes_field.fields import AttributesField
from filer.fields.file import FilerFileField
from filer.fields.folder import FilerFolderField


LINK_TARGET = (
('_self', _('Open in same window')),
('_blank', _('Open in new window')),
Expand Down
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from djangocms_file import __version__


REQUIREMENTS = [
'django-cms>=3.4.5',
'django-filer>=1.2.4',
Expand All @@ -14,10 +15,13 @@
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',
Expand All @@ -27,19 +31,19 @@
'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-file',
version=__version__,
description='Adds file plugin to django CMS',
author='Divio AG',
author_email='info@divio.ch',
url='https://github.com/divio/djangocms-file',
license='BSD',
description='Adds file plugin to django CMS',
long_description=open('README.rst').read(),
packages=find_packages(exclude=['tests']),
include_package_data=True,
Expand Down
1 change: 0 additions & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HELPER_SETTINGS = {
'INSTALLED_APPS': [
'easy_thumbnails',
Expand Down
31 changes: 31 additions & 0 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# original from
# http://tech.octopus.energy/news/2016/01/21/testing-for-missing-migrations-in-django.html
from django.core.management import call_command
from django.test import TestCase, override_settings
from django.utils.six import text_type
from django.utils.six.moves import StringIO


class MigrationTestCase(TestCase):

@override_settings(MIGRATION_MODULES={})
def test_for_missing_migrations(self):
output = StringIO()
options = {
'interactive': False,
'dry_run': True,
'stdout': output,
'check_changes': True,
}

try:
call_command('makemigrations', **options)
except SystemExit as e:
status_code = text_type(e)
else:
# the "no changes" exit code is 0
status_code = '0'

if status_code == '1':
self.fail('There are missing migrations:\n {}'.format(output.getvalue()))
16 changes: 0 additions & 16 deletions tests/tests_models.py → tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
from django.test import TestCase
from django.core.management import call_command
from django.utils.six import StringIO

from filer.models import File as FilerFile
from filer.models import Folder as FilerFolder
Expand Down Expand Up @@ -37,17 +35,3 @@ def test_folder_instance(self):
"""Folder instance has been created"""
test_folder = FilerFolder.objects.get(name='test')
self.assertEqual(test_folder.name, 'test')


class MigrationTestCase(TestCase):

def test_makemigrations(self):
"""Fail if there are schema changes with no migrations."""
app_name = 'djangocms_file'
out = StringIO()
call_command('makemigrations', dry_run=True, no_input=True, stdout=out)
output = out.getvalue()
self.assertNotIn(app_name, output, (
'`makemigrations` thinks there are schema changes without'
' migrations.'
))
30 changes: 28 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tox]
envlist =
flake8
isort
py{27,34,35,36}-dj111-cms{34,35,36}
py{34,35,36}-dj20-cms36
py{35,36}-dj21-cms36
Expand All @@ -23,5 +24,30 @@ commands =
{env:COMMAND:coverage} report

[flake8]
max-line-length = 120
exclude = */docs/*,*/migrations/*
max-line-length = 119
exclude =
*.egg-info,
.eggs,
.git,
.settings,
.tox,
build,
data,
dist,
docs,
*migrations*,
requirements,
tmp

[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
known_first_party = djangocms_file
known_cms = cms, menus
known_django = django