symposion_app/symposion/schedule/forms.py
2012-08-30 23:24:08 -04:00

24 lines
619 B
Python

from django import forms
from symposion.schedule.models import Slot, Presentation
class SlotEditForm(forms.Form):
presentation = forms.ModelChoiceField(
queryset=Presentation.objects.filter(slot__isnull=True),
required=True,
)
slot_pk = forms.CharField(
max_length=10,
widget=forms.HiddenInput,
required=True,
)
def clean_slot_pk(self):
value = self.cleaned_data["slot_pk"]
try:
Slot.objects.get(pk=value)
except Slot.DoesNotExist:
raise forms.ValidationError("Invalid slot.")
return value