Skip to content

Commit 5fc33eb

Browse files
committed
fix
1 parent 2281dc1 commit 5fc33eb

File tree

13 files changed

+85
-80
lines changed

13 files changed

+85
-80
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
python-version: [ "3.9", "3.10", "3.11"]
28-
django-version: [ "3.2", "4.2"]
27+
python-version: [ "3.9", "3.10", "3.11", "3.12, "3.13"]
28+
django-version: [ "3.2", "4.2", "5.1"]
2929
env:
3030
PY_VER: ${{ matrix.python-version}}
3131
DJ_VER: ${{ matrix.django-version}}

.travis.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,6 @@ dist: bionic
44

55
matrix:
66
fast_finish: true
7-
include:
8-
- { python: "3.6", env: DJANGO=1.11 }
9-
- { python: "3.6", env: DJANGO=2.1 }
10-
- { python: "3.6", env: DJANGO=2.2 }
11-
- { python: "3.6", env: DJANGO=3.0 }
12-
13-
- { python: "3.7", env: DJANGO=1.11 }
14-
- { python: "3.7", env: DJANGO=2.1 }
15-
- { python: "3.7", env: DJANGO=2.2 }
16-
- { python: "3.7", env: DJANGO=3.0 }
17-
- { python: "3.7", env: DJANGO=master }
18-
19-
- { python: "3.8", env: DJANGO=2.2 }
20-
- { python: "3.8", env: DJANGO=3.0 }
21-
- { python: "3.8", env: DJANGO=master }
227

238
install:
249
- pip install tox tox-venv tox-travis pip wheel codecov -U

docs/conf.py

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,207 +12,210 @@
1212
# serve to show the default.
1313

1414
import datetime
15-
import sys, os
1615
import selectable
1716

1817
# If extensions (or modules to document with autodoc) are in another directory,
1918
# add these directories to sys.path here. If the directory is relative to the
2019
# documentation root, use os.path.abspath to make it absolute, like shown here.
21-
#sys.path.insert(0, os.path.abspath('.'))
20+
# sys.path.insert(0, os.path.abspath('.'))
2221

2322
# -- General configuration -----------------------------------------------------
2423

2524
# If your documentation needs a minimal Sphinx version, state it here.
26-
#needs_sphinx = '1.0'
25+
# needs_sphinx = '1.0'
2726

2827
# Add any Sphinx extension module names here, as strings. They can be extensions
2928
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
3029
extensions = []
3130

3231
# Add any paths that contain templates here, relative to this directory.
33-
templates_path = ['_templates']
32+
templates_path = ["_templates"]
3433

3534
# The suffix of source filenames.
36-
source_suffix = '.rst'
35+
source_suffix = ".rst"
3736

3837
# The encoding of source files.
39-
#source_encoding = 'utf-8-sig'
38+
# source_encoding = 'utf-8-sig'
4039

4140
# The master toctree document.
42-
master_doc = 'index'
41+
master_doc = "index"
4342

4443
# General information about the project.
45-
project = u'Django-Selectable'
46-
copyright = u'2011-%s, Mark Lavin' % datetime.date.today().year
44+
project = "Django-Selectable"
45+
copyright = "2011-%s, Mark Lavin" % datetime.date.today().year
4746

4847
# The version info for the project you're documenting, acts as replacement for
4948
# |version| and |release|, also used in various other places throughout the
5049
# built documents.
5150
#
5251
# The short X.Y version.
53-
version = '.'.join(selectable.__version__.split('.')[0:2])
52+
version = ".".join(selectable.__version__.split(".")[0:2])
5453
# The full version, including alpha/beta/rc tags.
5554
release = selectable.__version__
5655

5756
# The language for content autogenerated by Sphinx. Refer to documentation
5857
# for a list of supported languages.
59-
#language = None
58+
# language = None
6059

6160
# There are two options for replacing |today|: either, you set today to some
6261
# non-false value, then it is used:
63-
#today = ''
62+
# today = ''
6463
# Else, today_fmt is used as the format for a strftime call.
65-
#today_fmt = '%B %d, %Y'
64+
# today_fmt = '%B %d, %Y'
6665

6766
# List of patterns, relative to source directory, that match files and
6867
# directories to ignore when looking for source files.
69-
exclude_patterns = ['_build']
68+
exclude_patterns = ["_build"]
7069

7170
# The reST default role (used for this markup: `text`) to use for all documents.
72-
#default_role = None
71+
# default_role = None
7372

7473
# If true, '()' will be appended to :func: etc. cross-reference text.
75-
#add_function_parentheses = True
74+
# add_function_parentheses = True
7675

7776
# If true, the current module name will be prepended to all description
7877
# unit titles (such as .. function::).
79-
#add_module_names = True
78+
# add_module_names = True
8079

8180
# If true, sectionauthor and moduleauthor directives will be shown in the
8281
# output. They are ignored by default.
83-
#show_authors = False
82+
# show_authors = False
8483

8584
# The name of the Pygments (syntax highlighting) style to use.
86-
pygments_style = 'sphinx'
85+
pygments_style = "sphinx"
8786

8887
# A list of ignored prefixes for module index sorting.
89-
#modindex_common_prefix = []
88+
# modindex_common_prefix = []
9089

9190

9291
# -- Options for HTML output ---------------------------------------------------
9392

9493
# The theme to use for HTML and HTML Help pages. See the documentation for
9594
# a list of builtin themes.
96-
html_theme = 'default'
95+
html_theme = "default"
9796

9897
# Theme options are theme-specific and customize the look and feel of a theme
9998
# further. For a list of options available for each theme, see the
10099
# documentation.
101-
#html_theme_options = {}
100+
# html_theme_options = {}
102101

103102
# Add any paths that contain custom themes here, relative to this directory.
104-
#html_theme_path = []
103+
# html_theme_path = []
105104

106105
# The name for this set of Sphinx documents. If None, it defaults to
107106
# "<project> v<release> documentation".
108-
#html_title = None
107+
# html_title = None
109108

110109
# A shorter title for the navigation bar. Default is the same as html_title.
111-
#html_short_title = None
110+
# html_short_title = None
112111

113112
# The name of an image file (relative to this directory) to place at the top
114113
# of the sidebar.
115-
#html_logo = None
114+
# html_logo = None
116115

117116
# The name of an image file (within the static path) to use as favicon of the
118117
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
119118
# pixels large.
120-
#html_favicon = None
119+
# html_favicon = None
121120

122121
# Add any paths that contain custom static files (such as style sheets) here,
123122
# relative to this directory. They are copied after the builtin static files,
124123
# so a file named "default.css" will overwrite the builtin "default.css".
125-
#html_static_path = ['_static']
124+
# html_static_path = ['_static']
126125

127126
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
128127
# using the given strftime format.
129-
#html_last_updated_fmt = '%b %d, %Y'
128+
# html_last_updated_fmt = '%b %d, %Y'
130129

131130
# If true, SmartyPants will be used to convert quotes and dashes to
132131
# typographically correct entities.
133-
#html_use_smartypants = True
132+
# html_use_smartypants = True
134133

135134
# Custom sidebar templates, maps document names to template names.
136-
#html_sidebars = {}
135+
# html_sidebars = {}
137136

138137
# Additional templates that should be rendered to pages, maps page names to
139138
# template names.
140-
#html_additional_pages = {}
139+
# html_additional_pages = {}
141140

142141
# If false, no module index is generated.
143-
#html_domain_indices = True
142+
# html_domain_indices = True
144143

145144
# If false, no index is generated.
146-
#html_use_index = True
145+
# html_use_index = True
147146

148147
# If true, the index is split into individual pages for each letter.
149-
#html_split_index = False
148+
# html_split_index = False
150149

151150
# If true, links to the reST sources are added to the pages.
152-
#html_show_sourcelink = True
151+
# html_show_sourcelink = True
153152

154153
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
155-
#html_show_sphinx = True
154+
# html_show_sphinx = True
156155

157156
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
158-
#html_show_copyright = True
157+
# html_show_copyright = True
159158

160159
# If true, an OpenSearch description file will be output, and all pages will
161160
# contain a <link> tag referring to it. The value of this option must be the
162161
# base URL from which the finished HTML is served.
163-
#html_use_opensearch = ''
162+
# html_use_opensearch = ''
164163

165164
# This is the file name suffix for HTML files (e.g. ".xhtml").
166-
#html_file_suffix = None
165+
# html_file_suffix = None
167166

168167
# Output file base name for HTML help builder.
169-
htmlhelp_basename = 'Django-Selectabledoc'
168+
htmlhelp_basename = "Django-Selectabledoc"
170169

171170

172171
# -- Options for LaTeX output --------------------------------------------------
173172

174173
# The paper size ('letter' or 'a4').
175-
#latex_paper_size = 'letter'
174+
# latex_paper_size = 'letter'
176175

177176
# The font size ('10pt', '11pt' or '12pt').
178-
#latex_font_size = '10pt'
177+
# latex_font_size = '10pt'
179178

180179
# Grouping the document tree into LaTeX files. List of tuples
181180
# (source start file, target name, title, author, documentclass [howto/manual]).
182181
latex_documents = [
183-
('index', 'Django-Selectable.tex', u'Django-Selectable Documentation',
184-
u'Mark Lavin', 'manual'),
182+
(
183+
"index",
184+
"Django-Selectable.tex",
185+
"Django-Selectable Documentation",
186+
"Mark Lavin",
187+
"manual",
188+
),
185189
]
186190

187191
# The name of an image file (relative to this directory) to place at the top of
188192
# the title page.
189-
#latex_logo = None
193+
# latex_logo = None
190194

191195
# For "manual" documents, if this is true, then toplevel headings are parts,
192196
# not chapters.
193-
#latex_use_parts = False
197+
# latex_use_parts = False
194198

195199
# If true, show page references after internal links.
196-
#latex_show_pagerefs = False
200+
# latex_show_pagerefs = False
197201

198202
# If true, show URL addresses after external links.
199-
#latex_show_urls = False
203+
# latex_show_urls = False
200204

201205
# Additional stuff for the LaTeX preamble.
202-
#latex_preamble = ''
206+
# latex_preamble = ''
203207

204208
# Documents to append as an appendix to all manuals.
205-
#latex_appendices = []
209+
# latex_appendices = []
206210

207211
# If false, no module index is generated.
208-
#latex_domain_indices = True
212+
# latex_domain_indices = True
209213

210214

211215
# -- Options for manual page output --------------------------------------------
212216

213217
# One entry per manual page. List of tuples
214218
# (source start file, name, description, authors, manual section).
215219
man_pages = [
216-
('index', 'django-selectable', u'Django-Selectable Documentation',
217-
[u'Mark Lavin'], 1)
220+
("index", "django-selectable", "Django-Selectable Documentation", ["Mark Lavin"], 1)
218221
]

example/example/wsgi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
framework.
1414
1515
"""
16+
1617
import os
1718

1819
from django.core.wsgi import get_wsgi_application

selectable/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"Auto-complete selection widgets using Django and jQuery UI."
22

3-
43
__version__ = "1.4.0"
54

65
default_app_config = "selectable.apps.SelectableConfig"

selectable/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"Base classes for lookup creation."
2+
23
import operator
34
import re
45
from functools import reduce

selectable/decorators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"Decorators for additional lookup functionality."
2+
23
from functools import wraps
34

45
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden
@@ -43,7 +44,7 @@ def inner(self, request):
4344
@results_decorator
4445
def ajax_required(request):
4546
"Lookup decorator to require AJAX calls to the lookup view."
46-
if not request.is_ajax():
47+
if not request.headers.get("x-requested-with") == "XMLHttpRequest":
4748
return HttpResponseBadRequest()
4849

4950

selectable/forms/fields.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
from django.utils.translation import gettext_lazy as _
66

77
from selectable.forms.base import import_lookup_class
8-
from selectable.forms.widgets import AutoCompleteSelectMultipleWidget, AutoCompleteSelectWidget
8+
from selectable.forms.widgets import (
9+
AutoCompleteSelectMultipleWidget,
10+
AutoCompleteSelectWidget,
11+
)
912

1013
__all__ = (
1114
"AutoCompleteSelectField",

selectable/registry.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
from django.utils.module_loading import autodiscover_modules
33

44
from selectable.base import LookupBase
5-
from selectable.exceptions import LookupAlreadyRegistered, LookupInvalid, LookupNotRegistered
5+
from selectable.exceptions import (
6+
LookupAlreadyRegistered,
7+
LookupInvalid,
8+
LookupNotRegistered,
9+
)
610

711

812
class LookupRegistry:

selectable/tests/test_decorators.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ def setUp(self):
1616

1717
def test_ajax_call(self):
1818
"Ajax call should yield a successful response."
19-
request = Mock()
20-
request.is_ajax = lambda: True
19+
request = Mock(headers={"x-requested-with": "XMLHttpRequest"})
2120
response = self.lookup.results(request)
2221
self.assertTrue(response.status_code, 200)
2322

2423
def test_non_ajax_call(self):
2524
"Non-Ajax call should yield a bad request response."
2625
request = Mock()
27-
request.is_ajax = lambda: False
2826
response = self.lookup.results(request)
2927
self.assertEqual(response.status_code, 400)
3028

0 commit comments

Comments
 (0)