Files @ 5b9f4fb71ed7
Branch filter:

Location: symposion_app/symposion/proposals/forms.py - annotation

Martey Dodoo
Loosen Django package requirement.

Loosen Django requirement to allow versions greater or equal to 1.8.5,
instead of mandating 1.8.5. This makes it easier to use newer releases
of Django (e.g. the bugfix and security releases 1.8.6 or 1.8.7) with
symposion.
from __future__ import unicode_literals
from django import forms
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _

from symposion.proposals.models import SupportingDocument


# @@@ 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",
        ]