Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop old Python and Django versions #220

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
id: create_matrix
with:
matrix: |
python-version {2.7}, django-version {1.8,1.9,1.10,1.11}, database {sqlite,postgres}
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}
python-version {3.7}, django-version {2.0,2.1,2.2,3.0,3.1,3.2}, database {sqlite,postgres}
python-version {3.8}, django-version {2.2,3.0,3.1,3.2}, database {sqlite,postgres}
python-version {3.9}, django-version {2.2,3.0,3.1,3.2}, database {sqlite,postgres}
python-version {3.10}, django-version {3.2,4.0,4.1}, database {sqlite,postgres}
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,17 @@ django-admin-interface is a modern **responsive flat admin interface customizabl

## Installation
- Run `pip install django-admin-interface`
- Add `admin_interface`, `flat_responsive`, `flat` and `colorfield` to `settings.INSTALLED_APPS` **before** `django.contrib.admin`
- Add `admin_interface` and `colorfield` to `settings.INSTALLED_APPS` **before** `django.contrib.admin`
```python
INSTALLED_APPS = (
#...
"admin_interface",
"flat_responsive", # only if django version < 2.0
"flat", # only if django version < 1.9
fabiocaccamo marked this conversation as resolved.
Show resolved Hide resolved
"colorfield",
#...
"django.contrib.admin",
#...
)

# only if django version >= 3.0
X_FRAME_OPTIONS = "SAMEORIGIN"
SILENCED_SYSTEM_CHECKS = ["security.W019"]
```
Expand Down
2 changes: 0 additions & 2 deletions admin_interface/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from django.contrib import admin

from admin_interface.compat import gettext_lazy as _
Expand Down
2 changes: 0 additions & 2 deletions admin_interface/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from django.apps import AppConfig
from django.db.models.signals import post_migrate

Expand Down
2 changes: 0 additions & 2 deletions admin_interface/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from django.conf import settings
from django.core.cache import cache, caches

Expand Down
38 changes: 12 additions & 26 deletions admin_interface/compat.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
# -*- coding: utf-8 -*-

import django

if django.VERSION >= (1, 11):
from django.core.validators import FileExtensionValidator
else:

def FileExtensionValidator(*args, **kwargs):
def noop(*args, **kwargs):
pass

return noop


if django.VERSION < (1, 10):
from django.core.urlresolvers import NoReverseMatch, reverse
else:
from django.urls import NoReverseMatch, reverse

if django.VERSION < (2, 0):
from django.utils.encoding import force_text as force_str
from django.utils.translation import ugettext_lazy as gettext_lazy
else:
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy
from django.core.validators import FileExtensionValidator
from django.urls import NoReverseMatch, reverse
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy

__all__ = [
"FileExtensionValidator",
"NoReverseMatch",
"reverse",
"force_str",
"gettext_lazy",
]
merwok marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 0 additions & 4 deletions admin_interface/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from colorfield.fields import ColorField
from django.db import models
from django.db.models.signals import post_delete, post_save, pre_save
Expand Down
4 changes: 0 additions & 4 deletions admin_interface/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import django
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
Expand Down Expand Up @@ -29,5 +27,3 @@ def check_installed_app(app, max_dj_version=None):

def check_installed_apps():
check_installed_app("colorfield")
check_installed_app("flat", max_dj_version=(1, 9))
check_installed_app("flat_responsive", max_dj_version=(2, 0))
26 changes: 9 additions & 17 deletions admin_interface/templatetags/admin_interface_tags.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-

import hashlib
import re

import django
from django import template
from django.conf import settings
from django.template.loader import get_template
Expand All @@ -16,13 +13,8 @@

register = template.Library()

if django.VERSION < (1, 9):
simple_tag = register.assignment_tag
else:
simple_tag = register.simple_tag


@simple_tag(takes_context=True)
@register.simple_tag(takes_context=True)
def get_admin_interface_languages(context):
if not settings.USE_I18N:
# i18n disabled
Expand Down Expand Up @@ -65,7 +57,7 @@ def get_admin_interface_languages(context):
return langs_data


@simple_tag()
@register.simple_tag()
def get_admin_interface_theme():
theme = get_cached_active_theme()
if not theme:
Expand All @@ -74,20 +66,20 @@ def get_admin_interface_theme():
return theme


@simple_tag()
@register.simple_tag()
def get_admin_interface_setting(setting):
theme = get_admin_interface_theme()
return getattr(theme, setting)


@simple_tag()
@register.simple_tag()
def get_admin_interface_inline_template(template):
template_path = template.split("/")
template_path[-1] = "headerless_" + template_path[-1]
return "/".join(template_path)


@simple_tag(takes_context=False)
@register.simple_tag()
def get_admin_interface_version():
return __version__

Expand All @@ -98,17 +90,17 @@ def hash_string(text):
return sha224_hash


@simple_tag(takes_context=False)
@register.simple_tag()
def get_admin_interface_nocache():
return hash_string(__version__)


@simple_tag()
@register.simple_tag()
def admin_interface_clear_filter_qs(changelist, list_filter):
return changelist.get_query_string(remove=list_filter.expected_parameters())


@simple_tag()
@register.simple_tag()
def admin_interface_filter_removal_link(changelist, list_filter):
template = get_template("admin_interface/list_filter_removal_link.html")
title = list_filter.title
Expand All @@ -130,7 +122,7 @@ def admin_interface_filter_removal_link(changelist, list_filter):
)


@simple_tag()
@register.simple_tag()
def admin_interface_use_changeform_tabs(adminform, inline_forms):
theme = get_admin_interface_theme()
has_fieldset_tabs = theme.show_fieldsets_as_tabs and len(adminform.fieldsets) > 1
Expand Down
2 changes: 0 additions & 2 deletions admin_interface/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

__version__ = "0.23.0"
2 changes: 0 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import os
import sys

Expand Down
23 changes: 2 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys

Expand All @@ -18,10 +16,7 @@
long_description_content_type = "text/markdown"
long_description = ""
try:
long_description_file_options = (
{} if sys.version_info[0] < 3 else {"encoding": "utf-8"}
)
with open(long_description_file_path, "r", **long_description_file_options) as f:
with open(long_description_file_path, "r", encoding="utf-8") as f:
long_description = f.read()
except IOError:
pass
Expand Down Expand Up @@ -54,7 +49,6 @@
"custom",
"ui",
],
requires=["django(>=1.7)"],
install_requires=[
"django-colorfield >= 0.2, < 1.0",
"django-flat-theme >= 1.0, < 2.0",
Expand All @@ -65,13 +59,6 @@
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 1.7",
"Framework :: Django :: 1.8",
"Framework :: Django :: 1.9",
"Framework :: Django :: 1.10",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.0",
"Framework :: Django :: 2.1",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
Expand All @@ -82,19 +69,13 @@
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Build Tools",
],
license="MIT",
test_suite="runtests.runtests",
)
37 changes: 6 additions & 31 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import os

import django

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = "django-admin-interface"
Expand All @@ -18,17 +12,6 @@
"colorfield",
]

if django.VERSION < (1, 9):
# ONLY if django version < 1.9
INSTALLED_APPS += [
"flat",
]

if django.VERSION < (2, 0):
# ONLY if django version < 2.0
INSTALLED_APPS += [
"flat_responsive",
]

INSTALLED_APPS += [
"django.contrib.admin",
Expand All @@ -38,20 +21,12 @@
"django.contrib.sessions",
]

if django.VERSION < (2, 0):
MIDDLEWARE_CLASSES = [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
]
else:
MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
]
MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
]

TEMPLATES = [
{
Expand Down
4 changes: 0 additions & 4 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from django.core.management import call_command
from django.test import TestCase

Expand Down
4 changes: 0 additions & 4 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import random
import shutil
from unittest import expectedFailure
Expand Down
4 changes: 0 additions & 4 deletions tests/test_multidb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from unittest import skipIf

from django import VERSION
from django.test import TestCase

from admin_interface.models import Theme
Expand All @@ -24,9 +23,6 @@ def test_dbrouter_selects_correct_db(self):
db_for_theme = router.db_for_read(Theme)
assert db_for_theme == "replica"

@skipIf(
VERSION[0] < 2, "TestCase does not respect database param on older versions"
)
def test_dbrouter_errors_when_fetching_from_default(self):
with self.assertRaises(Exception):
Theme.get_active_theme()
Expand Down
Loading