summaryrefslogtreecommitdiff
path: root/postgresqleu/membership/forms.py
blob: 8cd0f4d41c5a11d1c365f2063289d744d5ff32ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from django import forms

from .models import Member, get_config
from .util import validate_country


class MemberForm(forms.ModelForm):
    class Meta:
        model = Member
        fields = ('fullname', 'country', 'listed')

    def clean_country(self):
        if self.instance.country_exception:
            # No country checking for this member
            return self.cleaned_data['country']

        validate_country(get_config().country_validator, self.cleaned_data['country'])

        return self.cleaned_data['country']


class ProxyVoterForm(forms.Form):
    name = forms.CharField(min_length=5, max_length=100, help_text="Name of proxy voter. Leave empty to cancel proxy voting.", required=False)