enchant the docs -- adds spell checking
This commit is contained in:
parent
bc9601b3d3
commit
4dacbdf283
|
@ -1,6 +1,7 @@
|
|||
language: python
|
||||
sudo: false
|
||||
cache:
|
||||
- apt
|
||||
- pip
|
||||
services:
|
||||
- memcached
|
||||
|
@ -8,6 +9,12 @@ python:
|
|||
- "2.7"
|
||||
- "3.4"
|
||||
- "3.5"
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- python3-enchant
|
||||
- python2-enchant
|
||||
- graphviz
|
||||
env:
|
||||
global:
|
||||
- DISPLAY=:99.0
|
||||
|
@ -31,6 +38,7 @@ script:
|
|||
- isort --check-only --recursive --diff .
|
||||
- flake8 --jobs=2 .
|
||||
- pep257 --explain --source --count django_select2
|
||||
- (cd docs; make spelling)
|
||||
- coverage run --source=django_select2 -m py.test
|
||||
after_success:
|
||||
- coveralls
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Shared memory across multiple machines to the heavy ajax lookups.
|
||||
Shared memory across multiple machines to the heavy AJAX lookups.
|
||||
|
||||
Select2 uses django.core.cache_ to share fields across
|
||||
multiple threads and even machines.
|
||||
|
||||
Select2 uses the cabhe backend defind in the setting
|
||||
Select2 uses the cache backend defined in the setting
|
||||
``SELECT2_CACHE_BACKEND`` [default=``default``].
|
||||
|
||||
It is advised to always setup a separate cache server for Select2.
|
||||
|
|
|
@ -58,7 +58,7 @@ class Select2Conf(AppConf):
|
|||
SELECT2_JS = 'assets/js/select2.min.js'
|
||||
|
||||
.. tip:: Change this setting to a local asset in your development environment to
|
||||
develop without an internet connection.
|
||||
develop without an Internet connection.
|
||||
"""
|
||||
|
||||
CSS = '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css'
|
||||
|
@ -71,7 +71,7 @@ class Select2Conf(AppConf):
|
|||
SELECT2_CSS = 'assets/css/select2.css'
|
||||
|
||||
.. tip:: Change this setting to a local asset in your development environment to
|
||||
develop without an internet connection.
|
||||
develop without an Internet connection.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -190,13 +190,13 @@ class HeavySelect2Mixin(object):
|
|||
super(HeavySelect2Mixin, self).__init__(**kwargs)
|
||||
|
||||
def get_url(self):
|
||||
"""Return url from instance or by reversing :attr:`.data_view`."""
|
||||
"""Return URL from instance or by reversing :attr:`.data_view`."""
|
||||
if self.data_url:
|
||||
return self.data_url
|
||||
return reverse(self.data_view)
|
||||
|
||||
def build_attrs(self, extra_attrs=None, **kwargs):
|
||||
"""Set select2's ajax attributes."""
|
||||
"""Set select2's AJAX attributes."""
|
||||
attrs = super(HeavySelect2Mixin, self).build_attrs(extra_attrs=extra_attrs, **kwargs)
|
||||
|
||||
# encrypt instance Id
|
||||
|
@ -221,7 +221,7 @@ class HeavySelect2Mixin(object):
|
|||
return "%s%s" % (settings.SELECT2_CACHE_PREFIX, id(self))
|
||||
|
||||
def set_to_cache(self):
|
||||
"""Add widget object to Djnago's cache."""
|
||||
"""Add widget object to Django's cache."""
|
||||
cache.set(self._get_cache_key(), {
|
||||
'widget': self,
|
||||
'url': self.get_url(),
|
||||
|
@ -283,7 +283,7 @@ class ModelSelect2Mixin(object):
|
|||
queryset = None
|
||||
search_fields = []
|
||||
"""
|
||||
Model lookups that are used to filter the queryset.
|
||||
Model lookups that are used to filter the QuerySet.
|
||||
|
||||
Example::
|
||||
|
||||
|
@ -317,9 +317,9 @@ class ModelSelect2Mixin(object):
|
|||
|
||||
def set_to_cache(self):
|
||||
"""
|
||||
Add widget's attributes to Djnago's cache.
|
||||
Add widget's attributes to Django's cache.
|
||||
|
||||
Split the queryset, to not pickle the result set.
|
||||
Split the QuerySet, to not pickle the result set.
|
||||
"""
|
||||
queryset = self.get_queryset()
|
||||
cache.set(self._get_cache_key(), {
|
||||
|
@ -385,7 +385,7 @@ class ModelSelect2Mixin(object):
|
|||
raise NotImplementedError('%s, must implement "search_fields".' % self.__class__.__name__)
|
||||
|
||||
def render_options(self, choices, selected_choices):
|
||||
"""Render only selected options and set queryset from :class:`ModelChoicesIterator`."""
|
||||
"""Render only selected options and set QuerySet from :class:`ModelChoicesIterator`."""
|
||||
output = ['<option></option>' if not self.is_required else '']
|
||||
if isinstance(self.choices, ModelChoiceIterator):
|
||||
if not self.queryset:
|
||||
|
@ -454,8 +454,8 @@ class ModelSelect2Widget(ModelSelect2Mixin, HeavySelect2Widget):
|
|||
)
|
||||
|
||||
.. tip:: The ModelSelect2(Multiple)Widget will try
|
||||
to get the queryset from the fields choices.
|
||||
Therefore you don't need to define a queryset,
|
||||
to get the QuerySet from the fields choices.
|
||||
Therefore you don't need to define a QuerySet,
|
||||
if you just drop in the widget for a ForeignKey field.
|
||||
"""
|
||||
|
||||
|
@ -478,7 +478,7 @@ class ModelSelect2TagWidget(ModelSelect2Mixin, HeavySelect2TagWidget):
|
|||
|
||||
This it not a simple drop in widget.
|
||||
It requires to implement you own :func:`.value_from_datadict`
|
||||
that adds missing tags to you queryset.
|
||||
that adds missing tags to you QuerySet.
|
||||
|
||||
Example::
|
||||
|
||||
|
@ -487,10 +487,10 @@ class ModelSelect2TagWidget(ModelSelect2Mixin, HeavySelect2TagWidget):
|
|||
|
||||
def value_from_datadict(self, data, files, name):
|
||||
values = super().value_from_datadict(self, data, files, name)
|
||||
queryset = self.get_queryset()
|
||||
pks = queryset.filter(**{'pk__in': list(values)}).values_list('pk', flat=True)
|
||||
qs = self.queryset.filter(**{'pk__in': list(values)})
|
||||
pks = set(force_text(getattr(o, pk)) for o in qs)
|
||||
cleaned_values = []
|
||||
for val in values:
|
||||
for val in value:
|
||||
if force_text(val) not in pks:
|
||||
val = queryset.create(title=val).pk
|
||||
cleaned_values.append(val)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Django-Select2 url config.
|
||||
Django-Select2 URL configuration.
|
||||
|
||||
Add `django_select` to your urlconf **if** you use any 'Model' fields::
|
||||
Add `django_select` to your ``urlconf`` **if** you use any 'Model' fields::
|
||||
|
||||
url(r'^select2/', include('django_select2.urls')),
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class AutoResponseView(BaseListView):
|
|||
})
|
||||
|
||||
def get_queryset(self):
|
||||
"""Get queryset from cached widget."""
|
||||
"""Get QuerySet from cached widget."""
|
||||
return self.widget.filter_queryset(self.term, self.queryset)
|
||||
|
||||
def get_paginate_by(self, queryset):
|
||||
|
|
|
@ -46,6 +46,11 @@ html:
|
|||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
spelling:
|
||||
$(SPHINXBUILD) -b spelling -W $(ALLSPHINXOPTS) $(BUILDDIR)/spelling
|
||||
@echo
|
||||
@echo "Spell check finished. The results are in $(BUILDDIR)/spelling."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
|
|
|
@ -47,6 +47,7 @@ extensions = [
|
|||
'sphinx.ext.inheritance_diagram',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.viewcode',
|
||||
'sphinxcontrib.spelling',
|
||||
]
|
||||
|
||||
intersphinx_mapping = {
|
||||
|
@ -55,6 +56,11 @@ intersphinx_mapping = {
|
|||
'https://docs.djangoproject.com/en/dev/_objects/'),
|
||||
}
|
||||
|
||||
# spell check
|
||||
spelling_word_list_filename = 'spelling_wordlist.txt'
|
||||
spelling_show_suggestions = True
|
||||
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ DjangoSelect2 handles the initialization of select2 fields automatically. Just i
|
|||
``{{ form.media.js }}`` in your template before the closing ``body`` tag. That's it!
|
||||
|
||||
If you insert forms after page load or if you want to handle the initialization
|
||||
yourself, DjangoSelect2 provides a jQuery-Plugin. It will handle both normal and
|
||||
yourself, DjangoSelect2 provides a jQuery plugin. It will handle both normal and
|
||||
heavy fields. Simply call ``djangoSelect2(options)`` on your select fields.::
|
||||
|
||||
$('.django-select2').djangoSelect2();
|
||||
|
|
|
@ -18,7 +18,7 @@ Installation
|
|||
2. Add ``django_select2`` to your ``INSTALLED_APPS`` in your project settings.
|
||||
|
||||
|
||||
3. Add ``django_select`` to your urlconf **if** you use any
|
||||
3. Add ``django_select`` to your ``urlconf`` **if** you use any
|
||||
:class:`ModelWidgets <.django_select2.forms.ModelSelect2Mixin>`::
|
||||
|
||||
url(r'^select2/', include('django_select2.urls')),
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
jQuery
|
||||
Django
|
||||
mixin
|
||||
backend
|
||||
redis
|
||||
memcached
|
||||
AJAX
|
||||
Cloudflare
|
||||
lookup
|
||||
QuerySet
|
||||
pre
|
||||
py
|
||||
lookups
|
||||
functionalities
|
||||
plugin
|
||||
multi
|
||||
Indices
|
|
@ -7,3 +7,6 @@ pep257
|
|||
pytest
|
||||
pytest-django
|
||||
selenium
|
||||
sphinx
|
||||
sphinxcontrib-spelling
|
||||
pyenchant
|
|
@ -4,16 +4,28 @@
|
|||
#
|
||||
# pip-compile requirements_dev.in
|
||||
#
|
||||
alabaster==0.7.7 # via sphinx
|
||||
babel==2.2.0 # via sphinx
|
||||
django-appconf==1.0.1
|
||||
flake8==2.5.0
|
||||
docutils==0.12 # via sphinx
|
||||
flake8==2.5.2
|
||||
isort==4.2.2
|
||||
mccabe==0.3.1
|
||||
Jinja2==2.8
|
||||
MarkupSafe==0.23
|
||||
mccabe==0.4.0
|
||||
pep257==0.7.0
|
||||
pep8-naming==0.3.3
|
||||
pep8==1.5.7 # via flake8
|
||||
pep8==1.7.0 # via flake8
|
||||
py==1.4.31 # via pytest
|
||||
pyenchant==1.6.6
|
||||
pyflakes==1.0.0 # via flake8
|
||||
Pygments==2.1
|
||||
pytest-django==2.9.1
|
||||
pytest==2.8.3
|
||||
selenium==2.48.0
|
||||
six==1.10.0 # via django-appconf
|
||||
pytest==2.8.7
|
||||
pytz==2015.7 # via babel
|
||||
selenium==2.50.1
|
||||
six==1.10.0 # via django-appconf, sphinx, sphinxcontrib-spelling
|
||||
snowballstemmer==1.2.1 # via sphinx
|
||||
sphinx-rtd-theme==0.1.9 # via sphinx
|
||||
sphinx==1.3.5
|
||||
sphinxcontrib-spelling==2.1.2
|
||||
|
|
Loading…
Reference in New Issue