From fe94a5f0784a5d98eacb1eedb79b63a1b0411bda Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 10 Sep 2024 09:20:00 +0200 Subject: [PATCH] modernized code and remove obsolete snapshot file --- README.md | 1 + reversion_compare/admin.py | 8 +- ...model_all_changes_django50_1.snapshot.html | 217 ------------------ reversion_compare_project/admin.py | 38 +-- reversion_compare_project/settings.py | 1 - reversion_compare_project/settings/prod.py | 1 - reversion_compare_project/tests/test_admin.py | 8 +- reversion_compare_project/urls.py | 4 +- 8 files changed, 18 insertions(+), 260 deletions(-) delete mode 100644 reversion_compare/tests/test_variant_model_all_changes_django50_1.snapshot.html diff --git a/README.md b/README.md index 7edaf53..70793a3 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,7 @@ Maybe other versions are compatible, too. [comment]: <> (✂✂✂ auto generated history start ✂✂✂) * [v0.18.0](https://github.com/jedie/django-reversion-compare/compare/v0.17.0...v0.18.0) + * 2024-09-10 - modernized code and remove obsolete snapshot file * 2024-09-10 - Update test matrix and requirements * 2024-09-10 - Apply manageprojects updates * 2024-09-10 - Update requirements diff --git a/reversion_compare/admin.py b/reversion_compare/admin.py index 93d4ad3..6c0ba57 100644 --- a/reversion_compare/admin.py +++ b/reversion_compare/admin.py @@ -256,11 +256,10 @@ class CompareVersionAdmin(CompareMethodsMixin, BaseCompareVersionAdmin): class to inherit """ - pass - if hasattr(settings, "ADD_REVERSION_ADMIN") and settings.ADD_REVERSION_ADMIN: + @admin.register(Revision) class RevisionAdmin(admin.ModelAdmin): list_display = ("id", "date_created", "user", "comment") list_display_links = ("date_created",) @@ -271,8 +270,7 @@ class RevisionAdmin(admin.ModelAdmin): search_fields = ("user", "comment") raw_id_fields = ("user",) - admin.site.register(Revision, RevisionAdmin) - + @admin.register(Version) class VersionAdmin(admin.ModelAdmin): def comment(self, obj): return obj.revision.comment @@ -282,5 +280,3 @@ def comment(self, obj): list_select_related = ("revision", "content_type") search_fields = ("object_repr", "serialized_data") raw_id_fields = ("revision", "content_type") - - admin.site.register(Version, VersionAdmin) diff --git a/reversion_compare/tests/test_variant_model_all_changes_django50_1.snapshot.html b/reversion_compare/tests/test_variant_model_all_changes_django50_1.snapshot.html deleted file mode 100644 index d144337..0000000 --- a/reversion_compare/tests/test_variant_model_all_changes_django50_1.snapshot.html +++ /dev/null @@ -1,217 +0,0 @@ -
-

- Compare VariantModel instance pk: 1 -

-
-
    -
-

- Compare - - Jan. 1, 2010, 1 a.m. - - with - - Jan. 1, 2010, 1 a.m. - - : -

- ‹ - - Go back to history list - - | - - Revert to this version - - › -

- boolean -

-
-

- - False - - changed to: - - True - -

-
-

- null boolean -

-
-

- - None - - changed to: - - False - -

-
-

- char -

-
-
- a
-+ B
-
-

- choices char -

-
-
- alpha
-+ bravo
-
-

- text -

-
-
- Foo 'one'
-+ Bar 'two'
-
-

- integer -

-
-
- 0
-+ -1
-
-

- integers -

-
-
- 1,2,3
-+ 2,3,4
-
-

- positive integer -

-
-
- 1
-+ 3
-
-

- big integer -

-
-
- -9223372036854775808
-? -                  ^
-
-+ 9223372036854775807
-?                   ^
-
-

- time -

-
-
- 20:15:00
-+ 19:30:00
-
-

- date -

-
-
- 1941-05-12
-+ 2099-12-31
-
-

- datetime -

-
-
-- Aug. 19, 2005, 8:13 a.m. (time since that date: 18 years, 5 months)
-+ Jan. 1, 2000, midnight (time since that date: 24 years, 1 month)
-
-
-

- decimal -

-
-
- 1.23456789
-+ 3.1415926535
-
-

- float -

-
-
- 2.345
-+ 3.1415
-
-

- email -

-
-
- one@foo-bar.com
-?  --
-
-+ two@foo-bar.com
-? ++
-
-

- url -

-
-
https://www.pylucid.orggithub.aaakk.us.kg/jedie/
-
-
-

- file field -

-
-
/media/file_field_19.txt
-
-
-

- filepath -

-
-
- foo/
-+ bar/
-
-

- ip address -

-
-
- 192.168.0.1
-+ 10.0.0.0
-
-

- json field -

-
-
{
-    'foo': {
-        'bar': {
-            'baz': [
-                123,
-                456'XXX',
-                789
-            ]
-        }
-    }
-}
-
-
-

- Edit comment: -

-
- 19 change: 'json_field' field. -
- ‹ - - Go back to history list - - | - - Revert to this version - - › -
-
-
\ No newline at end of file diff --git a/reversion_compare_project/admin.py b/reversion_compare_project/admin.py index 4aef1a5..a8cec8c 100644 --- a/reversion_compare_project/admin.py +++ b/reversion_compare_project/admin.py @@ -29,71 +29,51 @@ ) +@admin.register(SimpleModel) class SimpleModelAdmin(CompareVersionAdmin): pass -admin.site.register(SimpleModel, SimpleModelAdmin) - - +@admin.register(MigrationModel) class MigrationModelAdmin(CompareVersionAdmin): pass -admin.site.register(MigrationModel, MigrationModelAdmin) - - +@admin.register(Factory) class FactoryAdmin(CompareVersionAdmin): pass -admin.site.register(Factory, FactoryAdmin) - - +@admin.register(Car) class CarAdmin(CompareVersionAdmin): pass -admin.site.register(Car, CarAdmin) - - +@admin.register(Person) class PersonAdmin(CompareVersionAdmin): pass -admin.site.register(Person, PersonAdmin) - - +@admin.register(Pet) class PetAdmin(CompareVersionAdmin): pass -admin.site.register(Pet, PetAdmin) - - +@admin.register(VariantModel) class VariantModelAdmin(CompareVersionAdmin): pass -admin.site.register(VariantModel, VariantModelAdmin) - - +@admin.register(CustomModel, Identity) class CustomModelAdmin(CompareVersionAdmin): pass -admin.site.register(CustomModel, CustomModelAdmin) - -admin.site.register(Identity, CustomModelAdmin) - - +@admin.register(TemplateField) class TemplateFieldModelAdmin(CompareVersionAdmin): pass -admin.site.register(TemplateField, TemplateFieldModelAdmin) - - @admin.register(CountryFieldTestModel) class CountryFieldTestModelAdmin(CompareVersionAdmin): pass diff --git a/reversion_compare_project/settings.py b/reversion_compare_project/settings.py index 86ab7fd..0676599 100644 --- a/reversion_compare_project/settings.py +++ b/reversion_compare_project/settings.py @@ -47,7 +47,6 @@ LANGUAGE_CODE = 'en-us' USE_I18N = True -USE_L10N = True USE_TZ = True LOCALE_PATHS = (BASE_DIR.parent / 'reversion_compare' / 'locale',) diff --git a/reversion_compare_project/settings/prod.py b/reversion_compare_project/settings/prod.py index 4ef19d9..a5eb849 100644 --- a/reversion_compare_project/settings/prod.py +++ b/reversion_compare_project/settings/prod.py @@ -114,7 +114,6 @@ ('en', _('English')), ] USE_I18N = True -USE_L10N = True TIME_ZONE = 'Europe/Paris' USE_TZ = True diff --git a/reversion_compare_project/tests/test_admin.py b/reversion_compare_project/tests/test_admin.py index 7852e4e..7904ff7 100644 --- a/reversion_compare_project/tests/test_admin.py +++ b/reversion_compare_project/tests/test_admin.py @@ -12,11 +12,11 @@ class AdminAnonymousTests(HtmlAssertionMixin, TestCase): """ def test_login_en(self): - response = self.client.get("/en/admin/", HTTP_ACCEPT_LANGUAGE="en") + response = self.client.get("/en/admin/", headers={"accept-language": "en"}) self.assertRedirects(response, expected_url="/en/admin/login/?next=/en/admin/") def test_login_de(self): - response = self.client.get("/de/admin/", HTTP_ACCEPT_LANGUAGE="de") + response = self.client.get("/de/admin/", headers={"accept-language": "de"}) self.assertRedirects(response, expected_url="/de/admin/login/?next=/de/admin/") @@ -53,7 +53,7 @@ def test_model_registering(self): def test_staff_admin_index(self): self.client.force_login(self.staffuser) - response = self.client.get("/en/admin/", HTTP_ACCEPT_LANGUAGE="en") + response = self.client.get("/en/admin/", headers={"accept-language": "en"}) self.assert_html_parts( response, parts=( @@ -67,7 +67,7 @@ def test_staff_admin_index(self): def test_superuser_admin_index(self): self.client.force_login(self.superuser) - response = self.client.get("/en/admin/", HTTP_ACCEPT_LANGUAGE="en") + response = self.client.get("/en/admin/", headers={"accept-language": "en"}) self.assert_html_parts( response, parts=( diff --git a/reversion_compare_project/urls.py b/reversion_compare_project/urls.py index 91099a8..478567d 100644 --- a/reversion_compare_project/urls.py +++ b/reversion_compare_project/urls.py @@ -1,8 +1,8 @@ from django.conf import settings -from django.conf.urls import include, static +from django.conf.urls import static from django.conf.urls.i18n import i18n_patterns from django.contrib import admin -from django.urls import path +from django.urls import include, path from django.views.generic import RedirectView from reversion_compare_project.views import SimpleModelHistoryCompareView