Skip to content

Commit

Permalink
Merge 3c72913 into d7f7b8f
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed May 14, 2020
2 parents d7f7b8f + 3c72913 commit 79abf05
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 114 deletions.
12 changes: 0 additions & 12 deletions .travis.yml
Expand Up @@ -14,18 +14,6 @@ matrix:
include:
- { python: "3.7", env: DJANGO=2.2 DATABASE=sqlite SPATIALITE_LIBRARY_PATH='mod_spatialite' }

- { python: "2.7", env: DJANGO=1.8 DATABASE=postgres }
- { python: "3.4", env: DJANGO=1.8 DATABASE=postgres }
- { python: "3.5", env: DJANGO=1.8 DATABASE=postgres }

- { python: "2.7", env: DJANGO=1.9 DATABASE=postgres }
- { python: "3.4", env: DJANGO=1.9 DATABASE=postgres }
- { python: "3.5", env: DJANGO=1.9 DATABASE=postgres }

- { python: "2.7", env: DJANGO=1.10 DATABASE=postgres }
- { python: "3.4", env: DJANGO=1.10 DATABASE=postgres }
- { python: "3.5", env: DJANGO=1.10 DATABASE=postgres }

- { python: "2.7", env: DJANGO=1.11 DATABASE=postgres }
- { python: "3.4", env: DJANGO=1.11 DATABASE=postgres }
- { python: "3.5", env: DJANGO=1.11 DATABASE=postgres }
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
0.27.0 (unreleased)
-------------------

- Drop support for Django < 1.11
- Update Czech translations, add Slovak translations #269
- Add Arabic translation #274

Expand Down
14 changes: 7 additions & 7 deletions example/mushrooms/settings.py
Expand Up @@ -4,10 +4,10 @@
Generated by 'django-admin startproject' using Django 1.10.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
https://docs.djangoproject.com/en/stable/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
https://docs.djangoproject.com/en/stable/ref/settings/
"""

import os
Expand All @@ -17,7 +17,7 @@


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/stable/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '_omc6hxq40u11no0uvi&g__lzj2n^4-dk#l#i+7+vgng!-bb^)'
Expand Down Expand Up @@ -75,7 +75,7 @@


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
# https://docs.djangoproject.com/en/stable/ref/settings/#databases

DATABASES = {
'default': {
Expand All @@ -86,7 +86,7 @@


# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/stable/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -105,7 +105,7 @@


# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
# https://docs.djangoproject.com/en/stable/topics/i18n/

LANGUAGE_CODE = 'en-us'

Expand All @@ -119,7 +119,7 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
# https://docs.djangoproject.com/en/stable/howto/static-files/

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
Expand Down
2 changes: 1 addition & 1 deletion example/mushrooms/urls.py
@@ -1,7 +1,7 @@
"""mushrooms URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
https://docs.djangoproject.com/en/stable/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
Expand Down
2 changes: 1 addition & 1 deletion example/mushrooms/wsgi.py
Expand Up @@ -4,7 +4,7 @@
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
https://docs.djangoproject.com/en/stable/howto/deployment/wsgi/
"""

import os
Expand Down
21 changes: 2 additions & 19 deletions leaflet/__init__.py
Expand Up @@ -10,29 +10,18 @@
from urlparse import urlparse
import warnings

try:
from collections import OrderedDict
except ImportError:
# python 2.6 compatibility (need to install ordereddict package).
from ordereddict import OrderedDict
from collections import OrderedDict

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

try:
from django.templatetags.static import static
except ImportError:
from django.contrib.staticfiles.templatetags.staticfiles import static

from django.templatetags.static import static
from django.utils.translation import ugettext_lazy as _

try:
import six
except ImportError:
from django.utils import six

import django

from .utils import memoized_lazy_function, ListWithLazyItems, ListWithLazyItemsRawIterator


Expand Down Expand Up @@ -226,12 +215,6 @@ def _normalize_plugins_config():

default_app_config = 'leaflet.apps.LeafletConfig'

if django.VERSION >= (1, 8, 0): # otherwise is called in apps.py
if django.apps.apps.ready:
_normalize_plugins_config()
else:
_normalize_plugins_config()


class JSONLazyTranslationEncoder(DjangoJSONEncoder):
def default(self, obj):
Expand Down
19 changes: 5 additions & 14 deletions leaflet/forms/widgets.py
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from distutils.version import LooseVersion

from django import get_version
from django import forms
from django.contrib.gis.forms.widgets import BaseGeometryWidget
from django.core import validators
Expand Down Expand Up @@ -67,15 +65,8 @@ def _get_attrs(self, name, attrs=None):
field_store_class=attrs.get('field_store_class', getattr(self, 'field_store_class', 'L.FieldStore')))
return attrs

# Django 1.11 changed how the widgets are rendered
if LooseVersion(get_version()) >= LooseVersion('1.11'):
def get_context(self, name, value, attrs):
value = None if value in validators.EMPTY_VALUES else value
context = super(LeafletWidget, self).get_context(name, value, attrs)
context.update(self._get_attrs(name, attrs))
return context
else:
def render(self, name, value, attrs=None):
attrs = self._get_attrs(name, attrs)
value = None if value in validators.EMPTY_VALUES else value
return super(LeafletWidget, self).render(name, value, attrs)
def get_context(self, name, value, attrs):
value = None if value in validators.EMPTY_VALUES else value
context = super(LeafletWidget, self).get_context(name, value, attrs)
context.update(self._get_attrs(name, attrs))
return context
6 changes: 1 addition & 5 deletions leaflet/templatetags/leaflet_tags.py
Expand Up @@ -45,14 +45,10 @@ def leaflet_js(plugins=None):
plugin_names = _get_plugin_names(plugins)
with_forms = PLUGIN_FORMS in plugin_names or PLUGIN_ALL in plugin_names
FORCE_IMAGE_PATH = app_settings.get('FORCE_IMAGE_PATH')
template_options = hasattr(settings, 'TEMPLATES') \
and len(settings.TEMPLATES) \
and settings.TEMPLATES[0].get('OPTIONS', None)
template_options = settings.TEMPLATES[0].get('OPTIONS', None)

if template_options and 'debug' in template_options:
debug = template_options['debug']
elif hasattr(settings, 'TEMPLATE_DEBUG'):
debug = settings.TEMPLATE_DEBUG
else:
debug = False

Expand Down
30 changes: 12 additions & 18 deletions leaflet/tests/tests.py
Expand Up @@ -3,17 +3,12 @@
import json

import django
from django.contrib.staticfiles.storage import StaticFilesStorage, staticfiles_storage

try:
from django.templatetags.static import static
except ImportError:
from django.contrib.staticfiles.templatetags.staticfiles import static

from django.test import SimpleTestCase
from django.contrib.admin import ModelAdmin, StackedInline
from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin
from django.contrib.gis.db import models as gismodels
from django.contrib.staticfiles.storage import StaticFilesStorage, staticfiles_storage
from django.templatetags.static import static
from django.test import SimpleTestCase

from .. import PLUGINS, PLUGIN_FORMS, _normalize_plugins_config, JSONLazyTranslationEncoder

Expand Down Expand Up @@ -330,16 +325,15 @@ class Meta:
output = form.as_p()
self.assertIn(".geom_type = 'Point'", output)

if django.VERSION >= (1, 6, 0):
def test_modelform_widget_conformity(self):
class DummyForm(django.forms.ModelForm):
class Meta:
model = DummyModel
fields = ['geom']
widgets = {'geom': LeafletWidget()}
form = DummyForm()
output = form.as_p()
self.assertIn(".geom_type = 'Point'", output)
def test_modelform_widget_conformity(self):
class DummyForm(django.forms.ModelForm):
class Meta:
model = DummyModel
fields = ['geom']
widgets = {'geom': LeafletWidget()}
form = DummyForm()
output = form.as_p()
self.assertIn(".geom_type = 'Point'", output)


class LeafletGeoAdminMapTest(LeafletGeoAdminTest):
Expand Down
40 changes: 15 additions & 25 deletions quicktest.py
Expand Up @@ -5,6 +5,7 @@
import sys
import argparse
from django.conf import settings
from django.test.runner import DiscoverRunner
import django


Expand All @@ -29,26 +30,14 @@ class QuickDjangoTest(object):
'django.contrib.messages',
]

if django.VERSION >= (1, 8, 0):
TEMPLATES = {
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
]
},
'APP_DIRS': True,
}

def __init__(self, *args, **kwargs):
self.apps = kwargs.get('apps', [])
self.database= kwargs.get('db', 'sqlite')
self.run_tests()

def run_tests(self):
"""
Fire up the Django test suite developed for version 1.2
Fire up the Django test suite.
"""
if self.database == 'postgres':
databases = {
Expand Down Expand Up @@ -76,7 +65,17 @@ def run_tests(self):
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
]
],
'TEMPLATES': [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
]
},
'APP_DIRS': True,
}],
}
if 'SPATIALITE_LIBRARY_PATH' in os.environ:
# If you get SpatiaLite-related errors, refer to this document
Expand All @@ -87,19 +86,10 @@ def run_tests(self):
# Example for macOS (with spatialite-tools installed using brew):
# $ export SPATIALITE_LIBRARY_PATH='/usr/local/lib/mod_spatialite.dylib'
conf['SPATIALITE_LIBRARY_PATH'] = os.getenv('SPATIALITE_LIBRARY_PATH')
if django.VERSION >= (1, 8, 0):
conf['TEMPLATES'] = self.TEMPLATES,
settings.configure(**conf)
if django.VERSION >= (1, 7, 0):
# see: https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
django.setup()
if django.VERSION >= (1, 6, 0):
# see: https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module
from django.test.runner import DiscoverRunner as Runner
else:
from django.test.simple import DjangoTestSuiteRunner as Runner
django.setup()

failures = Runner().run_tests(self.apps, verbosity=1)
failures = DiscoverRunner().run_tests(self.apps, verbosity=1)
if failures: # pragma: no cover
sys.exit(failures)

Expand Down
3 changes: 0 additions & 3 deletions setup.py
@@ -1,7 +1,6 @@

import os
from setuptools import setup, find_packages
import sys
import codecs

here = os.path.abspath(os.path.dirname(__file__))
Expand All @@ -10,8 +9,6 @@
'Django',
'six',
]
if sys.version_info < (2, 7):
requires += ['ordereddict']

setup(
name='django-leaflet',
Expand Down
9 changes: 0 additions & 9 deletions tox.ini
@@ -1,8 +1,5 @@
[tox]
envlist =
{py27,py33,py34,py35}-django18,
{py27,py34,py35}-django19,
{py27,py34,py35}-django110,
{py27,py34,py35,py36,py37}-django111,
{py34,py35,py36,py37}-django20,
{py35,py36,py37}-django21,
Expand All @@ -13,9 +10,6 @@ envlist =
[testenv]
commands = coverage run ./quicktest.py leaflet --db={env:DATABASE:}
deps =
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
Expand All @@ -29,9 +23,6 @@ passenv = DATABASE SPATIALITE_LIBRARY_PATH

[travis:env]
DJANGO =
1.8: django18
1.9: django19
1.10: django110
1.11: django111
2.0: django20
2.1: django21
Expand Down

0 comments on commit 79abf05

Please sign in to comment.