kers/events/admin.py

24 lines
570 B
Python
Raw Normal View History

2020-07-21 22:24:45 +02:00
from django.contrib import admin
from django import forms
2020-07-21 22:24:45 +02:00
2020-07-22 04:08:30 +02:00
from .models import Event, EventRegistration
2020-07-22 05:02:01 +02:00
class RegistrationFormSet(forms.BaseInlineFormSet):
def __init__(self, *args, **kwargs):
kwargs["initial"] = [
{"state": EventRegistration.ADMITTED}
]
super().__init__(*args, **kwargs)
class RegistrationInline(admin.TabularInline):
2020-07-22 05:02:01 +02:00
model = EventRegistration
extra = 1
formset = RegistrationFormSet
2020-07-22 05:02:01 +02:00
class EventAdmin(admin.ModelAdmin):
inlines = [RegistrationInline]
admin.site.register(Event, EventAdmin)