2012-08-31 03:24:08 +00:00
|
|
|
from django import forms
|
2012-09-14 05:17:32 +00:00
|
|
|
from django.db.models import Q
|
2012-08-31 03:24:08 +00:00
|
|
|
|
2012-08-31 05:12:15 +00:00
|
|
|
from symposion.schedule.models import Presentation
|
2012-08-31 03:24:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SlotEditForm(forms.Form):
|
|
|
|
|
|
|
|
presentation = forms.ModelChoiceField(
|
2012-09-14 05:17:32 +00:00
|
|
|
queryset=Presentation.objects.all(),
|
2012-08-31 03:24:08 +00:00
|
|
|
required=True,
|
|
|
|
)
|
2012-09-14 05:17:32 +00:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
presentation = kwargs.get("initial", {}).get("presentation")
|
|
|
|
super(SlotEditForm, self).__init__(*args, **kwargs)
|
|
|
|
queryset = self.fields["presentation"].queryset
|
|
|
|
if presentation:
|
|
|
|
queryset = queryset.filter(Q(slot=None) | Q(pk=presentation.pk))
|
|
|
|
else:
|
|
|
|
queryset = queryset.filter(slot=None)
|
|
|
|
self.fields["presentation"].queryset = queryset
|