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 all 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
4 changes: 1 addition & 3 deletions admin_interface/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-

from django.contrib import admin
from django.utils.translation import gettext_lazy as _

from admin_interface.compat import gettext_lazy as _
from admin_interface.models import Theme


Expand Down
5 changes: 1 addition & 4 deletions admin_interface/apps.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-

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

from admin_interface.compat import gettext_lazy as _
from django.utils.translation import gettext_lazy as _


class AdminInterfaceConfig(AppConfig):
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
26 changes: 0 additions & 26 deletions admin_interface/compat.py

This file was deleted.

3 changes: 1 addition & 2 deletions admin_interface/migrations/0021_file_extension_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

from __future__ import unicode_literals

from django.core.validators import FileExtensionValidator
from django.db import migrations, models

from admin_interface.compat import FileExtensionValidator


class Migration(migrations.Migration):

Expand Down
13 changes: 4 additions & 9 deletions admin_interface/models.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from colorfield.fields import ColorField
from django.core.validators import FileExtensionValidator
from django.db import models
from django.db.models.signals import post_delete, post_save, pre_save
from six import python_2_unicode_compatible
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _

from admin_interface.cache import del_cached_active_theme
from admin_interface.compat import FileExtensionValidator, force_str
from admin_interface.compat import gettext_lazy as _
from .cache import del_cached_active_theme


@python_2_unicode_compatible
class Theme(models.Model):
@staticmethod
def post_migrate_handler(**kwargs):
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))
6 changes: 1 addition & 5 deletions admin_interface/static/admin/js/popup_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@
if (typeof(openerRef.dismissAddRelatedObjectPopup) === 'function') {
openerRef.dismissAddRelatedObjectPopup(windowRef, initData.value, initData.obj);
}
else if (typeof(openerRef.dismissAddAnotherPopup) === 'function') {
// django 1.7 compatibility
openerRef.dismissAddAnotherPopup(windowRef, initData.value, initData.obj);
}
break;
}

})();
})();
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
}
}

// fix for django 1.7
// fix for django 1.7 TODO remove
if (iframeSrc.indexOf('_popup=1') === -1) {
if (iframeSrc.indexOf('?') === -1) {
iframeSrc += '?_popup=1';
Expand Down Expand Up @@ -135,10 +135,6 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
window.presentRelatedObjectModal = presentRelatedObjectModal;
window.presentRelatedObjectModalOnClickOn = presentRelatedObjectModalOnClickOn;

// django 1.7 compatibility
presentRelatedObjectModalOnClickOn('a.add-another');

// django 1.8 and above
presentRelatedObjectModalOnClickOn('a.related-widget-wrapper-link');

// raw_id_fields support
Expand Down
28 changes: 10 additions & 18 deletions admin_interface/templatetags/admin_interface_tags.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
# -*- 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
from django.urls import NoReverseMatch, reverse
from django.utils import translation

from admin_interface.cache import get_cached_active_theme, set_cached_active_theme
from admin_interface.compat import NoReverseMatch, reverse
from admin_interface.models import Theme
from admin_interface.version import __version__

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
Loading