Verified Commit 4c814a6d authored by Philipp Sebastian Sommer's avatar Philipp Sebastian Sommer
Browse files

limit presentation types to the event ones

parent 0d85f9f4
Pipeline #135374 passed with stage
in 5 minutes and 20 seconds
......@@ -84,6 +84,8 @@ class ContributionForm(utils.PermissionCheckFormMixin, forms.ModelForm):
self.disable_field("event")
self.disable_field("submitter")
event = self.get_initial_for_field(self.fields["event"], "event")
if not isinstance(event, Event):
event = Event.objects.get(pk=event)
if self.instance.pk:
licenses = event.submission_licenses.all()
values = licenses.values_list("pk")
......@@ -95,6 +97,9 @@ class ContributionForm(utils.PermissionCheckFormMixin, forms.ModelForm):
self.fields["license"].queryset = licenses
self.fields["license"].help_text += LICENSE_INFO
field = self.fields["presentation_type"]
field.queryset = field.queryset.filter(event=event)
def update_from_registered_user(self, user: User):
event: models.Event
try:
......@@ -303,11 +308,13 @@ class SessionForm(utils.PermissionCheckFormMixin, forms.ModelForm):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.disable_field("event")
if "meeting_rooms" in self.fields:
event = self.get_initial_for_field(self.fields["event"], "event")
if not isinstance(event, Event):
event = Event.objects.get(pk=event)
self.fields["meeting_rooms"].queryset = event.meetingroom_set.all()
event = self.get_initial_for_field(self.fields["event"], "event")
if not isinstance(event, Event):
event = Event.objects.get(pk=event)
for field_name in ["meeting_rooms", "presentation_type"]:
if field_name in self.fields:
field = self.fields[field_name]
field.queryset = field.queryset.filter(event=event)
def update_from_registered_user(self, user: User):
if not user.has_perm("events.schedule_session", self.initial["event"]):
......@@ -360,6 +367,16 @@ class SlotForm(forms.ModelForm):
super().__init__(*args, **kwargs)
self.fields["session"].disabled = True
session: models.Session = self.get_initial_for_field(
self.fields["session"], "session"
)
if not isinstance(session, models.Session):
session = models.Session.objects.get(pk=session)
event = session.event
field = self.fields["presentation_type"]
field.queryset = field.queryset.filter(event=event)
SessionSlotFormset = forms.inlineformset_factory(
models.Session,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment