Default to 1 registration in admin, "admitted"
This commit is contained in:
parent
f5aebd99b2
commit
033226a96f
1 changed files with 12 additions and 1 deletions
|
@ -1,10 +1,21 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django import forms
|
||||||
|
|
||||||
from .models import Event, EventRegistration
|
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
|
model = EventRegistration
|
||||||
|
extra = 1
|
||||||
|
formset = RegistrationFormSet
|
||||||
|
|
||||||
class EventAdmin(admin.ModelAdmin):
|
class EventAdmin(admin.ModelAdmin):
|
||||||
inlines = [RegistrationInline]
|
inlines = [RegistrationInline]
|
||||||
|
|
Loading…
Reference in a new issue