added ordering to presentations

This commit is contained in:
Brian Rosner 2012-09-19 19:18:09 -06:00
parent f98a3f2f9a
commit 453a443b5f

View file

@ -6,14 +6,14 @@ from symposion.schedule.models import Presentation
class SlotEditForm(forms.Form):
presentation = forms.ModelChoiceField(queryset=Presentation.objects.all())
presentation = forms.ModelChoiceField(queryset=Presentation.objects.none())
def __init__(self, *args, **kwargs):
content = kwargs.pop("content", None)
if content:
kwargs.setdefault("initial", {})["presentation"] = content
super(SlotEditForm, self).__init__(*args, **kwargs)
queryset = self.fields["presentation"].queryset
queryset = Presentation.objects.order_by("proposal_base__pk")
if content:
queryset = queryset.filter(Q(slot=None) | Q(pk=content.pk))
self.fields["presentation"].required = False