Skip to content

Commit 82cef8f

Browse files
committed
remove code for obsolete Django versions, remove support for Django 2.0
1 parent fc489a8 commit 82cef8f

File tree

4 files changed

+9
-84
lines changed

4 files changed

+9
-84
lines changed

categories/editor/settings.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""Settings management for the editor."""
2-
import django
32
from django.conf import settings
43

5-
DJANGO10_COMPAT = django.VERSION[0] < 1 or (django.VERSION[0] == 1 and django.VERSION[1] < 1)
6-
74
STATIC_URL = getattr(settings, "STATIC_URL", settings.MEDIA_URL)
85
if STATIC_URL is None:
96
STATIC_URL = settings.MEDIA_URL

categories/editor/templatetags/admin_tree_list_tags.py

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Template tags used to render the tree editor."""
2-
import django
32
from django.contrib.admin.templatetags.admin_list import _boolean_icon, result_headers
43
from django.contrib.admin.utils import lookup_field
54
from django.core.exceptions import ObjectDoesNotExist
@@ -44,9 +43,6 @@ def items_for_tree_result(cl, result, form):
4443
result_repr = get_empty_value_display(cl)
4544
else:
4645
if f is None:
47-
if django.VERSION[0] == 1 and django.VERSION[1] == 4:
48-
if field_name == "action_checkbox":
49-
row_class = ' class="action-checkbox disclosure"'
5046
allow_tags = getattr(attr, "allow_tags", False)
5147
boolean = getattr(attr, "boolean", False)
5248
if boolean:
@@ -69,25 +65,12 @@ def items_for_tree_result(cl, result, form):
6965
result_repr = display_for_field(value, f, "")
7066
if isinstance(f, models.DateField) or isinstance(f, models.TimeField):
7167
row_class = ' class="nowrap"'
72-
if first:
73-
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
74-
try:
75-
f, attr, checkbox_value = lookup_field("action_checkbox", result, cl.model_admin)
76-
if row_class:
77-
row_class = "%s%s" % (row_class[:-1], ' disclosure"')
78-
else:
79-
row_class = ' class="disclosure"'
80-
except (AttributeError, ObjectDoesNotExist):
81-
pass
8268

8369
if force_str(result_repr) == "":
8470
result_repr = mark_safe("&nbsp;")
8571
# If list_display_links not defined, add the link tag to the first field
8672
if (first and not cl.list_display_links) or field_name in cl.list_display_links:
87-
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
88-
table_tag = "td" # {True:'th', False:'td'}[first]
89-
else:
90-
table_tag = {True: "th", False: "td"}[first]
73+
table_tag = {True: "th", False: "td"}[first]
9174

9275
url = cl.url_for_result(result)
9376
# Convert the pk to something that can be used in Javascript.
@@ -165,13 +148,7 @@ def result_tree_list(cl):
165148
"""
166149
Displays the headers and data list together.
167150
"""
168-
import django
169-
170151
result = {"cl": cl, "result_headers": list(result_headers(cl)), "results": list(tree_results(cl))}
171-
if django.VERSION[0] == 1 and django.VERSION[1] > 2:
172-
from django.contrib.admin.templatetags.admin_list import result_hidden_fields
173-
174-
result["result_hidden_fields"] = list(result_hidden_fields(cl))
175152
return result
176153

177154

categories/editor/tree_editor.py

+4-52
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ class TreeChangeList(ChangeList):
8080
"""A change list for a tree."""
8181

8282
def _get_default_ordering(self):
83-
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
84-
return "", "" # ('tree_id', 'lft')
85-
else:
86-
return []
83+
return []
8784

8885
def get_ordering(self, request=None, queryset=None):
8986
"""
@@ -98,10 +95,7 @@ def get_ordering(self, request=None, queryset=None):
9895
Returns:
9996
Either a tuple of empty strings or an empty list.
10097
"""
101-
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
102-
return "", "" # ('tree_id', 'lft')
103-
else:
104-
return []
98+
return []
10599

106100
def get_queryset(self, *args, **kwargs):
107101
"""Return a queryset."""
@@ -170,36 +164,7 @@ def old_changelist_view(self, request, extra_context=None):
170164
pass
171165

172166
try:
173-
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
174-
params = (
175-
request,
176-
self.model,
177-
list_display,
178-
self.list_display_links,
179-
self.list_filter,
180-
self.date_hierarchy,
181-
self.search_fields,
182-
self.list_select_related,
183-
self.list_per_page,
184-
self.list_editable,
185-
self,
186-
)
187-
elif django.VERSION[0] == 1 or (django.VERSION[0] == 2 and django.VERSION[1] < 1):
188-
params = (
189-
request,
190-
self.model,
191-
list_display,
192-
self.list_display_links,
193-
self.list_filter,
194-
self.date_hierarchy,
195-
self.search_fields,
196-
self.list_select_related,
197-
self.list_per_page,
198-
self.list_max_show_all,
199-
self.list_editable,
200-
self,
201-
)
202-
elif django.VERSION < (4, 0):
167+
if django.VERSION < (4, 0):
203168
params = (
204169
request,
205170
self.model,
@@ -314,20 +279,7 @@ def old_changelist_view(self, request, extra_context=None):
314279
"actions_on_top": self.actions_on_top,
315280
"actions_on_bottom": self.actions_on_bottom,
316281
}
317-
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
318-
context["root_path"] = self.admin_site.root_path
319-
elif django.VERSION[0] == 1 or (django.VERSION[0] == 2 and django.VERSION[1] < 1):
320-
selection_note_all = ngettext("%(total_count)s selected", "All %(total_count)s selected", cl.result_count)
321-
322-
context.update(
323-
{
324-
"module_name": force_str(opts.verbose_name_plural),
325-
"selection_note": _("0 of %(cnt)s selected") % {"cnt": len(cl.result_list)},
326-
"selection_note_all": selection_note_all % {"total_count": cl.result_count},
327-
}
328-
)
329-
else:
330-
context["opts"] = self.model._meta
282+
context["opts"] = self.model._meta
331283

332284
context.update(extra_context or {})
333285
return render(

tox.ini

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
[tox]
22
envlist =
33
begin
4-
py36-lint
5-
py{36,37}-django{2,21}
6-
py{36,37,38,39}-django{22,3,31}
7-
py{36,37,38,39,310}-django{32}
4+
py37-lint
5+
py{37}-django{21}
6+
py{37,38,39}-django{22,3,31}
7+
py{37,38,39,310}-django{32}
88
py{38,39,310}-django{40}
99
py{38,39,310,311}-django{41}
1010
py{310,311,312}-django{42,50}
1111
coverage-report
1212

1313
[gh-actions]
1414
python =
15-
3.6: py36
1615
3.7: py37
1716
3.8: py38
1817
3.9: py39

0 commit comments

Comments
 (0)