Skip to content

Commit d62593e

Browse files
merwokfabiocaccamo
andauthored
Drop old Python and Django versions (#220)
* drop old python and django versions * fix tests * remove compat module entirely Co-authored-by: Fabio Caccamo <[email protected]>
1 parent 333025f commit d62593e

24 files changed

+34
-244
lines changed

.github/workflows/test-package.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ jobs:
1919
id: create_matrix
2020
with:
2121
matrix: |
22-
python-version {2.7}, django-version {1.8,1.9,1.10,1.11}, database {sqlite,postgres}
23-
python-version {3.6}, django-version {1.8,1.9,1.10,1.11,2.0,2.1,2.2,3.0,3.1,3.2}, database {sqlite,postgres}
24-
python-version {3.7}, django-version {2.0,2.1,2.2,3.0,3.1,3.2}, database {sqlite,postgres}
2522
python-version {3.8}, django-version {2.2,3.0,3.1,3.2}, database {sqlite,postgres}
2623
python-version {3.9}, django-version {2.2,3.0,3.1,3.2}, database {sqlite,postgres}
2724
python-version {3.10}, django-version {3.2,4.0,4.1}, database {sqlite,postgres}

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,17 @@ django-admin-interface is a modern **responsive flat admin interface customizabl
4747

4848
## Installation
4949
- Run `pip install django-admin-interface`
50-
- Add `admin_interface`, `flat_responsive`, `flat` and `colorfield` to `settings.INSTALLED_APPS` **before** `django.contrib.admin`
50+
- Add `admin_interface` and `colorfield` to `settings.INSTALLED_APPS` **before** `django.contrib.admin`
5151
```python
5252
INSTALLED_APPS = (
5353
#...
5454
"admin_interface",
55-
"flat_responsive", # only if django version < 2.0
56-
"flat", # only if django version < 1.9
5755
"colorfield",
5856
#...
5957
"django.contrib.admin",
6058
#...
6159
)
6260

63-
# only if django version >= 3.0
6461
X_FRAME_OPTIONS = "SAMEORIGIN"
6562
SILENCED_SYSTEM_CHECKS = ["security.W019"]
6663
```

admin_interface/admin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
from django.contrib import admin
2+
from django.utils.translation import gettext_lazy as _
43

5-
from admin_interface.compat import gettext_lazy as _
64
from admin_interface.models import Theme
75

86

admin_interface/apps.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
from django.apps import AppConfig
42
from django.db.models.signals import post_migrate
5-
6-
from admin_interface.compat import gettext_lazy as _
3+
from django.utils.translation import gettext_lazy as _
74

85

96
class AdminInterfaceConfig(AppConfig):

admin_interface/cache.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from django.conf import settings
42
from django.core.cache import cache, caches
53

admin_interface/compat.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

admin_interface/migrations/0021_file_extension_validator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
from __future__ import unicode_literals
44

5+
from django.core.validators import FileExtensionValidator
56
from django.db import migrations, models
67

7-
from admin_interface.compat import FileExtensionValidator
8-
98

109
class Migration(migrations.Migration):
1110

admin_interface/models.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
# -*- coding: utf-8 -*-
2-
3-
from __future__ import unicode_literals
4-
51
from colorfield.fields import ColorField
2+
from django.core.validators import FileExtensionValidator
63
from django.db import models
74
from django.db.models.signals import post_delete, post_save, pre_save
8-
from six import python_2_unicode_compatible
5+
from django.utils.encoding import force_str
6+
from django.utils.translation import gettext_lazy as _
97

10-
from admin_interface.cache import del_cached_active_theme
11-
from admin_interface.compat import FileExtensionValidator, force_str
12-
from admin_interface.compat import gettext_lazy as _
8+
from .cache import del_cached_active_theme
139

1410

15-
@python_2_unicode_compatible
1611
class Theme(models.Model):
1712
@staticmethod
1813
def post_migrate_handler(**kwargs):

admin_interface/settings.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import django
42
from django.conf import settings
53
from django.core.exceptions import ImproperlyConfigured
@@ -29,5 +27,3 @@ def check_installed_app(app, max_dj_version=None):
2927

3028
def check_installed_apps():
3129
check_installed_app("colorfield")
32-
check_installed_app("flat", max_dj_version=(1, 9))
33-
check_installed_app("flat_responsive", max_dj_version=(2, 0))

admin_interface/static/admin/js/popup_response.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@
4242
if (typeof(openerRef.dismissAddRelatedObjectPopup) === 'function') {
4343
openerRef.dismissAddRelatedObjectPopup(windowRef, initData.value, initData.obj);
4444
}
45-
else if (typeof(openerRef.dismissAddAnotherPopup) === 'function') {
46-
// django 1.7 compatibility
47-
openerRef.dismissAddAnotherPopup(windowRef, initData.value, initData.obj);
48-
}
4945
break;
5046
}
5147

52-
})();
48+
})();

admin_interface/static/admin_interface/related-modal/related-modal.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
7070
}
7171
}
7272

73-
// fix for django 1.7
73+
// fix for django 1.7 TODO remove
7474
if (iframeSrc.indexOf('_popup=1') === -1) {
7575
if (iframeSrc.indexOf('?') === -1) {
7676
iframeSrc += '?_popup=1';
@@ -135,10 +135,6 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
135135
window.presentRelatedObjectModal = presentRelatedObjectModal;
136136
window.presentRelatedObjectModalOnClickOn = presentRelatedObjectModalOnClickOn;
137137

138-
// django 1.7 compatibility
139-
presentRelatedObjectModalOnClickOn('a.add-another');
140-
141-
// django 1.8 and above
142138
presentRelatedObjectModalOnClickOn('a.related-widget-wrapper-link');
143139

144140
// raw_id_fields support

admin_interface/templatetags/admin_interface_tags.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
# -*- coding: utf-8 -*-
2-
31
import hashlib
42
import re
53

6-
import django
74
from django import template
85
from django.conf import settings
96
from django.template.loader import get_template
7+
from django.urls import NoReverseMatch, reverse
108
from django.utils import translation
119

1210
from admin_interface.cache import get_cached_active_theme, set_cached_active_theme
13-
from admin_interface.compat import NoReverseMatch, reverse
1411
from admin_interface.models import Theme
1512
from admin_interface.version import __version__
1613

1714
register = template.Library()
1815

19-
if django.VERSION < (1, 9):
20-
simple_tag = register.assignment_tag
21-
else:
22-
simple_tag = register.simple_tag
23-
2416

25-
@simple_tag(takes_context=True)
17+
@register.simple_tag(takes_context=True)
2618
def get_admin_interface_languages(context):
2719
if not settings.USE_I18N:
2820
# i18n disabled
@@ -65,7 +57,7 @@ def get_admin_interface_languages(context):
6557
return langs_data
6658

6759

68-
@simple_tag()
60+
@register.simple_tag()
6961
def get_admin_interface_theme():
7062
theme = get_cached_active_theme()
7163
if not theme:
@@ -74,20 +66,20 @@ def get_admin_interface_theme():
7466
return theme
7567

7668

77-
@simple_tag()
69+
@register.simple_tag()
7870
def get_admin_interface_setting(setting):
7971
theme = get_admin_interface_theme()
8072
return getattr(theme, setting)
8173

8274

83-
@simple_tag()
75+
@register.simple_tag()
8476
def get_admin_interface_inline_template(template):
8577
template_path = template.split("/")
8678
template_path[-1] = "headerless_" + template_path[-1]
8779
return "/".join(template_path)
8880

8981

90-
@simple_tag(takes_context=False)
82+
@register.simple_tag()
9183
def get_admin_interface_version():
9284
return __version__
9385

@@ -98,17 +90,17 @@ def hash_string(text):
9890
return sha224_hash
9991

10092

101-
@simple_tag(takes_context=False)
93+
@register.simple_tag()
10294
def get_admin_interface_nocache():
10395
return hash_string(__version__)
10496

10597

106-
@simple_tag()
98+
@register.simple_tag()
10799
def admin_interface_clear_filter_qs(changelist, list_filter):
108100
return changelist.get_query_string(remove=list_filter.expected_parameters())
109101

110102

111-
@simple_tag()
103+
@register.simple_tag()
112104
def admin_interface_filter_removal_link(changelist, list_filter):
113105
template = get_template("admin_interface/list_filter_removal_link.html")
114106
title = list_filter.title
@@ -130,7 +122,7 @@ def admin_interface_filter_removal_link(changelist, list_filter):
130122
)
131123

132124

133-
@simple_tag()
125+
@register.simple_tag()
134126
def admin_interface_use_changeform_tabs(adminform, inline_forms):
135127
theme = get_admin_interface_theme()
136128
has_fieldset_tabs = theme.show_fieldsets_as_tabs and len(adminform.fieldsets) > 1

admin_interface/version.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# -*- coding: utf-8 -*-
2-
31
__version__ = "0.23.0"

runtests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import os
42
import sys
53

setup.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
42
import os
53
import sys
64

@@ -18,10 +16,7 @@
1816
long_description_content_type = "text/markdown"
1917
long_description = ""
2018
try:
21-
long_description_file_options = (
22-
{} if sys.version_info[0] < 3 else {"encoding": "utf-8"}
23-
)
24-
with open(long_description_file_path, "r", **long_description_file_options) as f:
19+
with open(long_description_file_path, "r", encoding="utf-8") as f:
2520
long_description = f.read()
2621
except IOError:
2722
pass
@@ -54,7 +49,6 @@
5449
"custom",
5550
"ui",
5651
],
57-
requires=["django(>=1.7)"],
5852
install_requires=[
5953
"django-colorfield >= 0.2, < 1.0",
6054
"django-flat-theme >= 1.0, < 2.0",
@@ -65,13 +59,6 @@
6559
"Development Status :: 5 - Production/Stable",
6660
"Environment :: Web Environment",
6761
"Framework :: Django",
68-
"Framework :: Django :: 1.7",
69-
"Framework :: Django :: 1.8",
70-
"Framework :: Django :: 1.9",
71-
"Framework :: Django :: 1.10",
72-
"Framework :: Django :: 1.11",
73-
"Framework :: Django :: 2.0",
74-
"Framework :: Django :: 2.1",
7562
"Framework :: Django :: 2.2",
7663
"Framework :: Django :: 3.0",
7764
"Framework :: Django :: 3.1",
@@ -82,19 +69,13 @@
8269
"License :: OSI Approved :: MIT License",
8370
"Natural Language :: English",
8471
"Operating System :: OS Independent",
85-
"Programming Language :: Python :: 2",
86-
"Programming Language :: Python :: 2.7",
8772
"Programming Language :: Python :: 3",
88-
"Programming Language :: Python :: 3.4",
89-
"Programming Language :: Python :: 3.5",
90-
"Programming Language :: Python :: 3.6",
91-
"Programming Language :: Python :: 3.7",
73+
"Programming Language :: Python :: 3 :: Only",
9274
"Programming Language :: Python :: 3.8",
9375
"Programming Language :: Python :: 3.9",
9476
"Programming Language :: Python :: 3.10",
9577
"Programming Language :: Python :: 3.11",
9678
"Topic :: Software Development :: Build Tools",
9779
],
98-
license="MIT",
9980
test_suite="runtests.runtests",
10081
)

tests/settings.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
# -*- coding: utf-8 -*-
2-
3-
from __future__ import unicode_literals
4-
51
import os
62

7-
import django
8-
93
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
104

115
SECRET_KEY = "django-admin-interface"
@@ -18,17 +12,6 @@
1812
"colorfield",
1913
]
2014

21-
if django.VERSION < (1, 9):
22-
# ONLY if django version < 1.9
23-
INSTALLED_APPS += [
24-
"flat",
25-
]
26-
27-
if django.VERSION < (2, 0):
28-
# ONLY if django version < 2.0
29-
INSTALLED_APPS += [
30-
"flat_responsive",
31-
]
3215

3316
INSTALLED_APPS += [
3417
"django.contrib.admin",
@@ -38,20 +21,12 @@
3821
"django.contrib.sessions",
3922
]
4023

41-
if django.VERSION < (2, 0):
42-
MIDDLEWARE_CLASSES = [
43-
"django.contrib.auth.middleware.AuthenticationMiddleware",
44-
"django.contrib.messages.middleware.MessageMiddleware",
45-
"django.contrib.sessions.middleware.SessionMiddleware",
46-
"django.middleware.common.CommonMiddleware",
47-
]
48-
else:
49-
MIDDLEWARE = [
50-
"django.contrib.auth.middleware.AuthenticationMiddleware",
51-
"django.contrib.messages.middleware.MessageMiddleware",
52-
"django.contrib.sessions.middleware.SessionMiddleware",
53-
"django.middleware.common.CommonMiddleware",
54-
]
24+
MIDDLEWARE = [
25+
"django.contrib.auth.middleware.AuthenticationMiddleware",
26+
"django.contrib.messages.middleware.MessageMiddleware",
27+
"django.contrib.sessions.middleware.SessionMiddleware",
28+
"django.middleware.common.CommonMiddleware",
29+
]
5530

5631
TEMPLATES = [
5732
{

tests/test_fixtures.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
3-
from __future__ import unicode_literals
4-
51
from django.core.management import call_command
62
from django.test import TestCase
73

0 commit comments

Comments
 (0)