forked from AFPy/PonyConf
fix talk staff form: filter room on site
This commit is contained in:
parent
d0b99d0575
commit
10980a4cfe
|
@ -38,11 +38,13 @@ class TalkForm(forms.ModelForm):
|
||||||
fields = ('category', 'title', 'description','notes')
|
fields = ('category', 'title', 'description','notes')
|
||||||
|
|
||||||
|
|
||||||
class TalkStaffForm(TalkForm):
|
class TalkStaffForm(forms.ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
tracks = kwargs.pop('tracks')
|
conference = kwargs.pop('conference')
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['track'].queryset = tracks
|
self.fields['category'].queryset = TalkCategory.objects.filter(site=conference.site)
|
||||||
|
self.fields['track'].queryset = Track.objects.filter(site=conference.site)
|
||||||
|
self.fields['room'].queryset = Room.objects.filter(site=conference.site)
|
||||||
|
|
||||||
class Meta(TalkForm.Meta):
|
class Meta(TalkForm.Meta):
|
||||||
fields = ('category', 'track', 'title', 'description', 'notes', 'start_date', 'duration', 'room',)
|
fields = ('category', 'track', 'title', 'description', 'notes', 'start_date', 'duration', 'room',)
|
||||||
|
|
|
@ -13,6 +13,15 @@ class OnSiteMixin:
|
||||||
return super().get_queryset().filter(site=self.request.conference.site)
|
return super().get_queryset().filter(site=self.request.conference.site)
|
||||||
|
|
||||||
|
|
||||||
|
class OnSiteFormMixin:
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super().get_form_kwargs()
|
||||||
|
kwargs.update({
|
||||||
|
'conference': self.request.conference,
|
||||||
|
})
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
class OnSiteAdminMixin:
|
class OnSiteAdminMixin:
|
||||||
exclude = ('site',)
|
exclude = ('site',)
|
||||||
|
|
||||||
|
|
21
cfp/views.py
21
cfp/views.py
|
@ -15,7 +15,7 @@ from functools import reduce
|
||||||
from mailing.models import Message
|
from mailing.models import Message
|
||||||
from mailing.forms import MessageForm
|
from mailing.forms import MessageForm
|
||||||
from .decorators import staff_required
|
from .decorators import staff_required
|
||||||
from .mixins import StaffRequiredMixin, OnSiteMixin
|
from .mixins import StaffRequiredMixin, OnSiteMixin, OnSiteFormMixin
|
||||||
from .utils import is_staff
|
from .utils import is_staff
|
||||||
from .models import Participant, Talk, TalkCategory, Vote, Track, Room
|
from .models import Participant, Talk, TalkCategory, Vote, Track, Room
|
||||||
from .forms import TalkForm, TalkStaffForm, TalkFilterForm, TalkActionForm, \
|
from .forms import TalkForm, TalkStaffForm, TalkFilterForm, TalkActionForm, \
|
||||||
|
@ -390,21 +390,13 @@ You can now:
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class TalkUpdate(StaffRequiredMixin, OnSiteMixin, UpdateView):
|
class TalkUpdate(StaffRequiredMixin, OnSiteMixin, OnSiteFormMixin, UpdateView):
|
||||||
model = Talk
|
model = Talk
|
||||||
slug_field = 'token'
|
slug_field = 'token'
|
||||||
slug_url_kwarg = 'talk_id'
|
slug_url_kwarg = 'talk_id'
|
||||||
form_class = TalkStaffForm
|
form_class = TalkStaffForm
|
||||||
template_name = 'cfp/staff/talk_form.html'
|
template_name = 'cfp/staff/talk_form.html'
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
|
||||||
kwargs = super().get_form_kwargs()
|
|
||||||
kwargs.update({
|
|
||||||
'categories': TalkCategory.objects.filter(site=self.request.conference.site),
|
|
||||||
'tracks': Track.objects.filter(site=self.request.conference.site),
|
|
||||||
})
|
|
||||||
return kwargs
|
|
||||||
|
|
||||||
|
|
||||||
class TrackMixin(OnSiteMixin):
|
class TrackMixin(OnSiteMixin):
|
||||||
model = Track
|
model = Track
|
||||||
|
@ -414,18 +406,11 @@ class TrackList(StaffRequiredMixin, TrackMixin, ListView):
|
||||||
template_name = 'cfp/staff/track_list.html'
|
template_name = 'cfp/staff/track_list.html'
|
||||||
|
|
||||||
|
|
||||||
class TrackFormMixin(TrackMixin):
|
class TrackFormMixin(OnSiteFormMixin, TrackMixin):
|
||||||
template_name = 'cfp/staff/track_form.html'
|
template_name = 'cfp/staff/track_form.html'
|
||||||
form_class = TrackForm
|
form_class = TrackForm
|
||||||
success_url = reverse_lazy('track-list')
|
success_url = reverse_lazy('track-list')
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
|
||||||
kwargs = super().get_form_kwargs()
|
|
||||||
kwargs.update({
|
|
||||||
'conference': self.request.conference,
|
|
||||||
})
|
|
||||||
return kwargs
|
|
||||||
|
|
||||||
|
|
||||||
class TrackCreate(StaffRequiredMixin, TrackFormMixin, CreateView):
|
class TrackCreate(StaffRequiredMixin, TrackFormMixin, CreateView):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user