Default to 1 registration in admin, "admitted"

This commit is contained in:
Midgard 2020-07-22 17:02:23 +02:00
parent f5aebd99b2
commit 033226a96f
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -1,10 +1,21 @@
from django.contrib import admin
from django import forms
from .models import Event, EventRegistration
class RegistrationInline(admin.StackedInline):
class RegistrationFormSet(forms.BaseInlineFormSet):
def __init__(self, *args, **kwargs):
kwargs["initial"] = [
{"state": EventRegistration.ADMITTED}
]
super().__init__(*args, **kwargs)
class RegistrationInline(admin.TabularInline):
model = EventRegistration
extra = 1
formset = RegistrationFormSet
class EventAdmin(admin.ModelAdmin):
inlines = [RegistrationInline]