From a1f58bd5218f9248683c27a2b50a4e4c846b04d5 Mon Sep 17 00:00:00 2001 From: Ezequiel Bertti Date: Tue, 27 Aug 2024 18:25:34 -0300 Subject: [PATCH 1/7] fix object_id --- test_app/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_app/models.py b/test_app/models.py index 24a64b8..8e481fa 100644 --- a/test_app/models.py +++ b/test_app/models.py @@ -24,5 +24,5 @@ class Tag(models.Model): name = models.CharField(max_length=50) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) - object_id = models.PositiveBigIntegerField() + object_id = models.BigIntegerField() generic = GenericForeignKey('content_type', 'object_id') \ No newline at end of file From db514d950d93b656672c54d98b73273c65280a93 Mon Sep 17 00:00:00 2001 From: Ezequiel Bertti Date: Tue, 27 Aug 2024 18:25:34 -0300 Subject: [PATCH 2/7] fix object_id --- test_app/migrations/0002_auto_20240827_1315.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_app/migrations/0002_auto_20240827_1315.py b/test_app/migrations/0002_auto_20240827_1315.py index eef4a81..c5c6741 100644 --- a/test_app/migrations/0002_auto_20240827_1315.py +++ b/test_app/migrations/0002_auto_20240827_1315.py @@ -32,7 +32,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=50)), - ('object_id', models.PositiveBigIntegerField()), + ('object_id', models.BigIntegerField()), ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')), ], ), From 755bbe24890cb18c51418e20583dc0e0375c98b4 Mon Sep 17 00:00:00 2001 From: Ezequiel Bertti Date: Tue, 27 Aug 2024 18:34:23 -0300 Subject: [PATCH 3/7] update actions usage --- .github/workflows/pypi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 1231430..672fbe5 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies From 0837ef3132a18930c25c78055bc84f139641ecdd Mon Sep 17 00:00:00 2001 From: Ezequiel Bertti Date: Tue, 27 Aug 2024 18:38:21 -0300 Subject: [PATCH 4/7] update actions usage --- .github/workflows/pypi.yml | 8 ++++---- .github/workflows/test.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 672fbe5..b57c084 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies @@ -24,7 +24,7 @@ jobs: run: | python setup.py sdist bdist_wheel - name: Save artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: dist path: './dist' @@ -40,7 +40,7 @@ jobs: id-token: write steps: - name: Download artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: dist path: './dist' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12b1b84..50e4e19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,9 +12,9 @@ jobs: python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies From 5f19f230ac8b44f66e6260a7f6a2bf34b25e86f0 Mon Sep 17 00:00:00 2001 From: Ezequiel Bertti Date: Tue, 27 Aug 2024 19:20:19 -0300 Subject: [PATCH 5/7] add python 3.12 and django 5.0 and 5.1 remove django < 2 --- .github/workflows/test.yml | 2 +- README.rst | 2 +- easy/admin/mixin.py | 3 +- easy/helper.py | 44 +++++++------------------- easy/tests.py | 64 +++++++++++--------------------------- setup.py | 1 + tox.ini | 16 +++++----- 7 files changed, 42 insertions(+), 90 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 50e4e19..c9ac185 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 diff --git a/README.rst b/README.rst index fa894ec..5f773f3 100644 --- a/README.rst +++ b/README.rst @@ -10,7 +10,7 @@ Collection of admin fields, decorators and mixin to help to create computed or c .. image:: https://img.shields.io/badge/django-2.0%202.1%202.2-brightgreen.svg :target: http://pypi.python.org/pypi/django-admin-easy -.. image:: https://img.shields.io/badge/django-3.0%203.1%203.2%204.0%204.1%204.2-brightgreen.svg +.. image:: https://img.shields.io/badge/django-3.0%203.1%203.2%204.0%204.1%204.2%205.0%205.1-brightgreen.svg :target: http://pypi.python.org/pypi/django-admin-easy .. image:: https://img.shields.io/badge/django-4.0%204.1%204.2-brightgreen.svg diff --git a/easy/admin/mixin.py b/easy/admin/mixin.py index 399dcb2..1c57df8 100644 --- a/easy/admin/mixin.py +++ b/easy/admin/mixin.py @@ -1,14 +1,13 @@ from django.contrib import messages from django.http.response import HttpResponseRedirect -from easy.helper import get_model_name from easy.six import reverse, url class MixinEasyViews(object): def _get_info(self): - return self.model._meta.app_label, get_model_name(self.model) + return self.model._meta.app_label, self.model._meta.model_name def get_urls(self): urls = super(MixinEasyViews, self).get_urls() diff --git a/easy/helper.py b/easy/helper.py index e4c5487..069351e 100644 --- a/easy/helper.py +++ b/easy/helper.py @@ -20,31 +20,17 @@ def deep_getattribute(obj, attr): def get_django_filter(django_filter, load='django'): - if django.VERSION < (1, 9): - from django.template.base import get_library - if load and not load == 'django': - library = get_library(load) - else: - library_path = 'django.template.defaultfilters' - if django.VERSION > (1, 8): - from django.template.base import import_library - library = import_library(library_path) - else: - from django.template import import_library - library = import_library(library_path) - + from django.template.backends.django import get_installed_libraries + from django.template.library import import_library + libraries = get_installed_libraries() + if load and not load == 'django': + library_path = libraries.get(load) + if not library_path: + raise Exception('templatetag "{}" is not registered'.format(load)) else: - from django.template.backends.django import get_installed_libraries - from django.template.library import import_library - libraries = get_installed_libraries() - if load and not load == 'django': - library_path = libraries.get(load) - if not library_path: - raise Exception('templatetag "{}" is not registered'.format(load)) - else: - library_path = 'django.template.defaultfilters' + library_path = 'django.template.defaultfilters' - library = import_library(library_path) + library = import_library(library_path) filter_method = library.filters.get(django_filter) if not filter_method: raise Exception('filter "{}" not exist on {} templatetag package'.format( @@ -70,18 +56,10 @@ def call_or_get(obj, attr, default=None): return ret - -def get_model_name(model): - if django.VERSION < (1, 6): - return model._meta.module_name - else: - return model._meta.model_name - - def cache_method_key(model, method_name): return EASY_CACHE_TEMPLATE_METHOD.format( model._meta.app_label, - get_model_name(model), + model._meta.model_name, method_name, model.pk ) @@ -90,6 +68,6 @@ def cache_method_key(model, method_name): def cache_object_key(model): return EASY_CACHE_TEMPLATE_OBJ.format( model._meta.app_label, - get_model_name(model), + model._meta.model_name, model.pk ) diff --git a/easy/tests.py b/easy/tests.py index 427ef9f..f2cdc74 100644 --- a/easy/tests.py +++ b/easy/tests.py @@ -83,12 +83,8 @@ def test_foreignkey(self): custom_field = easy.ForeignKeyAdminField('poll') ret = custom_field(question) - if django.VERSION < (1, 9): - expected = u'Poll object' - elif django.VERSION < (2, 0): - expected = u'Poll object' - else: - expected = u'Poll object (1)' + + expected = u'Poll object (1)' self.assertEqual(expected, ret) self.assertTrue(custom_field.allow_tags) @@ -101,10 +97,7 @@ def test_foreignkey_display(self): custom_field = easy.ForeignKeyAdminField('poll', 'poll_id') ret = custom_field(question) - if django.VERSION < (1, 9): - expected = u'1' - else: - expected = u'1' + expected = u'1' self.assertEqual(expected, ret) self.assertTrue(custom_field.allow_tags) @@ -118,14 +111,12 @@ def test_foreignkey_display_sub_property(self): custom_field = easy.ForeignKeyAdminField('poll', 'poll.id') ret = custom_field(question) - if django.VERSION < (1, 9): - expected = u'1' - else: - expected = u'1' + expected = u'1' self.assertEqual(expected, ret) self.assertTrue(custom_field.allow_tags) + class TestGenericForeignKeyAdminField(test.TestCase): def test_generic_field(self): @@ -141,13 +132,7 @@ def test_generic_field(self): custom_field = easy.GenericForeignKeyAdminField('generic') ret = custom_field.render(tag) - - if django.VERSION < (1, 9): - expected = u'1 | usuário' - elif django.VERSION < (2, 0): - expected = u'1 | usuário' - else: - expected = u'1 | usuário' + expected = u'1 | usuário' self.assertEqual(expected, ret) self.assertTrue(custom_field.allow_tags) @@ -182,13 +167,7 @@ def test_generic_field_with_related_attr(self): custom_field = easy.GenericForeignKeyAdminField('generic', cache_content_type=True, related_attr='username') ret = custom_field.render(tag) - - if django.VERSION < (1, 9): - expected = u'eric' - elif django.VERSION < (2, 0): - expected = u'eric' - else: - expected = u'eric' + expected = u'eric' class TestRawIdAdminField(test.TestCase): @@ -200,12 +179,8 @@ def test_foreignkey(self): custom_field = easy.RawIdAdminField('poll') ret = custom_field(question) - if django.VERSION < (1, 9): - expected = u'1' - elif django.VERSION < (2, 0): - expected = u'1' - else: - expected = u'1' + + expected = u'1' self.assertEqual(expected, ret) self.assertTrue(custom_field.allow_tags) @@ -364,7 +339,7 @@ def test_decorators(self): def field(self, obj): return obj - self.assertEquals(field(object(), 'asd'), 'asd') + self.assertEqual(field(object(), 'asd'), 'asd') def test_function_not_exist(self): @@ -381,7 +356,7 @@ def test_decorators(self): def field(self, obj): return 10 - self.assertEquals(field(object(), 'asd'), '10') + self.assertEqual(field(object(), 'asd'), '10') def test_decorators_from_detaultags(self): @@ -389,7 +364,7 @@ def test_decorators_from_detaultags(self): def field(self, obj): return 'ezequiel bertti' - self.assertEquals(field(object(), 'asd'), 'Ezequiel bertti') + self.assertEqual(field(object(), 'asd'), 'Ezequiel bertti') def test_decorators_with_args(self): @@ -397,7 +372,7 @@ def test_decorators_with_args(self): def field(self, obj): return datetime(2016, 6, 25) - self.assertEquals(field(object(), 'asd'), '16-06-25') + self.assertEqual(field(object(), 'asd'), '16-06-25') def test_templatetag_not_exist(self): @@ -433,20 +408,20 @@ def setUp(self): def test_decorators(self): value2 = self.field(self.pool) - self.assertEquals(self.value, value2) + self.assertEqual(self.value, value2) def test_delete_cache(self): easy.clear_cache(self.pool) value2 = self.field(self.pool) - self.assertNotEquals(self.value, value2) + self.assertNotEqual(self.value, value2) def test_another_field(self): value1 = self.field(self.pool) value2 = self.field2(self.pool) - self.assertNotEquals(value1, value2) + self.assertNotEqual(value1, value2) class TestMultiDecorator(test.TestCase): @@ -459,7 +434,7 @@ def field(self, obj): return datetime(2016, 6, 25) v = field(1, 1) - self.assertEquals(v, '16-06-25') + self.assertEqual(v, '16-06-25') self.assertIsInstance(v, SafeData) @@ -502,9 +477,8 @@ def setUpClass(cls): def test_register_view(self): views = self.admin.get_urls() - if django.VERSION < (1, 9): - self.assertEqual(len(views), 7) - elif django.VERSION < (2, 0) or django.VERSION > (3, 2): + + if django.VERSION < (2, 0) or django.VERSION > (3, 2): self.assertEqual(len(views), 8) else: self.assertEqual(len(views), 9) diff --git a/setup.py b/setup.py index 0b8926b..d67460f 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], zip_safe=False, ) diff --git a/tox.ini b/tox.ini index 22f9616..b5ecd3b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,13 @@ [tox] envlist = - py34-{19,110,111,20} - py35-{19,110,111,20,21,22} - py36-{19,110,111,20,21,22,30,31,32} + py35-{20,21,22} + py36-{20,21,22,30,31,32} py37-{21,22,30,31,32} py38-{22,30,31,32,40,41,42} py39-{22,30,31,32,40,41,42} - py310-{22,30,31,32,40,41,42} - py311-{42} + py310-{22,30,31,32,40,41,42,50,51} + py311-{42,50,51} + py312-{42,50,51} [gh-actions] @@ -17,15 +17,13 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] deps = wheel pillow model-bakery - 19: Django >= 1.9, < 1.10 - 110: Django >= 1.10, < 1.11 - 111: Django >= 1.11, < 2.0 20: Django >= 2.0, < 2.1 21: Django >= 2.1, < 2.2 22: Django >= 2.2, < 2.3 @@ -35,5 +33,7 @@ deps = 40: Django >= 4.0, < 4.1 41: Django >= 4.1, < 4.2 42: Django >= 4.2, < 4.3 + 50: Django >= 5.0, < 5.1 + 51: Django >= 5.1, < 5.2 commands = python manage.py test easy From 5439569725ee0e1e6e5430c527aba98f716104a3 Mon Sep 17 00:00:00 2001 From: Ezequiel Bertti Date: Tue, 27 Aug 2024 19:37:16 -0300 Subject: [PATCH 6/7] drop support for python 3.5 and 3.6 --- setup.py | 2 -- tox.ini | 3 --- 2 files changed, 5 deletions(-) diff --git a/setup.py b/setup.py index d67460f..e3b7429 100644 --- a/setup.py +++ b/setup.py @@ -25,8 +25,6 @@ 'Natural Language :: Portuguese (Brazilian)', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', diff --git a/tox.ini b/tox.ini index b5ecd3b..6b38727 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,5 @@ [tox] envlist = - py35-{20,21,22} - py36-{20,21,22,30,31,32} py37-{21,22,30,31,32} py38-{22,30,31,32,40,41,42} py39-{22,30,31,32,40,41,42} @@ -12,7 +10,6 @@ envlist = [gh-actions] python = - 3.7: py37 3.8: py38 3.9: py39 3.10: py310 From 11f98dfc3763ae4279cc1544ecda5af6faa303b5 Mon Sep 17 00:00:00 2001 From: Ezequiel Bertti Date: Tue, 27 Aug 2024 19:37:32 -0300 Subject: [PATCH 7/7] update readme for version 0.8.0 --- README.rst | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 5f773f3..22951e0 100644 --- a/README.rst +++ b/README.rst @@ -4,16 +4,8 @@ django-admin-easy Collection of admin fields, decorators and mixin to help to create computed or custom fields more friendly and easy way -.. image:: https://img.shields.io/badge/django-1.8%201.9%201.10%201.11-brightgreen.svg - :target: http://pypi.python.org/pypi/django-admin-easy - -.. image:: https://img.shields.io/badge/django-2.0%202.1%202.2-brightgreen.svg - :target: http://pypi.python.org/pypi/django-admin-easy - -.. image:: https://img.shields.io/badge/django-3.0%203.1%203.2%204.0%204.1%204.2%205.0%205.1-brightgreen.svg - :target: http://pypi.python.org/pypi/django-admin-easy -.. image:: https://img.shields.io/badge/django-4.0%204.1%204.2-brightgreen.svg +.. image:: https://img.shields.io/badge/django-2.x%203.x%204.x%205.0%205.1-brightgreen.svg :target: http://pypi.python.org/pypi/django-admin-easy .. image:: https://img.shields.io/pypi/v/django-admin-easy.svg?style=flat @@ -28,7 +20,7 @@ Collection of admin fields, decorators and mixin to help to create computed or c .. image:: https://img.shields.io/pypi/status/django-admin-easy.svg?maxAge=2592000 :target: http://pypi.python.org/pypi/django-admin-easy -.. image:: https://github.com/ebertti/django-admin-easy/actions/workflows/test.yml/badge.svg +.. image:: https://github.com/ebertti/django-admin-easy/actions/workflows/test.yml/badge.svg?maxAge=2592000 :target: https://github.com/ebertti/django-admin-easy/actions/workflows/test.yml .. image:: https://img.shields.io/coveralls/ebertti/django-admin-easy/master.svg?maxAge=2592000 @@ -38,7 +30,7 @@ Collection of admin fields, decorators and mixin to help to create computed or c Installation ------------ -1. Requirements: **Django > 1.8** and **Python > 3.5** +1. Requirements: **Django > 3** and **Python > 3** 2. ``pip install django-admin-easy==0.8.0`` @@ -47,6 +39,10 @@ Installation ``pip install django-admin-easy==0.4.1`` +* For **Django < 2** + + ``pip install django-admin-easy==0.7`` + How it Works ------------ @@ -428,6 +424,14 @@ The django-admin-easy was originally created by Ezequiel Bertti `@ebertti `_) + * 0.7.0 Add support for Django 4.0, 4.1 and 4.2