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

Allow StatusLog searches #555

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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
19 changes: 19 additions & 0 deletions parking_permits/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.contrib.admin.sites import NotRegistered
from django.contrib.gis import admin
from django.urls import reverse
from django.utils.html import format_html
from django_db_logger.models import StatusLog

from parking_permits.models import (
Address,
Expand Down Expand Up @@ -391,3 +393,20 @@ class VehicleUserAdmin(admin.ModelAdmin):
@admin.display(description="Vehicles")
def get_vehicles(self, obj):
return [vehicle.registration_number for vehicle in obj.vehicles.all()]


# Importing the default StatusLogAdmin will automatically register the StatusLog model
from django_db_logger.admin import StatusLogAdmin # noqa: F401, E402

# Unregister the StatusLog model from the admin site registry
try:
admin.site.unregister(StatusLog)
except NotRegistered:
pass


# Create application specific StatusLogAdmin
@admin.register(StatusLog)
class ParkingPermitsStatusLogAdmin(StatusLogAdmin):
search_fields = ("msg",) # Add search field for the message
list_per_page = 20