29 lines
828 B
Python
29 lines
828 B
Python
|
from django.contrib import admin
|
||
|
|
||
|
from .models import Reservation, Resource, UserReservation
|
||
|
|
||
|
|
||
|
@admin.register(Resource)
|
||
|
class ResourceAdmin(admin.ModelAdmin):
|
||
|
list_display = ["name", "parent", "min_length", "max_length"]
|
||
|
list_filter = ["parent"]
|
||
|
search_fields = ["name"]
|
||
|
show_facets = admin.ShowFacets.ALWAYS
|
||
|
|
||
|
|
||
|
@admin.register(Reservation)
|
||
|
class ReservationAdmin(admin.ModelAdmin):
|
||
|
list_display = ["_resources", "start", "end"]
|
||
|
readonly_fields = ["google_calendar_event_id"]
|
||
|
list_filter = ["resources"]
|
||
|
show_facets = admin.ShowFacets.ALWAYS
|
||
|
|
||
|
@admin.display()
|
||
|
def _resources(self, obj: Reservation):
|
||
|
return list(obj.resources.all()) or None
|
||
|
|
||
|
|
||
|
@admin.register(UserReservation)
|
||
|
class UserReservationAdmin(ReservationAdmin):
|
||
|
list_display = ["_resources", "user", "start", "end"]
|