Skip to content

Commit

Permalink
modernized code and remove obsolete snapshot file
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Sep 10, 2024
1 parent 4bc437f commit fe94a5f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 260 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions reversion_compare/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",)
Expand All @@ -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
Expand All @@ -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)

This file was deleted.

38 changes: 9 additions & 29 deletions reversion_compare_project/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion reversion_compare_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',)

Expand Down
1 change: 0 additions & 1 deletion reversion_compare_project/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
('en', _('English')),
]
USE_I18N = True
USE_L10N = True
TIME_ZONE = 'Europe/Paris'
USE_TZ = True

Expand Down
8 changes: 4 additions & 4 deletions reversion_compare_project/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")


Expand Down Expand Up @@ -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=(
Expand All @@ -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=(
Expand Down
4 changes: 2 additions & 2 deletions reversion_compare_project/urls.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit fe94a5f

Please sign in to comment.