Skip to content
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
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ repos:
hooks:
- id: pyupgrade
args: [--py310-plus]

- repo: https://github.com/adamchainz/django-upgrade
rev: 1.29.1
hooks:
- id: django-upgrade
10 changes: 5 additions & 5 deletions simple_history/tests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)


@admin.register(Person)
class PersonAdmin(SimpleHistoryAdmin):
def has_change_permission(self, request, obj=None):
return False
Expand All @@ -29,17 +30,20 @@ def has_view_permission(self, request, obj=None):
return False


@admin.register(Choice)
class ChoiceAdmin(SimpleHistoryAdmin):
history_list_display = ["votes"]


@admin.register(FileModel)
class FileModelAdmin(SimpleHistoryAdmin):
def test_method(self, obj):
return "test_method_value"

history_list_display = ["title", "test_method"]


@admin.register(Planet)
class PlanetAdmin(SimpleHistoryAdmin):
def test_method(self, obj):
return "test_method_value"
Expand All @@ -63,20 +67,16 @@ def place_display(place: Place) -> SafeString:
return mark_safe(f"<b>{place.name}</b>")


@admin.register(PollWithManyToMany)
class PollWithManyToManyAdmin(SimpleHistoryAdmin):
def get_historical_record_context_helper(self, request, historical_record):
return HistoricalPollWithManyToManyContextHelper(self.model, historical_record)


admin.site.register(Book, SimpleHistoryAdmin)
admin.site.register(Choice, ChoiceAdmin)
admin.site.register(ConcreteExternal, SimpleHistoryAdmin)
admin.site.register(Document, SimpleHistoryAdmin)
admin.site.register(Employee, SimpleHistoryAdmin)
admin.site.register(ExternalModelWithCustomUserIdField, SimpleHistoryAdmin)
admin.site.register(FileModel, FileModelAdmin)
admin.site.register(Paper, SimpleHistoryAdmin)
admin.site.register(Person, PersonAdmin)
admin.site.register(Planet, PlanetAdmin)
admin.site.register(Poll, SimpleHistoryAdmin)
admin.site.register(PollWithManyToMany, PollWithManyToManyAdmin)
1 change: 0 additions & 1 deletion simple_history/tests/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ def test_bulk_update_history_with_batch_size(self):
self.assertEqual(Poll.objects.count(), 5)
self.assertEqual(Poll.history.filter(history_type="~").count(), 5)

@skipUnless(django.VERSION >= (4, 0), "Requires Django 4.0 or above")
def test_bulk_update_with_history_returns_rows_updated(self):
rows_updated = bulk_update_with_history(
self.data,
Expand Down
12 changes: 6 additions & 6 deletions simple_history/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from django.urls import path, re_path
from django.urls import path

from simple_history.tests.view import (
BucketDataRegisterRequestUserCreate,
Expand Down Expand Up @@ -29,8 +29,8 @@
BucketDataRegisterRequestUserCreate.as_view(),
name="bucket_data-add",
),
re_path(
r"^bucket_data/(?P<pk>[0-9]+)/$",
path(
"bucket_data/<int:pk>/",
BucketDataRegisterRequestUserDetail.as_view(),
name="bucket_data-detail",
),
Expand All @@ -40,9 +40,9 @@
PollWithHistoricalIPAddressCreate.as_view(),
name="pollip-add",
),
re_path(r"^poll/(?P<pk>[0-9]+)/$", PollUpdate.as_view(), name="poll-update"),
re_path(r"^poll/(?P<pk>[0-9]+)/delete/$", PollDelete.as_view(), name="poll-delete"),
re_path(r"^polls/(?P<pk>[0-9]+)/$", PollDetail.as_view(), name="poll-detail"),
path("poll/<int:pk>/", PollUpdate.as_view(), name="poll-update"),
path("poll/<int:pk>/delete/", PollDelete.as_view(), name="poll-delete"),
path("polls/<int:pk>/", PollDetail.as_view(), name="poll-detail"),
path("polls/", PollList.as_view(), name="poll-list"),
path("polls-bulk-create/", PollBulkCreateView.as_view(), name="poll-bulk-create"),
path(
Expand Down