2012-07-12 04:38:39 +00:00
|
|
|
from django import forms
|
|
|
|
from django.db.models import Q
|
2015-06-26 03:46:09 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2012-07-12 04:38:39 +00:00
|
|
|
|
|
|
|
from symposion.proposals.models import SupportingDocument
|
|
|
|
|
|
|
|
|
|
|
|
# @@@ generic proposal form
|
|
|
|
|
|
|
|
|
|
|
|
class AddSpeakerForm(forms.Form):
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2017-04-24 12:50:48 +00:00
|
|
|
required_css_class = 'label-required'
|
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
email = forms.EmailField(
|
2015-06-26 03:46:09 +00:00
|
|
|
label=_("Email address of new speaker (use their email address, not yours)")
|
2012-07-12 04:38:39 +00:00
|
|
|
)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
self.proposal = kwargs.pop("proposal")
|
|
|
|
super(AddSpeakerForm, self).__init__(*args, **kwargs)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
def clean_email(self):
|
|
|
|
value = self.cleaned_data["email"]
|
|
|
|
exists = self.proposal.additional_speakers.filter(
|
|
|
|
Q(user=None, invite_email=value) |
|
|
|
|
Q(user__email=value)
|
|
|
|
).exists()
|
|
|
|
if exists:
|
|
|
|
raise forms.ValidationError(
|
2015-06-26 03:46:09 +00:00
|
|
|
_("This email address has already been invited to your talk proposal")
|
2012-07-12 04:38:39 +00:00
|
|
|
)
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
|
|
class SupportingDocumentCreateForm(forms.ModelForm):
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2017-04-24 12:50:48 +00:00
|
|
|
required_css_class = 'label-required'
|
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
class Meta:
|
|
|
|
model = SupportingDocument
|
|
|
|
fields = [
|
|
|
|
"file",
|
|
|
|
"description",
|
|
|
|
]
|