Skip to content

Commit 160ad7e

Browse files
authored
fix: Relect template block structure of Django 5.2+ (#1523)
* fix: Relect template block structure of Django 5.2+ * fix isort * Update docs generation * Only use new template for django >= 5.2 * fix sourcery comment * fix action buttons * Align icons
1 parent 7aa9b13 commit 160ad7e

File tree

15 files changed

+405
-155
lines changed

15 files changed

+405
-155
lines changed

docs/conf.py

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import sys
1616

1717

18-
sys.path.append(os.path.abspath('../'))
18+
sys.path.append(os.path.abspath("../"))
1919

2020
from filer import __version__ # NOQA
2121

@@ -33,38 +33,38 @@
3333
# Add any Sphinx extension module names here, as strings. They can be extensions
3434
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
3535
extensions = [
36-
'sphinx.ext.autodoc',
37-
'sphinx.ext.doctest',
38-
'sphinx.ext.intersphinx',
39-
'sphinx.ext.todo',
40-
'sphinxcontrib.spelling',
36+
"sphinx.ext.autodoc",
37+
"sphinx.ext.doctest",
38+
"sphinx.ext.intersphinx",
39+
"sphinx.ext.todo",
40+
"sphinxcontrib.spelling",
4141
"sphinx_copybutton",
4242
"sphinxext.opengraph",
43-
'sphinxcontrib.images',
43+
"sphinxcontrib.images",
4444
]
4545

4646
# Add any paths that contain templates here, relative to this directory.
47-
templates_path = ['_templates']
47+
templates_path = ["_templates"]
4848

4949
# The suffix of source filenames.
50-
source_suffix = '.rst'
50+
source_suffix = ".rst"
5151

5252
# The encoding of source files.
5353
# source_encoding = 'utf-8-sig'
5454

5555
# The master toctree document.
56-
master_doc = 'index'
56+
master_doc = "index"
5757

5858
# General information about the project.
59-
project = 'django-filer'
60-
copyright = '%s, Stefan Foulis' % (datetime.date.today().year,)
59+
project = "django-filer"
60+
copyright = "%s, Stefan Foulis" % (datetime.date.today().year,)
6161

6262
# The version info for the project you're documenting, acts as replacement for
6363
# |version| and |release|, also used in various other places throughout the
6464
# built documents.
6565
#
6666
# The short X.Y version.
67-
version = '.'.join(__version__.split('.')[0:2])
67+
version = ".".join(__version__.split(".")[:2])
6868
# The full version, including alpha/beta/rc tags.
6969
release = __version__
7070

@@ -80,7 +80,7 @@
8080

8181
# List of patterns, relative to source directory, that match files and
8282
# directories to ignore when looking for source files.
83-
exclude_patterns = ['_build', '_images', 'README.rst']
83+
exclude_patterns = ["_build", "_images", "README.rst"]
8484

8585
# The reST default role (used for this markup: `text`) to use for all documents.
8686
# default_role = None
@@ -97,7 +97,7 @@
9797
# show_authors = False
9898

9999
# The name of the Pygments (syntax highlighting) style to use.
100-
pygments_style = 'sphinx'
100+
pygments_style = "sphinx"
101101

102102
# A list of ignored prefixes for module index sorting.
103103
# modindex_common_prefix = []
@@ -107,7 +107,7 @@
107107

108108
# The theme to use for HTML and HTML Help pages. See the documentation for
109109
# a list of builtin themes.
110-
html_theme = 'furo'
110+
html_theme = "furo"
111111

112112
# Theme options are theme-specific and customize the look and feel of a theme
113113
# further. For a list of options available for each theme, see the
@@ -138,7 +138,7 @@
138138
# Add any paths that contain custom static files (such as style sheets) here,
139139
# relative to this directory. They are copied after the builtin static files,
140140
# so a file named "default.css" will overwrite the builtin "default.css".
141-
html_static_path = ['_static']
141+
html_static_path = ["_static"]
142142

143143
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
144144
# using the given strftime format.
@@ -182,7 +182,7 @@
182182
# html_file_suffix = ''
183183

184184
# Output file base name for HTML help builder.
185-
htmlhelp_basename = 'django-filerdoc'
185+
htmlhelp_basename = "django-filerdoc"
186186

187187

188188
# -- Options for LaTeX output --------------------------------------------------
@@ -196,7 +196,13 @@
196196
# Grouping the document tree into LaTeX files. List of tuples
197197
# (source start file, target name, title, author, documentclass [howto/manual]).
198198
latex_documents = [
199-
('index', 'django-filer.tex', 'django-filer Documentation', 'Stefan Foulis', 'manual'),
199+
(
200+
"index",
201+
"django-filer.tex",
202+
"django-filer Documentation",
203+
"Stefan Foulis",
204+
"manual",
205+
),
200206
]
201207

202208
# The name of an image file (relative to this directory) to place at the top of
@@ -228,13 +234,19 @@
228234
# One entry per manual page. List of tuples
229235
# (source start file, name, description, authors, manual section).
230236
man_pages = [
231-
('index', 'django-filer', 'django-filer Documentation', ['Stefan Foulis'], 1)
237+
("index", "django-filer", "django-filer Documentation", ["Stefan Foulis"], 1)
232238
]
233239

234240

235241
# Example configuration for intersphinx: refer to the Python standard library.
236-
intersphinx_mapping = {'http://docs.python.org/': None}
242+
intersphinx_mapping = {
243+
"python": ("https://docs.python.org/3", None),
244+
"django": (
245+
"https://docs.djangoproject.com/en/stable/",
246+
"https://docs.djangoproject.com/en/stable/objects.inv",
247+
),
248+
}
237249

238250
images_config = {
239-
'override_image_directive': True,
251+
"override_image_directive": True,
240252
}

docs/requirements.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
django>=4.2,<5
2+
furo
3+
restructuredtext-lint
4+
sphinx<8
5+
sphinx-autobuild
6+
sphinx-copybutton
7+
sphinxcontrib-images
8+
sphinxcontrib-spelling
9+
sphinxcontrib-inlinesyntaxhighlight
10+
sphinxext-opengraph
11+
pip-tools

docs/requirements.txt

Lines changed: 61 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,80 @@
11
#
2-
# This file is autogenerated by pip-compile with python 3.9
3-
# To update, run:
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
44
#
5-
# pip-compile requirements.txt
5+
# pip-compile --output-file=requirements.txt requirements.in
66
#
7+
--extra-index-url https://www.piwheels.org/simple
8+
79
alabaster==0.7.12
8-
# via
9-
# -r requirements.txt
10-
# sphinx
11-
asgiref==3.5.0
12-
# via
13-
# -r requirements.txt
14-
# django
10+
# via sphinx
11+
asgiref==3.8.1
12+
# via django
1513
babel==2.9.1
16-
# via
17-
# -r requirements.txt
18-
# sphinx
14+
# via sphinx
1915
beautifulsoup4==4.10.0
20-
# via
21-
# -r requirements.txt
22-
# furo
16+
# via furo
17+
build==1.2.2.post1
18+
# via pip-tools
2319
certifi==2021.10.8
24-
# via
25-
# -r requirements.txt
26-
# requests
20+
# via requests
2721
charset-normalizer==2.0.12
28-
# via
29-
# -r requirements.txt
30-
# requests
22+
# via requests
23+
click==8.1.8
24+
# via pip-tools
3125
colorama==0.4.4
32-
# via
33-
# -r requirements.txt
34-
# sphinx-autobuild
35-
django==3.2.12
36-
# via -r requirements.txt
26+
# via sphinx-autobuild
27+
django==4.2.20
28+
# via -r requirements.in
3729
docutils==0.17.1
3830
# via
39-
# -r requirements.txt
4031
# restructuredtext-lint
4132
# sphinx
4233
furo==2021.6.24b37
43-
# via -r requirements.txt
34+
# via -r requirements.in
4435
idna==3.3
45-
# via
46-
# -r requirements.txt
47-
# requests
36+
# via requests
4837
imagesize==1.3.0
49-
# via
50-
# -r requirements.txt
51-
# sphinx
52-
importlib-metadata==4.11.0
53-
# via
54-
# -r requirements.txt
55-
# sphinx
38+
# via sphinx
5639
jinja2==3.0.3
57-
# via
58-
# -r requirements.txt
59-
# sphinx
40+
# via sphinx
6041
livereload==2.6.3
61-
# via
62-
# -r requirements.txt
63-
# sphinx-autobuild
42+
# via sphinx-autobuild
6443
markupsafe==2.0.1
65-
# via
66-
# -r requirements.txt
67-
# jinja2
44+
# via jinja2
6845
packaging==21.3
6946
# via
70-
# -r requirements.txt
47+
# build
7148
# sphinx
49+
pip-tools==7.4.1
50+
# via -r requirements.in
7251
pyenchant==3.2.2
73-
# via
74-
# -r requirements.txt
75-
# sphinxcontrib-spelling
52+
# via sphinxcontrib-spelling
7653
pygments==2.11.2
77-
# via
78-
# -r requirements.txt
79-
# sphinx
54+
# via sphinx
8055
pyparsing==3.0.7
56+
# via packaging
57+
pyproject-hooks==1.2.0
8158
# via
82-
# -r requirements.txt
83-
# packaging
59+
# build
60+
# pip-tools
8461
pytz==2021.3
85-
# via
86-
# -r requirements.txt
87-
# babel
88-
# django
62+
# via babel
8963
requests==2.27.1
9064
# via
91-
# -r requirements.txt
9265
# sphinx
9366
# sphinxcontrib-images
9467
restructuredtext-lint==1.3.2
95-
# via -r requirements.txt
68+
# via -r requirements.in
9669
six==1.16.0
97-
# via
98-
# -r requirements.txt
99-
# livereload
70+
# via livereload
10071
snowballstemmer==2.2.0
101-
# via
102-
# -r requirements.txt
103-
# sphinx
72+
# via sphinx
10473
soupsieve==2.3.1
105-
# via
106-
# -r requirements.txt
107-
# beautifulsoup4
74+
# via beautifulsoup4
10875
sphinx==4.4.0
10976
# via
110-
# -r requirements.txt
77+
# -r requirements.in
11178
# furo
11279
# sphinx-autobuild
11380
# sphinx-copybutton
@@ -116,54 +83,38 @@ sphinx==4.4.0
11683
# sphinxcontrib-spelling
11784
# sphinxext-opengraph
11885
sphinx-autobuild==2021.3.14
119-
# via -r requirements.txt
86+
# via -r requirements.in
12087
sphinx-copybutton==0.5.0
121-
# via -r requirements.txt
88+
# via -r requirements.in
12289
sphinxcontrib-applehelp==1.0.2
123-
# via
124-
# -r requirements.txt
125-
# sphinx
90+
# via sphinx
12691
sphinxcontrib-devhelp==1.0.2
127-
# via
128-
# -r requirements.txt
129-
# sphinx
92+
# via sphinx
13093
sphinxcontrib-htmlhelp==2.0.0
131-
# via
132-
# -r requirements.txt
133-
# sphinx
94+
# via sphinx
13495
sphinxcontrib-images==0.9.4
135-
# via -r requirements.txt
96+
# via -r requirements.in
13697
sphinxcontrib-inlinesyntaxhighlight==0.2
137-
# via -r requirements.txt
98+
# via -r requirements.in
13899
sphinxcontrib-jsmath==1.0.1
139-
# via
140-
# -r requirements.txt
141-
# sphinx
100+
# via sphinx
142101
sphinxcontrib-qthelp==1.0.3
143-
# via
144-
# -r requirements.txt
145-
# sphinx
102+
# via sphinx
146103
sphinxcontrib-serializinghtml==1.1.5
147-
# via
148-
# -r requirements.txt
149-
# sphinx
104+
# via sphinx
150105
sphinxcontrib-spelling==7.3.2
151-
# via -r requirements.txt
106+
# via -r requirements.in
152107
sphinxext-opengraph==0.5.1
153-
# via -r requirements.txt
108+
# via -r requirements.in
154109
sqlparse==0.4.2
155-
# via
156-
# -r requirements.txt
157-
# django
110+
# via django
158111
tornado==6.1
159-
# via
160-
# -r requirements.txt
161-
# livereload
112+
# via livereload
162113
urllib3==1.26.8
163-
# via
164-
# -r requirements.txt
165-
# requests
166-
zipp==3.7.0
167-
# via
168-
# -r requirements.txt
169-
# importlib-metadata
114+
# via requests
115+
wheel==0.45.1
116+
# via pip-tools
117+
118+
# The following packages are considered to be unsafe in a requirements file:
119+
# pip
120+
# setuptools

filer/admin/folderadmin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ class FolderAdmin(PrimitivePermissionAwareModelAdmin):
7171
actions = ['delete_files_or_folders', 'move_files_and_folders',
7272
'copy_files_and_folders', 'resize_images', 'rename_files']
7373

74-
directory_listing_template = 'admin/filer/folder/directory_listing.html'
74+
if DJANGO_VERSION >= (5, 2):
75+
directory_listing_template = 'admin/filer/folder/directory_listing.html'
76+
else: # Remove this when Django 5.2 is the minimum version
77+
directory_listing_template = 'admin/filer/folder/legacy_listing.html'
78+
7579
order_by_file_fields = ['_file_size', 'original_filename', 'name', 'owner',
7680
'uploaded_at', 'modified_at']
7781

0 commit comments

Comments
 (0)