symposion_app/pinaxcon/proposals/forms.py

139 lines
3.2 KiB
Python
Raw Normal View History

import copy
from django import forms
2018-10-05 19:43:50 +00:00
from pinaxcon.proposals.fields import HelpTextField
from pinaxcon.proposals import models
2018-10-01 02:09:33 +00:00
DEFAULT_FIELDS = [
"title",
"target_audience",
"abstract",
"private_abstract",
"technical_requirements",
"project",
"project_url",
"recording_release",
"materials_release",
]
TALK_FORMAT_FIELDS = copy.copy(DEFAULT_FIELDS)
2018-09-30 04:04:28 +00:00
TALK_FORMAT_FIELDS.insert(2, "talk_format")
TALK_FORMAT_FIELDS.append("ticket_acknowledgement")
2017-03-05 07:34:15 +00:00
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 = [
"title",
"target_audience",
"abstract",
"private_abstract",
"technical_requirements",
"project",
"project_url",
"video_url",
"recording_release",
"materials_release",
]
class TutorialProposalForm(ProposalForm):
class Meta:
model = models.TutorialProposal
fields = [
"title",
"target_audience",
"abstract",
"private_abstract",
"technical_requirements",
"project",
"project_url",
"video_url",
"recording_release",
"materials_release",
]
class MiniconfProposalForm(ProposalForm):
class Meta:
model = models.MiniconfProposal
fields = [
"title",
"abstract",
"private_abstract",
"technical_requirements",
"recording_release",
"materials_release",
]
### LCA2020 Miniconfs
class MiniconfSessionProposalForm(ProposalForm):
def __init__(self, *a, **k):
super(MiniconfSessionProposalForm, self).__init__(*a, **k)
self.fields['ticket_acknowledgement'].required = True
GLAM_FIELDS = copy.copy(TALK_FORMAT_FIELDS)
GLAM_FIELDS.insert(3, "require_approval")
class GlamProposalForm(MiniconfSessionProposalForm):
class Meta:
model = models.GlamProposal
fields = GLAM_FIELDS
class KernelProposalForm(MiniconfSessionProposalForm):
class Meta:
model = models.KernelProposal
fields = TALK_FORMAT_FIELDS
HARDWARE_FIELDS = copy.copy(TALK_FORMAT_FIELDS)
HARDWARE_FIELDS.insert(3, "experience_level")
class OpenHardwareProposalForm(MiniconfSessionProposalForm):
def __init__(self, *a, **k):
super(OpenHardwareProposalForm, self).__init__(*a, **k)
self.fields['experience_level'].required = True
class Meta:
model = models.OpenHardwareProposal
fields = HARDWARE_FIELDS
SYSADMIN_FIELDS = copy.copy(TALK_FORMAT_FIELDS)
SYSADMIN_FIELDS.insert(3, "local_timezone")
SYSADMIN_FIELDS.insert(4, "tech_check")
class SysAdminProposalForm(MiniconfSessionProposalForm):
class Meta:
model = models.SysAdminProposal
fields = SYSADMIN_FIELDS