Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6eaa26c16 | ||
|
|
73d4be8992 | ||
|
|
e1d42bfcad | ||
|
|
1954bf57fa | ||
|
|
08ca1c1c36 |
+2
-8
@@ -1,15 +1,13 @@
|
||||
language: python
|
||||
sudo: false
|
||||
dist: trusty
|
||||
cache:
|
||||
- apt
|
||||
- pip
|
||||
services:
|
||||
- redis
|
||||
addons:
|
||||
chrome: stable
|
||||
apt:
|
||||
packages:
|
||||
- chromium-chromedriver
|
||||
- python3-enchant
|
||||
- python-enchant
|
||||
- graphviz
|
||||
@@ -30,11 +28,7 @@ install:
|
||||
- pip install --upgrade pip tox
|
||||
- pip install -U codecov
|
||||
before_script:
|
||||
- mkdir bin
|
||||
- export CHROME_DRIVER_VERSION=`curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE`
|
||||
- curl -O https://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip
|
||||
- unzip chromedriver_linux64.zip -d bin
|
||||
- PATH=$PATH:$PWD/bin
|
||||
- ln -s /usr/lib/chromium-browser/chromedriver ~/bin/chromedriver
|
||||
- nvm install --lts
|
||||
- npm install -g standard
|
||||
- |
|
||||
|
||||
@@ -7,6 +7,10 @@ This is a `Django`_ integration of `Select2`_.
|
||||
|
||||
The app includes Select2 driven Django Widgets.
|
||||
|
||||
.. note::
|
||||
Django's admin comes with builtin support for Select2
|
||||
since version 2.0 via the `autocomplete_fields`_ feature.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
@@ -51,6 +55,7 @@ See `Github releases`_
|
||||
|
||||
.. _Django: https://www.djangoproject.com/
|
||||
.. _Select2: http://ivaynberg.github.com/select2/
|
||||
.. _autocomplete_fields: https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields
|
||||
.. _CHANGELOG.md: CHANGELOG.md
|
||||
.. _Github releases: https://github.com/applegrew/django-select2/releases
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ __all__ = ('settings', 'Select2Conf')
|
||||
class Select2Conf(AppConf):
|
||||
"""Settings for Django-Select2."""
|
||||
|
||||
LIB_VERSION = '4.0.5'
|
||||
"""Version of the Select2 library."""
|
||||
|
||||
CACHE_BACKEND = 'default'
|
||||
"""
|
||||
Django-Select2 uses Django's cache to sure a consistent state across multiple machines.
|
||||
@@ -53,7 +56,7 @@ class Select2Conf(AppConf):
|
||||
It has set `select2_` as a default value, which you can change if needed.
|
||||
"""
|
||||
|
||||
JS = '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js'
|
||||
JS = '//cdnjs.cloudflare.com/ajax/libs/select2/{version}/js/select2.min.js'.format(version=LIB_VERSION)
|
||||
"""
|
||||
The URI for the Select2 JS file. By default this points to the Cloudflare CDN.
|
||||
|
||||
@@ -71,7 +74,7 @@ class Select2Conf(AppConf):
|
||||
develop without an Internet connection.
|
||||
"""
|
||||
|
||||
CSS = '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css'
|
||||
CSS = '//cdnjs.cloudflare.com/ajax/libs/select2/{version}/css/select2.min.css'.format(version=LIB_VERSION)
|
||||
"""
|
||||
The URI for the Select2 CSS file. By default this points to the Cloudflare CDN.
|
||||
|
||||
@@ -89,7 +92,7 @@ class Select2Conf(AppConf):
|
||||
develop without an Internet connection.
|
||||
"""
|
||||
|
||||
I18N_PATH = '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/i18n'
|
||||
I18N_PATH = '//cdnjs.cloudflare.com/ajax/libs/select2/{version}/js/i18n'.format(version=LIB_VERSION)
|
||||
"""
|
||||
The base URI for the Select2 i18n files. By default this points to the Cloudflare CDN.
|
||||
|
||||
|
||||
+14
-13
@@ -14,6 +14,7 @@ from selenium.webdriver.support import expected_conditions
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
from django_select2.cache import cache
|
||||
from django_select2.conf import settings
|
||||
from django_select2.forms import (
|
||||
HeavySelect2MultipleWidget, HeavySelect2Widget, ModelSelect2TagWidget,
|
||||
ModelSelect2Widget, Select2Widget
|
||||
@@ -104,28 +105,28 @@ class TestSelect2Mixin(object):
|
||||
def test_i18n(self):
|
||||
translation.activate('de')
|
||||
assert tuple(Select2Widget().media._js) == (
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js',
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/i18n/de.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/select2.min.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/i18n/de.js',
|
||||
'django_select2/django_select2.js'
|
||||
)
|
||||
|
||||
translation.activate('en')
|
||||
assert tuple(Select2Widget().media._js) == (
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js',
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/i18n/en.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/select2.min.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/i18n/en.js',
|
||||
'django_select2/django_select2.js'
|
||||
)
|
||||
|
||||
translation.activate('00')
|
||||
assert tuple(Select2Widget().media._js) == (
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/select2.min.js',
|
||||
'django_select2/django_select2.js'
|
||||
)
|
||||
|
||||
translation.activate('sr-cyrl')
|
||||
assert tuple(Select2Widget().media._js) == (
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js',
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/i18n/sr-Cyrl.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/select2.min.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/i18n/sr-Cyrl.js',
|
||||
'django_select2/django_select2.js'
|
||||
)
|
||||
|
||||
@@ -133,15 +134,15 @@ class TestSelect2Mixin(object):
|
||||
|
||||
translation.activate('zh-hans')
|
||||
assert tuple(Select2Widget().media._js) == (
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js',
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/i18n/zh-CN.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/select2.min.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/i18n/zh-CN.js',
|
||||
'django_select2/django_select2.js'
|
||||
)
|
||||
|
||||
translation.activate('zh-hant')
|
||||
assert tuple(Select2Widget().media._js) == (
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js',
|
||||
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/i18n/zh-TW.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/select2.min.js',
|
||||
f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/i18n/zh-TW.js',
|
||||
'django_select2/django_select2.js'
|
||||
)
|
||||
|
||||
@@ -150,8 +151,8 @@ class TestSelect2MixinSettings(object):
|
||||
def test_default_media(self):
|
||||
sut = Select2Widget()
|
||||
result = sut.media.render()
|
||||
assert '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js' in result
|
||||
assert '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css' in result
|
||||
assert f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/js/select2.min.js' in result
|
||||
assert f'//cdnjs.cloudflare.com/ajax/libs/select2/{settings.SELECT2_LIB_VERSION}/css/select2.min.css' in result
|
||||
assert 'django_select2/django_select2.js' in result
|
||||
|
||||
def test_js_setting(self, settings):
|
||||
|
||||
Reference in New Issue
Block a user