port to new django, AI automated
This commit is contained in:
@@ -1,20 +1,69 @@
|
||||
#from django.contrib import admin
|
||||
#from eventplanner.models import Event, EventParticipation
|
||||
#
|
||||
#
|
||||
#class EventParticipationInline(admin.TabularInline):
|
||||
# model = EventParticipation
|
||||
# extra = 1
|
||||
# readonly_fields = ('user',)
|
||||
# fields = ('user', 'status', 'comment',)
|
||||
# has_add_permission = lambda self, req: False
|
||||
# has_delete_permission = lambda self, req, obj: False
|
||||
#
|
||||
# template = "eventplanner/admin_tabular.html"
|
||||
#
|
||||
#
|
||||
#class EventAdmin(admin.ModelAdmin):
|
||||
# inlines = (EventParticipationInline,)
|
||||
#
|
||||
#
|
||||
#admin.site.register(Event, EventAdmin)
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user