Skip to content

Commit

Permalink
Drop Django<1.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanfoulis committed Jul 24, 2017
1 parent 01cec27 commit 3c942ec
Show file tree
Hide file tree
Showing 44 changed files with 75 additions and 2,891 deletions.
47 changes: 27 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,36 @@ env:
- TOX_ENV=flake8

# python 2.7
- TOX_ENV=py27-dj16-thumbs1x
- TOX_ENV=py27-dj16-thumbs2x
- TOX_ENV=py27-dj17-thumbs2x
- TOX_ENV=py27-dj18-thumbs2x
- TOX_ENV=py27-dj19-thumbs2x
- TOX_ENV=py27-dj110-thumbs2x
- TOX_ENV=py27-dj18
- TOX_ENV=py27-dj19
- TOX_ENV=py27-dj110
- TOX_ENV=py27-dj111

# python 3.4
- TOX_ENV=py34-dj16-thumbs2x
- TOX_ENV=py34-dj17-thumbs2x
- TOX_ENV=py34-dj18-thumbs2x
- TOX_ENV=py34-dj19-thumbs2x
- TOX_ENV=py34-dj110-thumbs2x
- TOX_ENV=py34-dj18
- TOX_ENV=py34-dj19
- TOX_ENV=py34-dj110
- TOX_ENV=py34-dj111

# python 3.5
- TOX_ENV=py35-dj18-thumbs2x
- TOX_ENV=py35-dj19-thumbs2x
- TOX_ENV=py35-dj110-thumbs2x
- TOX_ENV=py35-dj18
- TOX_ENV=py35-dj19
- TOX_ENV=py35-dj110
- TOX_ENV=py35-dj111

# python 3.6
- TOX_ENV=py36-dj18
- TOX_ENV=py36-dj19
- TOX_ENV=py36-dj110
- TOX_ENV=py36-dj111

# next Django release
- TOX_ENV=py27-djmaster-thumbs2x
- TOX_ENV=py34-djmaster-thumbs2x
- TOX_ENV=py35-djmaster-thumbs2x
- TOX_ENV=py27-djmaster
- TOX_ENV=py34-djmaster
- TOX_ENV=py35-djmaster
- TOX_ENV=py36-djmaster

# frontend tests
- TOX_ENV=frontend FE=1

before_script:
Expand All @@ -60,6 +66,7 @@ after_success:

matrix:
allow_failures:
- env: TOX_ENV=py27-djmaster-thumbs2x
- env: TOX_ENV=py34-djmaster-thumbs2x
- env: TOX_ENV=py35-djmaster-thumbs2x
- env: TOX_ENV=py27-djmaster
- env: TOX_ENV=py34-djmaster
- env: TOX_ENV=py35-djmaster
- env: TOX_ENV=py36-djmaster
4 changes: 1 addition & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Welcome to django-filer's documentation!
``django-filer`` is a file management application for django. It handles uploading
and organizing files and images in contrib.admin.

.. note:: upgrading from 0.8.7? Checkout :ref:`upgrading`.

+--------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------+
| .. image:: https://raw.githubusercontent.com/divio/django-filer/develop/docs/_static/filer_1.png | .. image:: https://raw.githubusercontent.com/divio/django-filer/develop/docs/_static/filer_2.png |
+--------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------+
Expand All @@ -33,7 +31,7 @@ Filer picker widget:
+--------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------+
| .. image:: https://raw.githubusercontent.com/divio/django-filer/develop/docs/_static/file_picker_1.png | .. image:: https://raw.githubusercontent.com/divio/django-filer/develop/docs/_static/file_picker_2.png |
+--------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------+
| .. image:: https://raw.githubusercontent.com/divio/django-filer/develop/docs/_static/file_picker_3.png | |
| .. image:: https://raw.githubusercontent.com/divio/django-filer/develop/docs/_static/file_picker_3.png | |
+--------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------+

Custom model fields are provided for use in 3rd party apps as a replacement for
Expand Down
32 changes: 5 additions & 27 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
Installation and Configuration
==============================

.. note:: upgrading from 0.8.7? Checkout :ref:`upgrading`.


Getting the latest release
--------------------------

Expand All @@ -17,41 +14,23 @@ The easiest way to get ``django-filer`` is simply install it with `pip`_::
Dependencies
------------

* `Django`_ >= 1.5
* `Django`_ >= 1.8
* `django-mptt`_ >=0.6
* `easy_thumbnails`_ >= 1.0
* `easy_thumbnails`_ >= 2.0
* `django-polymorphic`_ >= 0.7
* `Pillow`_ >=2.3.0 (with JPEG and ZLIB support, `PIL`_ 1.1.7 is supported but not recommended)
* `Pillow`_ >=2.3.0 (with JPEG and ZLIB support, `PIL`_ may work but is not supported)

``django.contrib.staticfiles`` is required.

Please note, there are some compatibility constraints that we can not enforce
through the `setup.py`. Here are the most important of them::

Django | django-polymorphic | django-mptt
------ | ------------------ | -----------
1.5 | >=0.4.1 | >=0.6,<0.8
1.6 | >=0.5.4, | >=0.6,<0.8
1.7 | >=0.5.6 | >=0.6,<0.8
1.8 | >=0.7 | >=0.7

Please make sure you install `Pillow`_ with JPEG and ZLIB support installed;
for further information on Pillow installation and its binary dependencies,
check `Pillow doc`_.


Django <1.7 and South
.....................

Django 1.7+ is supported together with the new migrations. For Django<1.7 South
is still supported, you need at least South>=1.0 for South to find them though.


Configuration
-------------

Add ``"filer"`` and related apps to your project's ``INSTALLED_APPS`` setting and run ``manage.py syncdb``
(or ``manage.py migrate`` if you're using `South`_ or Django migrations).::
Add ``"filer"`` and related apps to your project's ``INSTALLED_APPS`` setting and run ``manage.py migrate``::

INSTALLED_APPS = [
...
Expand All @@ -61,8 +40,7 @@ Add ``"filer"`` and related apps to your project's ``INSTALLED_APPS`` setting an
...
]

Note that `easy_thumbnails`_ also has database tables and needs a ``syncdb`` or
``migrate``.
Note that `easy_thumbnails`_ also has database tables and needs a ``python manage.py migrate``.

For `easy_thumbnails`_ to support retina displays (recent MacBooks, iOS) add to settings.py::

Expand Down
8 changes: 4 additions & 4 deletions docs/running_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ done for you. Tox will setup multiple virtual environments with different python
# run all tests in all default environments
tox
# run tests on particular versions
tox -e py27-django18-thumbs2x,py34-django_master-thumbs2x
tox -e py27-dj18,py34-dj_master
# run a test class in specific environment
tox -e py27-django18-thumbs2x -- test filer.tests.models.FilerApiTests
tox -e py27-dj18 -- test filer.tests.models.FilerApiTests
# run a specific testcase in specific environment
tox -e py27-django18-thumbs2x -- test filer.tests.models.FilerApiTests.test_create_folder_structure
tox -e py27-dj18 -- test filer.tests.models.FilerApiTests.test_create_folder_structure

Other test runner options are also supported, see
`djangocms-helper <https://djangocms-helper.readthedocs.io/en/develop/>`_
documentation for details.

To speed things up a bit use `detox <http://pypi.python.org/pypi/detox/>`_. ``detox`` runs each testsuite in a
separate process in parallel.
separate process in parallel. Detox also supports using ``pyenv`` to install multiple python versions.
2 changes: 1 addition & 1 deletion docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private (with permission checks) storages. Defaults to ``'filer.utils.generate_f


``FILER_SERVERS``
------------------
-----------------

.. warning:: Server Backends are experimental and the API may change at any time.

Expand Down
10 changes: 5 additions & 5 deletions filer/admin/clipboardadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from . import views
from .. import settings as filer_settings
from ..models import Clipboard, ClipboardItem, Folder, Image
from ..utils.compatibility import LTE_DJANGO_1_4
from ..utils.files import (
UploadException,
handle_request_files_upload,
Expand Down Expand Up @@ -75,16 +74,17 @@ def ajax_upload(request, folder_id=None):
Receives an upload from the uploader. Receives only one file at a time.
"""
mimetype = "application/json" if request.is_ajax() else "text/html"
content_type_key = 'mimetype' if LTE_DJANGO_1_4 else 'content_type'
response_params = {content_type_key: mimetype}
response_params = {'content_type': mimetype}
folder = None
if folder_id:
try:
# Get folder
folder = Folder.objects.get(pk=folder_id)
except Folder.DoesNotExist:
return HttpResponse(json.dumps({'error': NO_FOLDER_ERROR}),
**response_params)
return HttpResponse(
json.dumps({'error': NO_FOLDER_ERROR}),
**response_params
)

# check permissions
if folder and not folder.has_add_children_permission(request):
Expand Down
11 changes: 1 addition & 10 deletions filer/admin/fileadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .. import settings
from ..models import File
from ..utils.compatibility import LTE_DJANGO_1_5, LTE_DJANGO_1_6, unquote
from ..utils.compatibility import unquote
from .permissions import PrimitivePermissionAwareModelAdmin
from .tools import AdminContext, admin_url_params_encoded, popup_status

Expand All @@ -34,11 +34,6 @@ class FileAdmin(PrimitivePermissionAwareModelAdmin):

form = FileAdminChangeFrom

def get_queryset(self, request):
if LTE_DJANGO_1_5:
return super(FileAdmin, self).queryset(request)
return super(FileAdmin, self).get_queryset(request)

@classmethod
def build_fieldsets(cls, extra_main_fields=(), extra_advanced_fields=(),
extra_fieldsets=()):
Expand Down Expand Up @@ -121,10 +116,6 @@ def delete_view(self, request, object_id, extra_context=None):
except self.model.DoesNotExist:
parent_folder = None

admin_context = AdminContext(request)
if LTE_DJANGO_1_6:
extra_context = extra_context or {}
extra_context.update({'is_popup': admin_context.popup})
if request.POST:
# Return to folder listing, since there is no usable file listing.
super(FileAdmin, self).delete_view(
Expand Down
13 changes: 6 additions & 7 deletions filer/admin/folderadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
from .permissions import PrimitivePermissionAwareModelAdmin
from .tools import (
AdminContext,
admin_each_context,
admin_url_params_encoded,
check_files_edit_permissions,
check_files_read_permissions,
Expand Down Expand Up @@ -414,7 +413,7 @@ def directory_listing(self, request, folder_id=None, viewtype=None):
except EmptyPage:
paginated_items = paginator.page(paginator.num_pages)

context = admin_each_context(self.admin_site, request)
context = self.admin_site.each_context(request)
context.update({
'folder': folder,
'clipboard_files': File.objects.filter(
Expand Down Expand Up @@ -761,7 +760,7 @@ def delete_files_or_folders(self, request, files_queryset, folders_queryset):
else:
title = _("Are you sure?")

context = admin_each_context(self.admin_site, request)
context = self.admin_site.each_context(request)
context.update({
"title": title,
"instance": current_folder,
Expand Down Expand Up @@ -912,7 +911,7 @@ def move_files_and_folders(self, request, files_queryset, folders_queryset):
})
return None

context = admin_each_context(self.admin_site, request)
context = self.admin_site.each_context(request)
context.update({
"title": _("Move files and/or folders"),
"instance": current_folder,
Expand Down Expand Up @@ -995,7 +994,7 @@ def rename_files(self, request, files_queryset, folders_queryset):
else:
form = RenameFilesForm()

context = admin_each_context(self.admin_site, request)
context = self.admin_site.each_context(request)
context.update({
"title": _("Rename files"),
"instance": current_folder,
Expand Down Expand Up @@ -1125,7 +1124,7 @@ def copy_files_and_folders(self, request, files_queryset, folders_queryset):
else:
selected_destination_folder = 0

context = admin_each_context(self.admin_site, request)
context = self.admin_site.each_context(request)
context.update({
"title": _("Copy files and/or folders"),
"instance": current_folder,
Expand Down Expand Up @@ -1256,7 +1255,7 @@ def resize_images(self, request, files_queryset, folders_queryset):
else:
form = ResizeImagesForm()

context = admin_each_context(self.admin_site, request)
context = self.admin_site.each_context(request)
context.update({
"title": _("Resize images"),
"instance": current_folder,
Expand Down
8 changes: 1 addition & 7 deletions filer/admin/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from django.contrib import admin
from django.core.urlresolvers import reverse

from ..utils.compatibility import LTE_DJANGO_1_7


class PrimitivePermissionAwareModelAdmin(admin.ModelAdmin):
def has_add_permission(self, request):
Expand Down Expand Up @@ -34,10 +32,6 @@ def _get_post_url(self, obj):
"""
# Code from django ModelAdmin to determine changelist on the fly
opts = obj._meta
if LTE_DJANGO_1_7:
model_name = opts.module_name
else:
model_name = opts.model_name
return reverse('admin:%s_%s_changelist' %
(opts.app_label, model_name),
(opts.app_label, opts.model_name),
current_app=self.admin_site.name)
13 changes: 0 additions & 13 deletions filer/admin/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,9 @@
from django.core.exceptions import PermissionDenied
from django.utils.http import urlencode

from ..utils.compatibility import LTE_DJANGO_1_6, LTE_DJANGO_1_7

ALLOWED_PICK_TYPES = ('folder', 'file')


if LTE_DJANGO_1_6:
def admin_each_context(admin_site, request):
return {}
elif LTE_DJANGO_1_7:
def admin_each_context(admin_site, request):
return admin_site.each_context()
else:
def admin_each_context(admin_site, request):
return admin_site.each_context(request)


def check_files_edit_permissions(request, files):
for f in files:
if not f.has_edit_permission(request):
Expand Down
2 changes: 0 additions & 2 deletions filer/fields/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from .. import settings as filer_settings
from ..models import File
from ..utils.compatibility import (
LTE_DJANGO_1_7,
LTE_DJANGO_1_8,
truncate_words,
)
Expand Down Expand Up @@ -69,7 +68,6 @@ def render(self, name, value, attrs=None):
'admin/img/icon_deletelink.gif' if LTE_DJANGO_1_8
else 'admin/img/icon-deletelink.svg'
),
'LTE_DJANGO_1_7': LTE_DJANGO_1_7,
}
html = render_to_string('admin/filer/widgets/admin_file.html', context)
return mark_safe(html)
Expand Down
3 changes: 1 addition & 2 deletions filer/fields/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.utils.safestring import mark_safe

from ..models import Folder
from ..utils.compatibility import LTE_DJANGO_1_7, truncate_words
from ..utils.compatibility import truncate_words
from ..utils.model_label import get_model_label


Expand Down Expand Up @@ -63,7 +63,6 @@ def render(self, name, value, attrs=None):
'noimg': 'filer/icons/nofile_32x32.png',
'foldid': css_id_folder,
'id': css_id,
'LTE_DJANGO_1_7': LTE_DJANGO_1_7,
}
html = render_to_string('admin/filer/widgets/admin_folder.html', context)
return mark_safe(html)
Expand Down
Loading

0 comments on commit 3c942ec

Please sign in to comment.