symposion_app/pinaxcon/proposals/forms.py
2021-08-09 21:12:43 +10:00

105 lines
2.3 KiB
Python

import copy
from django import forms
from pinaxcon.proposals.fields import HelpTextField
from pinaxcon.proposals import models
DEFAULT_FIELDS = [
"title",
"primary_topic",
"target_audience",
"experience_level",
"abstract",
"private_abstract",
"technical_requirements",
"project",
"project_url",
"video_url",
"require_approval",
"recording_release",
"materials_release",
]
MINICONF_SESSION_FORMAT_FIELDS = copy.copy(DEFAULT_FIELDS)
class ProposalForm(forms.ModelForm):
required_css_class = 'label-required'
def clean_description(self):
value = self.cleaned_data["description"]
if len(value) > 400:
raise forms.ValidationError(
u"The description must be less than 400 characters"
)
return value
class TalkProposalForm(ProposalForm):
class Meta:
model = models.TalkProposal
fields = copy.copy(DEFAULT_FIELDS)
class TutorialProposalForm(ProposalForm):
class Meta:
model = models.TutorialProposal
fields = copy.copy(DEFAULT_FIELDS)
class MiniconfProposalForm(ProposalForm):
class Meta:
model = models.MiniconfProposal
fields = [
"title",
"abstract",
"private_abstract",
"technical_requirements",
"recording_release",
"materials_release",
]
### LCA2022 Miniconfs
class MiniconfSessionProposalForm(ProposalForm):
pass
class GlamCommunityProposalForm(MiniconfSessionProposalForm):
class Meta:
model = models.GlamCommunityProposal
fields = MINICONF_SESSION_FORMAT_FIELDS
class KernelProposalForm(MiniconfSessionProposalForm):
class Meta:
model = models.KernelProposal
fields = MINICONF_SESSION_FORMAT_FIELDS
HARDWARE_FIELDS = copy.copy(MINICONF_SESSION_FORMAT_FIELDS)
HARDWARE_FIELDS.insert(4, "talk_format")
class OpenHardwareProposalForm(MiniconfSessionProposalForm):
def __init__(self, *a, **k):
super(OpenHardwareProposalForm, self).__init__(*a, **k)
self.fields['talk_format'].required = True
class Meta:
model = models.OpenHardwareProposal
fields = HARDWARE_FIELDS
class SysAdminProposalForm(MiniconfSessionProposalForm):
class Meta:
model = models.SysAdminProposal
fields = MINICONF_SESSION_FORMAT_FIELDS