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

modernized code #253

Merged
merged 1 commit into from
Sep 10, 2024
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
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
* 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)
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
Loading