Source code for intranet.apps.eighth.forms.admin.scheduling
from django import forms
from ...models import EighthScheduledActivity
[docs]class ScheduledActivityForm(forms.ModelForm):
"""Represents a row in the table activity scheduling admin page."""
# Whether the activity should actually be scheduled for the block
scheduled = forms.BooleanField(required=False)
unschedule = forms.BooleanField(required=False)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for fieldname in ["sponsors", "rooms"]:
self.fields[fieldname].help_text = None
for fieldname in ["block", "activity"]:
self.fields[fieldname].widget = forms.HiddenInput()
[docs] class Meta:
model = EighthScheduledActivity
fields = [
"cancelled",
"scheduled",
"unschedule",
"block",
"activity",
"rooms",
"capacity",
"sponsors",
"title",
"special",
"administrative",
"restricted",
"sticky",
"both_blocks",
"comments",
"admin_comments",
]
widgets = {
"capacity": forms.TextInput(),
"title": forms.TextInput(attrs={"size": 30}),
"comments": forms.Textarea(attrs={"rows": 2, "cols": 30}),
"admin_comments": forms.Textarea(attrs={"rows": 2, "cols": 30}),
}
[docs] def clean(self):
cleaned_data = super().clean()
cleaned_data["title"] = cleaned_data["title"].replace("\\", "/")
cleaned_data["comments"] = cleaned_data["comments"].replace("\\", "/")
cleaned_data["admin_comments"] = cleaned_data["admin_comments"].replace("\\", "/")
return cleaned_data