summaryrefslogtreecommitdiffstats
path: root/django/sp_sso/invite/forms.py
blob: 1b5f3bb5a77dbdccff2734acbb393da88da8fb79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from django.utils.translation import ugettext_lazy as _
from django import forms

from .utils import get_invitaton_attributes_mapping, get_additional_prefilled_fields


class InvitationForm(forms.Form):
    def __init__(self, *args, **kwargs):
        super(InvitationForm, self).__init__(*args, **kwargs)
        # Add a help text for sending multiple invitations
        self.fields['email'].help_text = _(
            _('Blank-separated emails if multiple adresses.'))
        # Pre-filled fields are readonly
        for prefilled_field in get_invitaton_attributes_mapping().values() + \
                get_additional_prefilled_fields():
            if  kwargs['initial'].get(prefilled_field):
                self.fields[prefilled_field].widget.attrs['readonly'] = True

    # Blank-seperated list of recipient email adresses
    email = forms.CharField(
            max_length=100,
            label=_('Email address(es) where to send an invite'))
    # Invitation message that will be sent with the invite
    message = forms.CharField(
            widget=forms.Textarea(), max_length=999,
            label=_("Invitation message"), required=False)

    # Host identity
    #  If the RENATER identity federation is used, this field will be pre-
    #  filled with the host's EPPN (EduPersonPrincalName)
    hote_identite = forms.CharField(
            max_length=100, label=_("Your RENATER identifier"))

    hote_nom = forms.CharField(
            max_length=100, label=_("Your lastname"))

    hote_prenom = forms.CharField(
            max_length=100, label=_("Your firstname"))

    hote_etablissement = forms.CharField(
            max_length=100, label=_("Your institution"))

    hote_unite = forms.CharField(
            max_length=100, label=_("Your research unit"))

    hote_courriel = forms.CharField(
            max_length=100, label=_("Your email address"))