a95825ede8
- Things are suggested in python3 porting guide. https://docs.djangoproject.com/en/1.8/topics/python3/ 1. adding ```from django.utils.encoding import python_2_unicode_compatible``` 2. ``` __str__``` instead of ```__unicode__``` https://docs.djangoproject.com/en/1.8/topics/python3/#str-and-unicode-methods 3. Adding ```from __future__ import unicode_literals``` at the top of your Python modules https://docs.djangoproject.com/en/1.8/topics/python3/#unicode-literals 4. Removing the `u` prefix before unicode strings; https://docs.djangoproject.com/en/1.8/topics/python3/#unicode-literals - also closed #66 Signed-off-by: Hiroshi Miura <miurahr@linux.com>
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from __future__ import unicode_literals
|
|
from django import forms
|
|
from django.db.models import Q
|
|
|
|
from symposion.proposals.models import SupportingDocument
|
|
# from markitup.widgets import MarkItUpWidget
|
|
|
|
|
|
# @@@ generic proposal form
|
|
|
|
|
|
class AddSpeakerForm(forms.Form):
|
|
|
|
email = forms.EmailField(
|
|
label="Email address of new speaker (use their email address, not yours)"
|
|
)
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
self.proposal = kwargs.pop("proposal")
|
|
super(AddSpeakerForm, self).__init__(*args, **kwargs)
|
|
|
|
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(
|
|
"This email address has already been invited to your talk proposal"
|
|
)
|
|
return value
|
|
|
|
|
|
class SupportingDocumentCreateForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = SupportingDocument
|
|
fields = [
|
|
"file",
|
|
"description",
|
|
]
|