70 lines
1.7 KiB
Python
70 lines
1.7 KiB
Python
from django.contrib import admin
|
|
|
|
from .models import Event, EventParticipation
|
|
|
|
|
|
class EventParticipationInline(admin.TabularInline):
|
|
"""Inline admin for event participations."""
|
|
|
|
model = EventParticipation
|
|
extra = 0
|
|
readonly_fields = ("user",)
|
|
fields = ("user", "status", "comment")
|
|
|
|
def has_add_permission(self, request, obj=None):
|
|
return False
|
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
return False
|
|
|
|
|
|
@admin.register(Event)
|
|
class EventAdmin(admin.ModelAdmin):
|
|
"""Admin configuration for Event model."""
|
|
|
|
list_display = ("title", "type", "date", "time", "location")
|
|
list_filter = ("type", "date")
|
|
search_fields = ("short_desc", "location", "desc")
|
|
date_hierarchy = "date"
|
|
ordering = ("-date",)
|
|
|
|
inlines = (EventParticipationInline,)
|
|
|
|
fieldsets = (
|
|
(
|
|
None,
|
|
{
|
|
"fields": ("type", "short_desc", "date", "end_date"),
|
|
},
|
|
),
|
|
(
|
|
"Time",
|
|
{
|
|
"fields": ("time", "meeting_time"),
|
|
},
|
|
),
|
|
(
|
|
"Location",
|
|
{
|
|
"fields": ("location", "map_location"),
|
|
},
|
|
),
|
|
(
|
|
"Description",
|
|
{
|
|
"fields": ("desc",),
|
|
"classes": ("collapse",),
|
|
},
|
|
),
|
|
)
|
|
|
|
|
|
@admin.register(EventParticipation)
|
|
class EventParticipationAdmin(admin.ModelAdmin):
|
|
"""Admin configuration for EventParticipation model."""
|
|
|
|
list_display = ("event", "user", "status", "comment")
|
|
list_filter = ("status", "event__date")
|
|
search_fields = ("user__username", "event__short_desc", "comment")
|
|
raw_id_fields = ("event", "user")
|