Skip to content

Commit

Permalink
Add the TestEvent model to Django admin
Browse files Browse the repository at this point in the history
Make the string representation of TestEvent simpler
  • Loading branch information
ColeDCrawford committed Jun 3, 2024
1 parent d5ad27b commit daf0d04
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
44 changes: 43 additions & 1 deletion edtf_django_tests/edtf_integration/admin.py
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
# Register your models here.
from django.contrib import admin

from .models import TestEvent


class TestEventAdmin(admin.ModelAdmin):
list_display = (
"date_display",
"date_edtf_direct",
"date_earliest",
"date_latest",
"date_sort_ascending",
"date_sort_descending",
"date_edtf",
)
search_fields = ("date_display", "date_edtf_direct")
list_filter = ("date_earliest", "date_latest")
readonly_fields = (
"date_earliest",
"date_latest",
"date_sort_ascending",
"date_sort_descending",
"date_edtf",
)

fieldsets = (
(None, {"fields": ("date_display", "date_edtf_direct", "date_edtf")}),
(
"Computed Dates",
{
"classes": ("collapse",),
"fields": (
"date_earliest",
"date_latest",
"date_sort_ascending",
"date_sort_descending",
),
},
),
)


admin.site.register(TestEvent, TestEventAdmin)
4 changes: 0 additions & 4 deletions edtf_django_tests/edtf_integration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,5 @@ def __str__(self) -> str:
return (
f"Test Event: {self.date_display=}, "
f"{self.date_edtf_direct=}, "
f"{self.date_earliest=}, "
f"{self.date_latest=}, "
f"{self.date_sort_ascending=}, "
f"{self.date_sort_descending=}, "
f"{self.date_edtf=}"
)

0 comments on commit daf0d04

Please sign in to comment.